|
|
|
import { EnvelopePlus } from './types';
|
|
|
|
export { downloadAttachment } from './attachments';
|
|
|
|
import { v4 as uuidv4 } from 'uuid';
|
|
|
|
|
|
|
|
import { addToCache, getAllFromCache, getAllFromCacheForSource, removeFromCache } from './cache';
|
Session 1.7.5 (#2094)
* Added message requests disabled for now
* no longer showing empty space for conversations moved from list.
* Added syncing accepting of contact between running instances.
* Adding blocking of individual requests and syncing of block to devices. Added approval by replying to a message.
* fixed typos for translations and method name.
* Blocking, accepting on click and accepting on msg send
working across clients.
* adding setting of active_at to hide unapproved messages.
* adding feature flag for config message receiving
* fix archlinux pw unused issue
on archlinux, the appimage links to the system sqlite by default which
does not support sqlcipher
* hide activeAt = 0 convo from search results
Fixes #2033
* opengroup messages from blocked user are dropped
Fixes #2019
* opengroup messages from blocked user are dropped
Fixes #2019
* dismiss a call when answered from another of our devices
* add data-testid for leftpane sections and edit profile dialog
* update turn servers
* cleanup sessionprotobuf
* move the state of calling to its own slice
* no video track by default and will be turn ON if asked to
* message request refactoring.
* create offer and answer ourselves and do not use the negotiation needed
event.
this event is causing us to loop in negotiation needed when each side
try to create one, gets the answer and so on...
* auto select the first audio input on connection success webrtc
* add a way to choose the audioouput/mute a webrtc call
* mute audio from bg when video is in fullscreen
this is to avoid having two times the remote sound playing
one in the bg and one in the fullscreen
* Adding improvements to message request handling.
* Only updating approval when it is a true value as we consider a block a decline.
* Linting and formatting.
* More formatting and linting
* fixing merge conflicts
* linting and formatting changes
* darken a bit the green of sent message box in light theme
* disable deduplication based serverId+sender
only use the serverTimestamp+sender for searching because
serverId+sender might have false positive
* Fixing up block all logic.
* speed up fetching closed group's members avatar
* Applying PR changes.
* cleanup props passing of avatar and name with a custom hook
* fix a bug releasing the decrypted attachment blobs too early
* Adding trigger logic for conversation filtering of requests.
* Fixing rimraf transpile bug. Adding PR fixes - icon buttons.
* Minor call tweaks (#2051)
* show missed-call,started-call and answered call notification in chat
* fix types for createLastMessageUpdate
* show incoming dialog if we have a pending call when enable call receptio
* simplify a bit the avatar component
* move disableDrag to a custom hook
* speed up hash colors of avatarPlaceHolders
* fixup text selection and double click reply on message
* keep avatar decoded items longer before releasing memory
* add incoming/outgoing/missed call notification
also, merge that notification with the timer and group notification
component
* hangup call if no answer after 30sec
* refactor SessionInput using hook + add testid field for recovery
* disable message request feature flag for now
* fix merge issue
* force loading screen to be black instead of white
for our dark theme user's eyes safety
* Fetch translations (#2056)
* show missed-call,started-call and answered call notification in chat
* fix types for createLastMessageUpdate
* show incoming dialog if we have a pending call when enable call receptio
* simplify a bit the avatar component
* move disableDrag to a custom hook
* speed up hash colors of avatarPlaceHolders
* fixup text selection and double click reply on message
* keep avatar decoded items longer before releasing memory
* add incoming/outgoing/missed call notification
also, merge that notification with the timer and group notification
component
* hangup call if no answer after 30sec
* refactor SessionInput using hook + add testid field for recovery
* disable message request feature flag for now
* fix merge issue
* force loading screen to be black instead of white
for our dark theme user's eyes safety
* add type for i18n to run update after crowdin fetch with tools/updateI18nKeysType.py
* update to latest translations
* Open group regex fixes (#2058)
* Open group URL regex fixes
- Capital letters in room tokens were not being accepted (it eventually
gets lower-cased internally, which works fine, but that happens
*after* the URL is tested for acceptability).
- `-` in room was not being allowed (it is and always has been on SOGS,
session-android, and session-ios).
- single-letter room ids are valid, but only 2+ letter ids were being
accepted.
- complete URL regex wasn't anchored so something like
`garbagehttps://example.com/room?public_key=<64hex>moregarbage` was
being accepted in the GUI input (it fails later when other code tries
to parse it as a URL).
- removed `m` modifier from open group regex: without anchors it wasn't
doing anything anyway, but *with* anchors it would still allow
leading/trailing garbage if delineated by newlines.
- public key regex was accepting g-z letters, and not accepting A-F.
- various regex cleanups:
- use non-capture groups (?:...) rather than capturing groups (...)
- avoid repetition in host segment matching
- tightened up host pattern matching a bit:
- DNS host segments have a max length of 63
- Limit port max length to 5, and disallow starting with 0
* Show an error when the open group URL is invalid
It's quite disconcerting when you have a bad open group URL and try to
add it and the join button just "doesn't work" without any feedback at
all. Fix it to show an error message. (There is already an i18n entry
for this because this same message is thrown if the URL can't be parsed
later on).
* Add call duration (#2059)
* add call duration once connected
* close incoming call dialog if endCall from same sender
* disable message request toggle if featureFlag is OFF
* Cleanup message request (#2063)
* close incoming call dialog if endCall from seame sender
* disable message request toggle if featureFlag is OFF
* cleanup UI of message requests
* mark all existing conversations as approved in a migration
* fix regex with conversationID for opengroups
* Various UI fixes (#2070)
* cleanup unused convo json fields in db
* display a toast if the user is not approved yet on call OFFER received
* enable CBR for calls
* do not update active_at on configMessage if !!active_at
* remove mkdirp dependency
* disable call button if focused convo is blocked
* quote: do not include the full body in quote, but just the first 100
* click on the edit profile qr code padding
* Allow longer input for opengroup join overlay
Fixes #2068
* Fix overlay feature for start new session button
* make ringing depend on redux CALL status
* turn ON read-receipt by default
* keep read-receipts disabled by default (#2071)
* refactor most of the components to outside of their Session folder (#2072)
* refactor most of the components to outside of their Session folder
* finish moving overlay and memberListItem to react hook
* fix bug with kicked member len >2 not being displayed
also sort admins first in UpdateGroupMembers dialog
* fix admin leaving text of groupNotification
* add a useFocusMount hook to focus input fields on mount
* make click avatar convo item open only user dialog
* cleanup config default.json
* make sure to use convoController to build sync message
* disable showing pubkey on opengroups
* add a pause on audio playback
Fixes #2079
* Minor styling fix for large amount of message requests (#2080)
* Minor styling fix for large amount of message requests
* Vertical center fix for message request banner.
* removing top margin from banner again.
* reactify group updates text bubble from redux store (#2083)
* add crown icon for closed group admins (#2084)
* disable call for now + fix left pane actions overflow (#2085)
* Fix attachment dl freeze (#2086)
* fix attachment download freezing app for some opengroups
* make registration page work with smaller height
* Unban UI (#2091)
* adding basic functionaliy for unbanning a user
* merge ban and unban user dialog in to one dialog
Co-authored-by: warrickct <warrickct@gmail.com>
* use React Provider for convoListItem (#2088)
this is to avoid passing down the prop to all the components
* fix closed group updates undefined on no names (#2092)
Co-authored-by: Warrick Corfe-Tan <warrickct@gmail.com>
Co-authored-by: Jason Rhinelander <jason@imaginary.ca>
Co-authored-by: Warrick <wcor690@aucklanduni.ac.nz>
3 years ago
|
|
|
import { processMessage } from '../session/apis/snode_api/swarmPolling';
|
|
|
|
import { onError } from './errors';
|
|
|
|
|
|
|
|
// innerHandleContentMessage is only needed because of code duplication in handleDecryptedEnvelope...
|
|
|
|
import { handleContentMessage, innerHandleContentMessage } from './contentMessage';
|
|
|
|
import _, { noop } from 'lodash';
|
|
|
|
|
|
|
|
export { processMessage };
|
|
|
|
|
|
|
|
import { createMessage, isMessageDuplicate, MessageCreationData } from './dataMessage';
|
|
|
|
|
|
|
|
import { getEnvelopeId } from './common';
|
|
|
|
import { StringUtils, UserUtils } from '../session/utils';
|
|
|
|
import { SignalService } from '../protobuf';
|
|
|
|
import { getConversationController } from '../session/conversations';
|
|
|
|
import { removeUnprocessed } from '../data/data';
|
|
|
|
import { ConversationTypeEnum } from '../models/conversation';
|
Session 1.7.5 (#2094)
* Added message requests disabled for now
* no longer showing empty space for conversations moved from list.
* Added syncing accepting of contact between running instances.
* Adding blocking of individual requests and syncing of block to devices. Added approval by replying to a message.
* fixed typos for translations and method name.
* Blocking, accepting on click and accepting on msg send
working across clients.
* adding setting of active_at to hide unapproved messages.
* adding feature flag for config message receiving
* fix archlinux pw unused issue
on archlinux, the appimage links to the system sqlite by default which
does not support sqlcipher
* hide activeAt = 0 convo from search results
Fixes #2033
* opengroup messages from blocked user are dropped
Fixes #2019
* opengroup messages from blocked user are dropped
Fixes #2019
* dismiss a call when answered from another of our devices
* add data-testid for leftpane sections and edit profile dialog
* update turn servers
* cleanup sessionprotobuf
* move the state of calling to its own slice
* no video track by default and will be turn ON if asked to
* message request refactoring.
* create offer and answer ourselves and do not use the negotiation needed
event.
this event is causing us to loop in negotiation needed when each side
try to create one, gets the answer and so on...
* auto select the first audio input on connection success webrtc
* add a way to choose the audioouput/mute a webrtc call
* mute audio from bg when video is in fullscreen
this is to avoid having two times the remote sound playing
one in the bg and one in the fullscreen
* Adding improvements to message request handling.
* Only updating approval when it is a true value as we consider a block a decline.
* Linting and formatting.
* More formatting and linting
* fixing merge conflicts
* linting and formatting changes
* darken a bit the green of sent message box in light theme
* disable deduplication based serverId+sender
only use the serverTimestamp+sender for searching because
serverId+sender might have false positive
* Fixing up block all logic.
* speed up fetching closed group's members avatar
* Applying PR changes.
* cleanup props passing of avatar and name with a custom hook
* fix a bug releasing the decrypted attachment blobs too early
* Adding trigger logic for conversation filtering of requests.
* Fixing rimraf transpile bug. Adding PR fixes - icon buttons.
* Minor call tweaks (#2051)
* show missed-call,started-call and answered call notification in chat
* fix types for createLastMessageUpdate
* show incoming dialog if we have a pending call when enable call receptio
* simplify a bit the avatar component
* move disableDrag to a custom hook
* speed up hash colors of avatarPlaceHolders
* fixup text selection and double click reply on message
* keep avatar decoded items longer before releasing memory
* add incoming/outgoing/missed call notification
also, merge that notification with the timer and group notification
component
* hangup call if no answer after 30sec
* refactor SessionInput using hook + add testid field for recovery
* disable message request feature flag for now
* fix merge issue
* force loading screen to be black instead of white
for our dark theme user's eyes safety
* Fetch translations (#2056)
* show missed-call,started-call and answered call notification in chat
* fix types for createLastMessageUpdate
* show incoming dialog if we have a pending call when enable call receptio
* simplify a bit the avatar component
* move disableDrag to a custom hook
* speed up hash colors of avatarPlaceHolders
* fixup text selection and double click reply on message
* keep avatar decoded items longer before releasing memory
* add incoming/outgoing/missed call notification
also, merge that notification with the timer and group notification
component
* hangup call if no answer after 30sec
* refactor SessionInput using hook + add testid field for recovery
* disable message request feature flag for now
* fix merge issue
* force loading screen to be black instead of white
for our dark theme user's eyes safety
* add type for i18n to run update after crowdin fetch with tools/updateI18nKeysType.py
* update to latest translations
* Open group regex fixes (#2058)
* Open group URL regex fixes
- Capital letters in room tokens were not being accepted (it eventually
gets lower-cased internally, which works fine, but that happens
*after* the URL is tested for acceptability).
- `-` in room was not being allowed (it is and always has been on SOGS,
session-android, and session-ios).
- single-letter room ids are valid, but only 2+ letter ids were being
accepted.
- complete URL regex wasn't anchored so something like
`garbagehttps://example.com/room?public_key=<64hex>moregarbage` was
being accepted in the GUI input (it fails later when other code tries
to parse it as a URL).
- removed `m` modifier from open group regex: without anchors it wasn't
doing anything anyway, but *with* anchors it would still allow
leading/trailing garbage if delineated by newlines.
- public key regex was accepting g-z letters, and not accepting A-F.
- various regex cleanups:
- use non-capture groups (?:...) rather than capturing groups (...)
- avoid repetition in host segment matching
- tightened up host pattern matching a bit:
- DNS host segments have a max length of 63
- Limit port max length to 5, and disallow starting with 0
* Show an error when the open group URL is invalid
It's quite disconcerting when you have a bad open group URL and try to
add it and the join button just "doesn't work" without any feedback at
all. Fix it to show an error message. (There is already an i18n entry
for this because this same message is thrown if the URL can't be parsed
later on).
* Add call duration (#2059)
* add call duration once connected
* close incoming call dialog if endCall from same sender
* disable message request toggle if featureFlag is OFF
* Cleanup message request (#2063)
* close incoming call dialog if endCall from seame sender
* disable message request toggle if featureFlag is OFF
* cleanup UI of message requests
* mark all existing conversations as approved in a migration
* fix regex with conversationID for opengroups
* Various UI fixes (#2070)
* cleanup unused convo json fields in db
* display a toast if the user is not approved yet on call OFFER received
* enable CBR for calls
* do not update active_at on configMessage if !!active_at
* remove mkdirp dependency
* disable call button if focused convo is blocked
* quote: do not include the full body in quote, but just the first 100
* click on the edit profile qr code padding
* Allow longer input for opengroup join overlay
Fixes #2068
* Fix overlay feature for start new session button
* make ringing depend on redux CALL status
* turn ON read-receipt by default
* keep read-receipts disabled by default (#2071)
* refactor most of the components to outside of their Session folder (#2072)
* refactor most of the components to outside of their Session folder
* finish moving overlay and memberListItem to react hook
* fix bug with kicked member len >2 not being displayed
also sort admins first in UpdateGroupMembers dialog
* fix admin leaving text of groupNotification
* add a useFocusMount hook to focus input fields on mount
* make click avatar convo item open only user dialog
* cleanup config default.json
* make sure to use convoController to build sync message
* disable showing pubkey on opengroups
* add a pause on audio playback
Fixes #2079
* Minor styling fix for large amount of message requests (#2080)
* Minor styling fix for large amount of message requests
* Vertical center fix for message request banner.
* removing top margin from banner again.
* reactify group updates text bubble from redux store (#2083)
* add crown icon for closed group admins (#2084)
* disable call for now + fix left pane actions overflow (#2085)
* Fix attachment dl freeze (#2086)
* fix attachment download freezing app for some opengroups
* make registration page work with smaller height
* Unban UI (#2091)
* adding basic functionaliy for unbanning a user
* merge ban and unban user dialog in to one dialog
Co-authored-by: warrickct <warrickct@gmail.com>
* use React Provider for convoListItem (#2088)
this is to avoid passing down the prop to all the components
* fix closed group updates undefined on no names (#2092)
Co-authored-by: Warrick Corfe-Tan <warrickct@gmail.com>
Co-authored-by: Jason Rhinelander <jason@imaginary.ca>
Co-authored-by: Warrick <wcor690@aucklanduni.ac.nz>
3 years ago
|
|
|
import { getOpenGroupV2ConversationId } from '../session/apis/open_group_api/utils/OpenGroupUtils';
|
|
|
|
import { OpenGroupMessageV2 } from '../session/apis/open_group_api/opengroupV2/OpenGroupMessageV2';
|
|
|
|
import { OpenGroupRequestCommonType } from '../session/apis/open_group_api/opengroupV2/ApiUtil';
|
|
|
|
import { handleMessageJob } from './queuedJob';
|
|
|
|
import { fromBase64ToArray } from '../session/utils/String';
|
|
|
|
import { removeMessagePadding } from '../session/crypto/BufferPadding';
|
|
|
|
import { isDuplicateBasedOnHash } from './hashDuplicateFilter';
|
|
|
|
import { createTaskWithTimeout } from '../session/utils/TaskWithTimeout';
|
|
|
|
import { perfEnd, perfStart } from '../session/utils/Performance';
|
|
|
|
|
|
|
|
// TODO: check if some of these exports no longer needed
|
|
|
|
|
|
|
|
interface ReqOptions {
|
|
|
|
conversationId: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
const incomingMessagePromises: Array<Promise<any>> = [];
|
|
|
|
|
|
|
|
async function handleEnvelope(envelope: EnvelopePlus, messageHash?: string) {
|
|
|
|
if (envelope.content && envelope.content.length > 0) {
|
|
|
|
return handleContentMessage(envelope, messageHash);
|
|
|
|
}
|
|
|
|
|
|
|
|
await removeFromCache(envelope);
|
|
|
|
throw new Error('Received message with no content and no legacyMessage');
|
|
|
|
}
|
|
|
|
|
|
|
|
class EnvelopeQueue {
|
|
|
|
// Last pending promise
|
|
|
|
private pending: Promise<any> = Promise.resolve();
|
|
|
|
|
|
|
|
public add(task: any): void {
|
|
|
|
const promise = this.pending.then(task, task);
|
|
|
|
this.pending = promise;
|
|
|
|
|
|
|
|
this.pending.then(this.cleanup.bind(this, promise), this.cleanup.bind(this, promise));
|
|
|
|
}
|
|
|
|
|
|
|
|
private cleanup(promise: Promise<any>) {
|
|
|
|
// We want to clear out the promise chain whenever possible because it could
|
|
|
|
// lead to large memory usage over time:
|
|
|
|
// https://github.com/nodejs/node/issues/6673#issuecomment-244331609
|
|
|
|
if (this.pending === promise) {
|
|
|
|
this.pending = Promise.resolve();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const envelopeQueue = new EnvelopeQueue();
|
|
|
|
|
|
|
|
function queueEnvelope(envelope: EnvelopePlus, messageHash?: string) {
|
|
|
|
const id = getEnvelopeId(envelope);
|
Session 1.7.5 (#2094)
* Added message requests disabled for now
* no longer showing empty space for conversations moved from list.
* Added syncing accepting of contact between running instances.
* Adding blocking of individual requests and syncing of block to devices. Added approval by replying to a message.
* fixed typos for translations and method name.
* Blocking, accepting on click and accepting on msg send
working across clients.
* adding setting of active_at to hide unapproved messages.
* adding feature flag for config message receiving
* fix archlinux pw unused issue
on archlinux, the appimage links to the system sqlite by default which
does not support sqlcipher
* hide activeAt = 0 convo from search results
Fixes #2033
* opengroup messages from blocked user are dropped
Fixes #2019
* opengroup messages from blocked user are dropped
Fixes #2019
* dismiss a call when answered from another of our devices
* add data-testid for leftpane sections and edit profile dialog
* update turn servers
* cleanup sessionprotobuf
* move the state of calling to its own slice
* no video track by default and will be turn ON if asked to
* message request refactoring.
* create offer and answer ourselves and do not use the negotiation needed
event.
this event is causing us to loop in negotiation needed when each side
try to create one, gets the answer and so on...
* auto select the first audio input on connection success webrtc
* add a way to choose the audioouput/mute a webrtc call
* mute audio from bg when video is in fullscreen
this is to avoid having two times the remote sound playing
one in the bg and one in the fullscreen
* Adding improvements to message request handling.
* Only updating approval when it is a true value as we consider a block a decline.
* Linting and formatting.
* More formatting and linting
* fixing merge conflicts
* linting and formatting changes
* darken a bit the green of sent message box in light theme
* disable deduplication based serverId+sender
only use the serverTimestamp+sender for searching because
serverId+sender might have false positive
* Fixing up block all logic.
* speed up fetching closed group's members avatar
* Applying PR changes.
* cleanup props passing of avatar and name with a custom hook
* fix a bug releasing the decrypted attachment blobs too early
* Adding trigger logic for conversation filtering of requests.
* Fixing rimraf transpile bug. Adding PR fixes - icon buttons.
* Minor call tweaks (#2051)
* show missed-call,started-call and answered call notification in chat
* fix types for createLastMessageUpdate
* show incoming dialog if we have a pending call when enable call receptio
* simplify a bit the avatar component
* move disableDrag to a custom hook
* speed up hash colors of avatarPlaceHolders
* fixup text selection and double click reply on message
* keep avatar decoded items longer before releasing memory
* add incoming/outgoing/missed call notification
also, merge that notification with the timer and group notification
component
* hangup call if no answer after 30sec
* refactor SessionInput using hook + add testid field for recovery
* disable message request feature flag for now
* fix merge issue
* force loading screen to be black instead of white
for our dark theme user's eyes safety
* Fetch translations (#2056)
* show missed-call,started-call and answered call notification in chat
* fix types for createLastMessageUpdate
* show incoming dialog if we have a pending call when enable call receptio
* simplify a bit the avatar component
* move disableDrag to a custom hook
* speed up hash colors of avatarPlaceHolders
* fixup text selection and double click reply on message
* keep avatar decoded items longer before releasing memory
* add incoming/outgoing/missed call notification
also, merge that notification with the timer and group notification
component
* hangup call if no answer after 30sec
* refactor SessionInput using hook + add testid field for recovery
* disable message request feature flag for now
* fix merge issue
* force loading screen to be black instead of white
for our dark theme user's eyes safety
* add type for i18n to run update after crowdin fetch with tools/updateI18nKeysType.py
* update to latest translations
* Open group regex fixes (#2058)
* Open group URL regex fixes
- Capital letters in room tokens were not being accepted (it eventually
gets lower-cased internally, which works fine, but that happens
*after* the URL is tested for acceptability).
- `-` in room was not being allowed (it is and always has been on SOGS,
session-android, and session-ios).
- single-letter room ids are valid, but only 2+ letter ids were being
accepted.
- complete URL regex wasn't anchored so something like
`garbagehttps://example.com/room?public_key=<64hex>moregarbage` was
being accepted in the GUI input (it fails later when other code tries
to parse it as a URL).
- removed `m` modifier from open group regex: without anchors it wasn't
doing anything anyway, but *with* anchors it would still allow
leading/trailing garbage if delineated by newlines.
- public key regex was accepting g-z letters, and not accepting A-F.
- various regex cleanups:
- use non-capture groups (?:...) rather than capturing groups (...)
- avoid repetition in host segment matching
- tightened up host pattern matching a bit:
- DNS host segments have a max length of 63
- Limit port max length to 5, and disallow starting with 0
* Show an error when the open group URL is invalid
It's quite disconcerting when you have a bad open group URL and try to
add it and the join button just "doesn't work" without any feedback at
all. Fix it to show an error message. (There is already an i18n entry
for this because this same message is thrown if the URL can't be parsed
later on).
* Add call duration (#2059)
* add call duration once connected
* close incoming call dialog if endCall from same sender
* disable message request toggle if featureFlag is OFF
* Cleanup message request (#2063)
* close incoming call dialog if endCall from seame sender
* disable message request toggle if featureFlag is OFF
* cleanup UI of message requests
* mark all existing conversations as approved in a migration
* fix regex with conversationID for opengroups
* Various UI fixes (#2070)
* cleanup unused convo json fields in db
* display a toast if the user is not approved yet on call OFFER received
* enable CBR for calls
* do not update active_at on configMessage if !!active_at
* remove mkdirp dependency
* disable call button if focused convo is blocked
* quote: do not include the full body in quote, but just the first 100
* click on the edit profile qr code padding
* Allow longer input for opengroup join overlay
Fixes #2068
* Fix overlay feature for start new session button
* make ringing depend on redux CALL status
* turn ON read-receipt by default
* keep read-receipts disabled by default (#2071)
* refactor most of the components to outside of their Session folder (#2072)
* refactor most of the components to outside of their Session folder
* finish moving overlay and memberListItem to react hook
* fix bug with kicked member len >2 not being displayed
also sort admins first in UpdateGroupMembers dialog
* fix admin leaving text of groupNotification
* add a useFocusMount hook to focus input fields on mount
* make click avatar convo item open only user dialog
* cleanup config default.json
* make sure to use convoController to build sync message
* disable showing pubkey on opengroups
* add a pause on audio playback
Fixes #2079
* Minor styling fix for large amount of message requests (#2080)
* Minor styling fix for large amount of message requests
* Vertical center fix for message request banner.
* removing top margin from banner again.
* reactify group updates text bubble from redux store (#2083)
* add crown icon for closed group admins (#2084)
* disable call for now + fix left pane actions overflow (#2085)
* Fix attachment dl freeze (#2086)
* fix attachment download freezing app for some opengroups
* make registration page work with smaller height
* Unban UI (#2091)
* adding basic functionaliy for unbanning a user
* merge ban and unban user dialog in to one dialog
Co-authored-by: warrickct <warrickct@gmail.com>
* use React Provider for convoListItem (#2088)
this is to avoid passing down the prop to all the components
* fix closed group updates undefined on no names (#2092)
Co-authored-by: Warrick Corfe-Tan <warrickct@gmail.com>
Co-authored-by: Jason Rhinelander <jason@imaginary.ca>
Co-authored-by: Warrick <wcor690@aucklanduni.ac.nz>
3 years ago
|
|
|
// window?.log?.info('queueing envelope', id);
|
|
|
|
|
|
|
|
const task = handleEnvelope.bind(null, envelope, messageHash);
|
|
|
|
const taskWithTimeout = createTaskWithTimeout(task, `queueEnvelope ${id}`);
|
|
|
|
|
|
|
|
try {
|
|
|
|
envelopeQueue.add(taskWithTimeout);
|
|
|
|
} catch (error) {
|
|
|
|
window?.log?.error(
|
|
|
|
'queueEnvelope error handling envelope',
|
|
|
|
id,
|
|
|
|
':',
|
|
|
|
error && error.stack ? error.stack : error
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async function handleRequestDetail(
|
|
|
|
plaintext: Uint8Array,
|
|
|
|
options: ReqOptions,
|
|
|
|
lastPromise: Promise<any>,
|
|
|
|
messageHash: string
|
|
|
|
): Promise<void> {
|
|
|
|
const envelope: any = SignalService.Envelope.decode(plaintext);
|
|
|
|
|
|
|
|
// After this point, decoding errors are not the server's
|
|
|
|
// fault, and we should handle them gracefully and tell the
|
|
|
|
// user they received an invalid message
|
|
|
|
|
|
|
|
// The message is for a medium size group
|
|
|
|
if (options.conversationId) {
|
|
|
|
const ourNumber = UserUtils.getOurPubKeyStrFromCache();
|
|
|
|
const senderIdentity = envelope.source;
|
|
|
|
|
|
|
|
if (senderIdentity === ourNumber) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Sender identity will be lost if we load from cache, because
|
|
|
|
// plaintext (and protobuf.Envelope) does not have that field...
|
|
|
|
envelope.source = options.conversationId;
|
|
|
|
// tslint:disable-next-line no-parameter-reassignment
|
|
|
|
plaintext = SignalService.Envelope.encode(envelope).finish();
|
|
|
|
envelope.senderIdentity = senderIdentity;
|
|
|
|
}
|
|
|
|
|
|
|
|
envelope.id = envelope.serverGuid || uuidv4();
|
|
|
|
envelope.serverTimestamp = envelope.serverTimestamp ? envelope.serverTimestamp.toNumber() : null;
|
|
|
|
envelope.messageHash = messageHash;
|
|
|
|
|
|
|
|
try {
|
|
|
|
// NOTE: Annoyngly we add plaintext to the cache
|
|
|
|
// after we've already processed some of it (thus the
|
|
|
|
// need to handle senderIdentity separately)...
|
|
|
|
perfStart(`addToCache-${envelope.id}`);
|
|
|
|
|
|
|
|
await addToCache(envelope, plaintext, messageHash);
|
|
|
|
perfEnd(`addToCache-${envelope.id}`, 'addToCache');
|
|
|
|
|
|
|
|
// TODO: This is the glue between the first and the last part of the
|
|
|
|
// receiving pipeline refactor. It is to be implemented in the next PR.
|
|
|
|
|
|
|
|
// To ensure that we queue in the same order we receive messages
|
|
|
|
|
|
|
|
await lastPromise;
|
|
|
|
|
|
|
|
queueEnvelope(envelope, messageHash);
|
|
|
|
} catch (error) {
|
|
|
|
window?.log?.error(
|
|
|
|
'handleRequest error trying to add message to cache:',
|
|
|
|
error && error.stack ? error.stack : error
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function handleRequest(body: any, options: ReqOptions, messageHash: string): void {
|
|
|
|
// tslint:disable-next-line no-promise-as-boolean
|
|
|
|
const lastPromise = _.last(incomingMessagePromises) || Promise.resolve();
|
|
|
|
|
|
|
|
const plaintext = body;
|
|
|
|
|
|
|
|
const promise = handleRequestDetail(plaintext, options, lastPromise, messageHash).catch(e => {
|
|
|
|
window?.log?.error('Error handling incoming message:', e && e.stack ? e.stack : e);
|
|
|
|
|
|
|
|
void onError(e);
|
|
|
|
});
|
|
|
|
|
|
|
|
incomingMessagePromises.push(promise);
|
|
|
|
}
|
|
|
|
|
Session 1.7.5 (#2094)
* Added message requests disabled for now
* no longer showing empty space for conversations moved from list.
* Added syncing accepting of contact between running instances.
* Adding blocking of individual requests and syncing of block to devices. Added approval by replying to a message.
* fixed typos for translations and method name.
* Blocking, accepting on click and accepting on msg send
working across clients.
* adding setting of active_at to hide unapproved messages.
* adding feature flag for config message receiving
* fix archlinux pw unused issue
on archlinux, the appimage links to the system sqlite by default which
does not support sqlcipher
* hide activeAt = 0 convo from search results
Fixes #2033
* opengroup messages from blocked user are dropped
Fixes #2019
* opengroup messages from blocked user are dropped
Fixes #2019
* dismiss a call when answered from another of our devices
* add data-testid for leftpane sections and edit profile dialog
* update turn servers
* cleanup sessionprotobuf
* move the state of calling to its own slice
* no video track by default and will be turn ON if asked to
* message request refactoring.
* create offer and answer ourselves and do not use the negotiation needed
event.
this event is causing us to loop in negotiation needed when each side
try to create one, gets the answer and so on...
* auto select the first audio input on connection success webrtc
* add a way to choose the audioouput/mute a webrtc call
* mute audio from bg when video is in fullscreen
this is to avoid having two times the remote sound playing
one in the bg and one in the fullscreen
* Adding improvements to message request handling.
* Only updating approval when it is a true value as we consider a block a decline.
* Linting and formatting.
* More formatting and linting
* fixing merge conflicts
* linting and formatting changes
* darken a bit the green of sent message box in light theme
* disable deduplication based serverId+sender
only use the serverTimestamp+sender for searching because
serverId+sender might have false positive
* Fixing up block all logic.
* speed up fetching closed group's members avatar
* Applying PR changes.
* cleanup props passing of avatar and name with a custom hook
* fix a bug releasing the decrypted attachment blobs too early
* Adding trigger logic for conversation filtering of requests.
* Fixing rimraf transpile bug. Adding PR fixes - icon buttons.
* Minor call tweaks (#2051)
* show missed-call,started-call and answered call notification in chat
* fix types for createLastMessageUpdate
* show incoming dialog if we have a pending call when enable call receptio
* simplify a bit the avatar component
* move disableDrag to a custom hook
* speed up hash colors of avatarPlaceHolders
* fixup text selection and double click reply on message
* keep avatar decoded items longer before releasing memory
* add incoming/outgoing/missed call notification
also, merge that notification with the timer and group notification
component
* hangup call if no answer after 30sec
* refactor SessionInput using hook + add testid field for recovery
* disable message request feature flag for now
* fix merge issue
* force loading screen to be black instead of white
for our dark theme user's eyes safety
* Fetch translations (#2056)
* show missed-call,started-call and answered call notification in chat
* fix types for createLastMessageUpdate
* show incoming dialog if we have a pending call when enable call receptio
* simplify a bit the avatar component
* move disableDrag to a custom hook
* speed up hash colors of avatarPlaceHolders
* fixup text selection and double click reply on message
* keep avatar decoded items longer before releasing memory
* add incoming/outgoing/missed call notification
also, merge that notification with the timer and group notification
component
* hangup call if no answer after 30sec
* refactor SessionInput using hook + add testid field for recovery
* disable message request feature flag for now
* fix merge issue
* force loading screen to be black instead of white
for our dark theme user's eyes safety
* add type for i18n to run update after crowdin fetch with tools/updateI18nKeysType.py
* update to latest translations
* Open group regex fixes (#2058)
* Open group URL regex fixes
- Capital letters in room tokens were not being accepted (it eventually
gets lower-cased internally, which works fine, but that happens
*after* the URL is tested for acceptability).
- `-` in room was not being allowed (it is and always has been on SOGS,
session-android, and session-ios).
- single-letter room ids are valid, but only 2+ letter ids were being
accepted.
- complete URL regex wasn't anchored so something like
`garbagehttps://example.com/room?public_key=<64hex>moregarbage` was
being accepted in the GUI input (it fails later when other code tries
to parse it as a URL).
- removed `m` modifier from open group regex: without anchors it wasn't
doing anything anyway, but *with* anchors it would still allow
leading/trailing garbage if delineated by newlines.
- public key regex was accepting g-z letters, and not accepting A-F.
- various regex cleanups:
- use non-capture groups (?:...) rather than capturing groups (...)
- avoid repetition in host segment matching
- tightened up host pattern matching a bit:
- DNS host segments have a max length of 63
- Limit port max length to 5, and disallow starting with 0
* Show an error when the open group URL is invalid
It's quite disconcerting when you have a bad open group URL and try to
add it and the join button just "doesn't work" without any feedback at
all. Fix it to show an error message. (There is already an i18n entry
for this because this same message is thrown if the URL can't be parsed
later on).
* Add call duration (#2059)
* add call duration once connected
* close incoming call dialog if endCall from same sender
* disable message request toggle if featureFlag is OFF
* Cleanup message request (#2063)
* close incoming call dialog if endCall from seame sender
* disable message request toggle if featureFlag is OFF
* cleanup UI of message requests
* mark all existing conversations as approved in a migration
* fix regex with conversationID for opengroups
* Various UI fixes (#2070)
* cleanup unused convo json fields in db
* display a toast if the user is not approved yet on call OFFER received
* enable CBR for calls
* do not update active_at on configMessage if !!active_at
* remove mkdirp dependency
* disable call button if focused convo is blocked
* quote: do not include the full body in quote, but just the first 100
* click on the edit profile qr code padding
* Allow longer input for opengroup join overlay
Fixes #2068
* Fix overlay feature for start new session button
* make ringing depend on redux CALL status
* turn ON read-receipt by default
* keep read-receipts disabled by default (#2071)
* refactor most of the components to outside of their Session folder (#2072)
* refactor most of the components to outside of their Session folder
* finish moving overlay and memberListItem to react hook
* fix bug with kicked member len >2 not being displayed
also sort admins first in UpdateGroupMembers dialog
* fix admin leaving text of groupNotification
* add a useFocusMount hook to focus input fields on mount
* make click avatar convo item open only user dialog
* cleanup config default.json
* make sure to use convoController to build sync message
* disable showing pubkey on opengroups
* add a pause on audio playback
Fixes #2079
* Minor styling fix for large amount of message requests (#2080)
* Minor styling fix for large amount of message requests
* Vertical center fix for message request banner.
* removing top margin from banner again.
* reactify group updates text bubble from redux store (#2083)
* add crown icon for closed group admins (#2084)
* disable call for now + fix left pane actions overflow (#2085)
* Fix attachment dl freeze (#2086)
* fix attachment download freezing app for some opengroups
* make registration page work with smaller height
* Unban UI (#2091)
* adding basic functionaliy for unbanning a user
* merge ban and unban user dialog in to one dialog
Co-authored-by: warrickct <warrickct@gmail.com>
* use React Provider for convoListItem (#2088)
this is to avoid passing down the prop to all the components
* fix closed group updates undefined on no names (#2092)
Co-authored-by: Warrick Corfe-Tan <warrickct@gmail.com>
Co-authored-by: Jason Rhinelander <jason@imaginary.ca>
Co-authored-by: Warrick <wcor690@aucklanduni.ac.nz>
3 years ago
|
|
|
// tslint:enable:cyclomatic-complexity max-func-body-length */
|
|
|
|
/**
|
|
|
|
* Used in background.js
|
|
|
|
*/
|
|
|
|
export async function queueAllCached() {
|
|
|
|
const items = await getAllFromCache();
|
|
|
|
items.forEach(async item => {
|
|
|
|
await queueCached(item);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function queueAllCachedFromSource(source: string) {
|
|
|
|
const items = await getAllFromCacheForSource(source);
|
|
|
|
|
|
|
|
// queue all cached for this source, but keep the order
|
|
|
|
await items.reduce(async (promise, item) => {
|
|
|
|
await promise;
|
|
|
|
await queueCached(item);
|
|
|
|
}, Promise.resolve());
|
|
|
|
}
|
|
|
|
|
|
|
|
async function queueCached(item: any) {
|
|
|
|
try {
|
|
|
|
const envelopePlaintext = StringUtils.encode(item.envelope, 'base64');
|
|
|
|
const envelopeArray = new Uint8Array(envelopePlaintext);
|
|
|
|
|
|
|
|
const envelope: any = SignalService.Envelope.decode(envelopeArray);
|
|
|
|
envelope.id = envelope.serverGuid || item.id;
|
|
|
|
envelope.source = envelope.source || item.source;
|
|
|
|
|
|
|
|
// Why do we need to do this???
|
|
|
|
envelope.sourceDevice = 1;
|
|
|
|
envelope.senderIdentity = envelope.senderIdentity || item.senderIdentity;
|
|
|
|
envelope.serverTimestamp = envelope.serverTimestamp || item.serverTimestamp;
|
|
|
|
|
|
|
|
const { decrypted } = item;
|
|
|
|
|
|
|
|
if (decrypted) {
|
|
|
|
const payloadPlaintext = StringUtils.encode(decrypted, 'base64');
|
|
|
|
|
|
|
|
queueDecryptedEnvelope(envelope, payloadPlaintext);
|
|
|
|
} else {
|
|
|
|
queueEnvelope(envelope);
|
|
|
|
}
|
|
|
|
} catch (error) {
|
|
|
|
window?.log?.error(
|
|
|
|
'queueCached error handling item',
|
|
|
|
item.id,
|
|
|
|
'removing it. Error:',
|
|
|
|
error && error.stack ? error.stack : error
|
|
|
|
);
|
|
|
|
|
|
|
|
try {
|
|
|
|
const { id } = item;
|
|
|
|
await removeUnprocessed(id);
|
|
|
|
} catch (deleteError) {
|
|
|
|
window?.log?.error(
|
|
|
|
'queueCached error deleting item',
|
|
|
|
item.id,
|
|
|
|
'Error:',
|
|
|
|
deleteError && deleteError.stack ? deleteError.stack : deleteError
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function queueDecryptedEnvelope(envelope: any, plaintext: ArrayBuffer) {
|
|
|
|
const id = getEnvelopeId(envelope);
|
|
|
|
window?.log?.info('queueing decrypted envelope', id);
|
|
|
|
|
|
|
|
const task = handleDecryptedEnvelope.bind(null, envelope, plaintext);
|
|
|
|
const taskWithTimeout = createTaskWithTimeout(task, `queueEncryptedEnvelope ${id}`);
|
|
|
|
try {
|
|
|
|
envelopeQueue.add(taskWithTimeout);
|
|
|
|
} catch (error) {
|
|
|
|
window?.log?.error(
|
|
|
|
`queueDecryptedEnvelope error handling envelope ${id}:`,
|
|
|
|
error && error.stack ? error.stack : error
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async function handleDecryptedEnvelope(envelope: EnvelopePlus, plaintext: ArrayBuffer) {
|
|
|
|
// if (this.stoppingProcessing) {
|
|
|
|
// return Promise.resolve();
|
|
|
|
// }
|
|
|
|
|
|
|
|
if (envelope.content) {
|
|
|
|
await innerHandleContentMessage(envelope, plaintext);
|
|
|
|
} else {
|
|
|
|
await removeFromCache(envelope);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function handleOpenGroupV2Message(
|
|
|
|
message: OpenGroupMessageV2,
|
|
|
|
roomInfos: OpenGroupRequestCommonType
|
|
|
|
) {
|
|
|
|
const { base64EncodedData, sentTimestamp, sender, serverId } = message;
|
|
|
|
const { serverUrl, roomId } = roomInfos;
|
|
|
|
if (!base64EncodedData || !sentTimestamp || !sender || !serverId) {
|
|
|
|
window?.log?.warn('Invalid data passed to handleMessageEvent.', message);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Note: opengroup messages are not padded
|
|
|
|
const dataUint = new Uint8Array(removeMessagePadding(fromBase64ToArray(base64EncodedData)));
|
|
|
|
|
|
|
|
const decoded = SignalService.Content.decode(dataUint);
|
|
|
|
|
|
|
|
const conversationId = getOpenGroupV2ConversationId(serverUrl, roomId);
|
|
|
|
if (!conversationId) {
|
|
|
|
window?.log?.error('We cannot handle a message without a conversationId');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const idataMessage = decoded?.dataMessage;
|
|
|
|
if (!idataMessage) {
|
|
|
|
window?.log?.error('Invalid decoded opengroup message: no dataMessage');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const dataMessage = idataMessage as SignalService.DataMessage;
|
|
|
|
|
|
|
|
if (!getConversationController().get(conversationId)) {
|
|
|
|
window?.log?.error('Received a message for an unknown convo. Skipping');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// if the message is `sent` (from secondary device) we have to set the sender manually... (at least for now)
|
|
|
|
// source = source || msg.get('source');
|
|
|
|
|
|
|
|
const conversation = await getConversationController().getOrCreateAndWait(
|
|
|
|
conversationId,
|
|
|
|
ConversationTypeEnum.GROUP
|
|
|
|
);
|
|
|
|
|
|
|
|
if (!conversation) {
|
|
|
|
window?.log?.warn('Skipping handleJob for unknown convo: ', conversationId);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void conversation.queueJob(async () => {
|
|
|
|
const isMe = UserUtils.isUsFromCache(sender);
|
|
|
|
// for an opengroupv2 incoming message the serverTimestamp and the timestamp
|
|
|
|
const messageCreationData: MessageCreationData = {
|
|
|
|
isPublic: true,
|
|
|
|
sourceDevice: 1,
|
|
|
|
serverId,
|
|
|
|
serverTimestamp: sentTimestamp,
|
|
|
|
receivedAt: Date.now(),
|
|
|
|
destination: conversationId,
|
|
|
|
timestamp: sentTimestamp,
|
|
|
|
expirationStartTimestamp: undefined,
|
|
|
|
source: sender,
|
|
|
|
message: dataMessage,
|
|
|
|
};
|
|
|
|
// WARNING this is very important that the isMessageDuplicate is made in the conversation.queueJob
|
|
|
|
const isDuplicate = await isMessageDuplicate(messageCreationData);
|
|
|
|
|
|
|
|
if (isDuplicate) {
|
|
|
|
window?.log?.info('Received duplicate message. Dropping it.');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isDuplicateBasedOnHash(dataMessage, conversationId, sender)) {
|
|
|
|
window?.log?.info('Received duplicate message based on hash. Dropping it.');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// this line just create an empty message with some basic stuff set.
|
|
|
|
// the whole decoding of data is happening in handleMessageJob()
|
|
|
|
const msg = createMessage(messageCreationData, !isMe);
|
|
|
|
const ourNumber = UserUtils.getOurPubKeyStrFromCache();
|
|
|
|
|
|
|
|
await handleMessageJob(msg, conversation, decoded?.dataMessage, ourNumber, noop, sender, '');
|
|
|
|
});
|
|
|
|
}
|