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

pull/1592/head
Audric Ackermann 4 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;
}
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);
return {

@ -44,7 +44,9 @@ export async function handleClosedGroupControlMessage(
const { type } = groupUpdate;
const { Type } = SignalService.DataMessage.ClosedGroupControlMessage;
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))) {
@ -210,12 +212,12 @@ export async function handleNewClosedGroup(
);
// We only set group admins on group creation
const groupDetails = {
const groupDetails: ClosedGroup.GroupInfo = {
id: groupId,
name: name,
members: members,
admins,
active: true,
activeAt: Date.now(),
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
// envelope.timestamp and Date.now(). And we need to listen to those (some might even remove us)
convo.set('lastJoinedTimestamp', _.toNumber(envelope.timestamp));
convo.updateLastMessage();
await convo.commit();
// sanity checks validate this
// tslint:disable: no-non-null-assertion
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());
@ -894,12 +897,12 @@ export async function createClosedGroup(groupName: string, members: Array<string
const admins = [ourNumber.key];
const groupDetails = {
const groupDetails: ClosedGroup.GroupInfo = {
id: groupPublicKey,
name: groupName,
members: listOfMembers,
admins,
active: true,
activeAt: Date.now(),
expireTimer: 0,
};
@ -931,11 +934,12 @@ export async function createClosedGroup(groupName: string, members: Array<string
expireTimer: 0,
};
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);
});
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
SwarmPolling.getInstance().addGroupId(new PubKey(groupPublicKey));

@ -37,12 +37,12 @@ import { ClosedGroupRemovedMembersMessage } from '../messages/outgoing/controlMe
import { updateOpenGroupV1 } from '../../opengroup/opengroupV1/OpenGroup';
import { updateOpenGroupV2 } from '../../opengroup/opengroupV2/OpenGroupUpdate';
export interface GroupInfo {
export type GroupInfo = {
id: string;
name: string;
members: Array<string>;
zombies?: Array<string>;
active?: boolean;
activeAt?: number;
expireTimer?: number | null;
avatar?: any;
color?: any; // what is this???
@ -50,7 +50,7 @@ export interface GroupInfo {
admins?: Array<string>;
secretKey?: Uint8Array;
weWereJustAdded?: boolean;
}
};
interface UpdatableGroupState {
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
// updateOrCreateClosedGroup() will update them if given the choice.
const groupDetails = {
const groupDetails: GroupInfo = {
id: groupId,
name: groupName,
members,
// remove from the zombies list the zombies not which are not in the group anymore
zombies: convo.get('zombies').filter(z => members.includes(z)),
active: true,
activeAt: Date.now(),
expireTimer: convo.get('expireTimer'),
avatar,
};
@ -245,15 +245,10 @@ export async function updateOrCreateClosedGroup(details: GroupInfo) {
is_medium_group: true,
};
if (details.active) {
const activeAt = conversation.get('active_at');
if (details.activeAt) {
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.lastJoinedTimestamp = weWereJustAdded ? Date.now() : updates.active_at;
} else {

Loading…
Cancel
Save