mark convo as ActiveAt when we get a message adding us after left

pull/1592/head
Audric Ackermann 5 years ago
parent eb0ddd85f4
commit fae80c327a
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -70,7 +70,7 @@ export class UpdateGroupMembersDialog extends React.Component<Props, State> {
return null; return null;
} }
const lokiProfile = convo.getLokiProfile(); const lokiProfile = convo.getLokiProfile();
const name = lokiProfile ? `${lokiProfile.displayName} (Zombie)` : window.i18n('anonymous'); const name = lokiProfile ? lokiProfile.displayName : window.i18n('anonymous');
const existingZombie = this.props.existingZombies.includes(convo.id); const existingZombie = this.props.existingZombies.includes(convo.id);
return { return {

@ -44,7 +44,9 @@ export async function handleClosedGroupControlMessage(
const { type } = groupUpdate; const { type } = groupUpdate;
const { Type } = SignalService.DataMessage.ClosedGroupControlMessage; const { Type } = SignalService.DataMessage.ClosedGroupControlMessage;
window.log.info( window.log.info(
` handle closed group update from ${envelope.senderIdentity} about group ${envelope.source}` ` handle closed group update from ${envelope.senderIdentity || envelope.source} about group ${
envelope.source
}`
); );
if (BlockedNumberController.isGroupBlocked(PubKey.cast(envelope.source))) { if (BlockedNumberController.isGroupBlocked(PubKey.cast(envelope.source))) {
@ -210,12 +212,12 @@ export async function handleNewClosedGroup(
); );
// We only set group admins on group creation // We only set group admins on group creation
const groupDetails = { const groupDetails: ClosedGroup.GroupInfo = {
id: groupId, id: groupId,
name: name, name: name,
members: members, members: members,
admins, admins,
active: true, activeAt: Date.now(),
weWereJustAdded: true, weWereJustAdded: true,
}; };
@ -228,12 +230,13 @@ export async function handleNewClosedGroup(
// Having that timestamp set will allow us to pickup incoming group update which were sent between // Having that timestamp set will allow us to pickup incoming group update which were sent between
// envelope.timestamp and Date.now(). And we need to listen to those (some might even remove us) // envelope.timestamp and Date.now(). And we need to listen to those (some might even remove us)
convo.set('lastJoinedTimestamp', _.toNumber(envelope.timestamp)); convo.set('lastJoinedTimestamp', _.toNumber(envelope.timestamp));
convo.updateLastMessage();
await convo.commit(); await convo.commit();
// sanity checks validate this // sanity checks validate this
// tslint:disable: no-non-null-assertion // tslint:disable: no-non-null-assertion
const ecKeyPair = new ECKeyPair(encryptionKeyPair!.publicKey, encryptionKeyPair!.privateKey); const ecKeyPair = new ECKeyPair(encryptionKeyPair!.publicKey, encryptionKeyPair!.privateKey);
window.log.info(`Received a the encryptionKeyPair for new group ${groupId}`); window.log.info(`Received the encryptionKeyPair for new group ${groupId}`);
await addClosedGroupEncryptionKeyPair(groupId, ecKeyPair.toHexKeyPair()); await addClosedGroupEncryptionKeyPair(groupId, ecKeyPair.toHexKeyPair());
@ -894,12 +897,12 @@ export async function createClosedGroup(groupName: string, members: Array<string
const admins = [ourNumber.key]; const admins = [ourNumber.key];
const groupDetails = { const groupDetails: ClosedGroup.GroupInfo = {
id: groupPublicKey, id: groupPublicKey,
name: groupName, name: groupName,
members: listOfMembers, members: listOfMembers,
admins, admins,
active: true, activeAt: Date.now(),
expireTimer: 0, expireTimer: 0,
}; };
@ -931,11 +934,12 @@ export async function createClosedGroup(groupName: string, members: Array<string
expireTimer: 0, expireTimer: 0,
}; };
const message = new ClosedGroupNewMessage(messageParams); const message = new ClosedGroupNewMessage(messageParams);
window.log.info(`Creating a new group and an encryptionKeyPair for group ${groupPublicKey}`);
// tslint:disable-next-line: no-non-null-assertion
await addClosedGroupEncryptionKeyPair(groupPublicKey, encryptionKeyPair.toHexKeyPair());
return getMessageQueue().sendToPubKey(PubKey.cast(m), message); return getMessageQueue().sendToPubKey(PubKey.cast(m), message);
}); });
window.log.info(`Creating a new group and an encryptionKeyPair for group ${groupPublicKey}`);
// tslint:disable-next-line: no-non-null-assertion
await addClosedGroupEncryptionKeyPair(groupPublicKey, encryptionKeyPair.toHexKeyPair());
// Subscribe to this group id // Subscribe to this group id
SwarmPolling.getInstance().addGroupId(new PubKey(groupPublicKey)); SwarmPolling.getInstance().addGroupId(new PubKey(groupPublicKey));

@ -37,12 +37,12 @@ import { ClosedGroupRemovedMembersMessage } from '../messages/outgoing/controlMe
import { updateOpenGroupV1 } from '../../opengroup/opengroupV1/OpenGroup'; import { updateOpenGroupV1 } from '../../opengroup/opengroupV1/OpenGroup';
import { updateOpenGroupV2 } from '../../opengroup/opengroupV2/OpenGroupUpdate'; import { updateOpenGroupV2 } from '../../opengroup/opengroupV2/OpenGroupUpdate';
export interface GroupInfo { export type GroupInfo = {
id: string; id: string;
name: string; name: string;
members: Array<string>; members: Array<string>;
zombies?: Array<string>; zombies?: Array<string>;
active?: boolean; activeAt?: number;
expireTimer?: number | null; expireTimer?: number | null;
avatar?: any; avatar?: any;
color?: any; // what is this??? color?: any; // what is this???
@ -50,7 +50,7 @@ export interface GroupInfo {
admins?: Array<string>; admins?: Array<string>;
secretKey?: Uint8Array; secretKey?: Uint8Array;
weWereJustAdded?: boolean; weWereJustAdded?: boolean;
} };
interface UpdatableGroupState { interface UpdatableGroupState {
name: string; name: string;
@ -113,13 +113,13 @@ export async function initiateGroupUpdate(
// do not give an admins field here. We don't want to be able to update admins and // do not give an admins field here. We don't want to be able to update admins and
// updateOrCreateClosedGroup() will update them if given the choice. // updateOrCreateClosedGroup() will update them if given the choice.
const groupDetails = { const groupDetails: GroupInfo = {
id: groupId, id: groupId,
name: groupName, name: groupName,
members, members,
// remove from the zombies list the zombies not which are not in the group anymore // remove from the zombies list the zombies not which are not in the group anymore
zombies: convo.get('zombies').filter(z => members.includes(z)), zombies: convo.get('zombies').filter(z => members.includes(z)),
active: true, activeAt: Date.now(),
expireTimer: convo.get('expireTimer'), expireTimer: convo.get('expireTimer'),
avatar, avatar,
}; };
@ -245,15 +245,10 @@ export async function updateOrCreateClosedGroup(details: GroupInfo) {
is_medium_group: true, is_medium_group: true,
}; };
if (details.active) { if (details.activeAt) {
const activeAt = conversation.get('active_at'); updates.active_at = details.activeAt;
updates.timestamp = updates.active_at;
// The idea is to make any new group show up in the left pane. If
// activeAt is null, then this group has been purposefully hidden.
if (activeAt !== null) {
updates.active_at = activeAt || Date.now();
updates.timestamp = updates.active_at;
}
updates.left = false; updates.left = false;
updates.lastJoinedTimestamp = weWereJustAdded ? Date.now() : updates.active_at; updates.lastJoinedTimestamp = weWereJustAdded ? Date.now() : updates.active_at;
} else { } else {

Loading…
Cancel
Save