Skip to content

Commit

Permalink
Merge pull request #1518 from Bilb/fix-left-readded-bug
Browse files Browse the repository at this point in the history
Fix the bug where if we leave and get added back, we get removed again
  • Loading branch information
Bilb authored Feb 25, 2021
2 parents 6aa3e5b + 641f9ee commit 8e18089
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
4 changes: 3 additions & 1 deletion ts/receiver/closedGroups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ export async function handleNewClosedGroup(
members: members,
admins,
active: true,
weWereJustAdded: true,
};

// be sure to call this before sending the message.
Expand Down Expand Up @@ -509,7 +510,8 @@ async function performIfValid(
lastJoinedTimestamp = aYearAgo;
}

if (envelope.timestamp <= lastJoinedTimestamp) {
const envelopeTimestamp = _.toNumber(envelope.timestamp);
if (envelopeTimestamp <= lastJoinedTimestamp) {
window.log.warn(
'Got a group update with an older timestamp than when we joined this group last time. Dropping it.'
);
Expand Down
7 changes: 5 additions & 2 deletions ts/session/group/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export interface GroupInfo {
blocked?: boolean;
admins?: Array<string>;
secretKey?: Uint8Array;
weWereJustAdded?: boolean;
}

interface UpdatableGroupState {
Expand Down Expand Up @@ -243,7 +244,7 @@ export function buildGroupDiff(
}

export async function updateOrCreateClosedGroup(details: GroupInfo) {
const { id } = details;
const { id, weWereJustAdded } = details;

const conversation = await ConversationController.getInstance().getOrCreateAndWait(
id,
Expand All @@ -268,7 +269,9 @@ export async function updateOrCreateClosedGroup(details: GroupInfo) {
updates.timestamp = updates.active_at;
}
updates.left = false;
updates.lastJoinedTimestamp = updates.active_at;
updates.lastJoinedTimestamp = weWereJustAdded
? Date.now()
: updates.active_at;
} else {
updates.left = true;
}
Expand Down
8 changes: 4 additions & 4 deletions ts/session/utils/syncUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ export const forceSyncConfigurationNowIfNeeded = async (
// tslint:disable-next-line: no-void-expression
const callback = waitForMessageSent
? () => {
resolve(true);
}
resolve(true);
}
: undefined;
void getMessageQueue().sendSyncMessage(configMessage, callback as any);
// either we resolve from the callback if we need to wait for it,
Expand Down Expand Up @@ -95,8 +95,8 @@ export const getCurrentConfigurationMessage = async (
const openGroupsIds = convos
.filter(c => !!c.get('active_at') && c.isPublic() && !c.get('left'))
.map(c => c.id.substring((c.id as string).lastIndexOf('@') + 1)) as Array<
string
>;
string
>;

// Filter Closed/Medium groups
const closedGroupModels = convos.filter(
Expand Down

0 comments on commit 8e18089

Please sign in to comment.