Merge remote-tracking branch 'upstream/clearnet' into restore-handle-configuration

pull/1512/head
Audric Ackermann 4 years ago
commit aac54e6045
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -2,7 +2,7 @@
"name": "session-desktop", "name": "session-desktop",
"productName": "Session", "productName": "Session",
"description": "Private messaging from your desktop", "description": "Private messaging from your desktop",
"version": "1.4.10", "version": "1.4.11",
"license": "GPL-3.0", "license": "GPL-3.0",
"author": { "author": {
"name": "Loki Project", "name": "Loki Project",

@ -236,6 +236,7 @@ export async function handleNewClosedGroup(
members: members, members: members,
admins, admins,
active: true, active: true,
weWereJustAdded: true,
}; };
// be sure to call this before sending the message. // be sure to call this before sending the message.
@ -521,7 +522,8 @@ async function performIfValid(
lastJoinedTimestamp = aYearAgo; lastJoinedTimestamp = aYearAgo;
} }
if (envelope.timestamp <= lastJoinedTimestamp) { const envelopeTimestamp = _.toNumber(envelope.timestamp);
if (envelopeTimestamp <= lastJoinedTimestamp) {
window.log.warn( window.log.warn(
'Got a group update with an older timestamp than when we joined this group last time. Dropping it.' 'Got a group update with an older timestamp than when we joined this group last time. Dropping it.'
); );

@ -45,6 +45,7 @@ export interface GroupInfo {
blocked?: boolean; blocked?: boolean;
admins?: Array<string>; admins?: Array<string>;
secretKey?: Uint8Array; secretKey?: Uint8Array;
weWereJustAdded?: boolean;
} }
interface UpdatableGroupState { interface UpdatableGroupState {
@ -247,7 +248,7 @@ export function buildGroupDiff(
} }
export async function updateOrCreateClosedGroup(details: GroupInfo) { export async function updateOrCreateClosedGroup(details: GroupInfo) {
const { id } = details; const { id, weWereJustAdded } = details;
const conversation = await ConversationController.getInstance().getOrCreateAndWait( const conversation = await ConversationController.getInstance().getOrCreateAndWait(
id, id,
@ -272,7 +273,9 @@ export async function updateOrCreateClosedGroup(details: GroupInfo) {
updates.timestamp = updates.active_at; updates.timestamp = updates.active_at;
} }
updates.left = false; updates.left = false;
updates.lastJoinedTimestamp = updates.active_at; updates.lastJoinedTimestamp = weWereJustAdded
? Date.now()
: updates.active_at;
} else { } else {
updates.left = true; updates.left = true;
} }

@ -98,10 +98,10 @@ export class ChatMessage extends DataMessage {
) { ) {
if ( if (
(dataMessage as any).constructor.name !== 'DataMessage' && (dataMessage as any).constructor.name !== 'DataMessage' &&
!(dataMessage instanceof DataMessage) !(dataMessage instanceof SignalService.DataMessage)
) { ) {
throw new Error( window.log.warn(
'Tried to build a sync message from something else than a DataMessage' 'buildSyncMessage with something else than a DataMessage'
); );
} }

@ -62,11 +62,11 @@ export const forceSyncConfigurationNowIfNeeded = async (
) => ) =>
new Promise(resolve => { new Promise(resolve => {
const allConvos = ConversationController.getInstance().getConversations(); const allConvos = ConversationController.getInstance().getConversations();
void getCurrentConfigurationMessage(allConvos) void getCurrentConfigurationMessage(allConvos)
.then(configMessage => { .then(configMessage => {
// console.warn('forceSyncConfigurationNowIfNeeded with', configMessage); // console.warn('forceSyncConfigurationNowIfNeeded with', configMessage);
try {
// this just adds the message to the sending queue. // this just adds the message to the sending queue.
// if waitForMessageSent is set, we need to effectively wait until then // if waitForMessageSent is set, we need to effectively wait until then
// tslint:disable-next-line: no-void-expression // tslint:disable-next-line: no-void-expression
@ -75,22 +75,12 @@ export const forceSyncConfigurationNowIfNeeded = async (
resolve(true); resolve(true);
} }
: undefined; : undefined;
void getMessageQueue().sendSyncMessage( void getMessageQueue().sendSyncMessage(configMessage, callback as any);
configMessage,
callback as any
);
// either we resolve from the callback if we need to wait for it, // either we resolve from the callback if we need to wait for it,
// or we don't want to wait, we resolve it here. // or we don't want to wait, we resolve it here.
if (!waitForMessageSent) { if (!waitForMessageSent) {
resolve(true); resolve(true);
} }
} catch (e) {
window.log.warn(
'Caught an error while sending our ConfigurationMessage:',
e
);
resolve(false);
}
}) })
.catch(e => { .catch(e => {
window.log.warn( window.log.warn(

@ -122,7 +122,7 @@ describe('Promise Utils', () => {
expect(waitForTaskSpy.callCount).to.equal(1); expect(waitForTaskSpy.callCount).to.equal(1);
expect(completionSpy.callCount).to.equal(0); expect(completionSpy.callCount).to.equal(0);
return promise.should.eventually.be.rejectedWith('Task timed out.'); return promise.should.eventually.be.rejectedWith('Task timed out');
}); });
}); });

Loading…
Cancel
Save