Consolidate checks for v2 Groups
This commit is contained in:
parent
c3ddedfde1
commit
cf9764c85a
5 changed files with 13 additions and 11 deletions
|
@ -2436,8 +2436,7 @@ type WhatIsThis = typeof window.WhatIsThis;
|
||||||
id,
|
id,
|
||||||
'group'
|
'group'
|
||||||
);
|
);
|
||||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
if (conversation.isGroupV2()) {
|
||||||
if (conversation.get('groupVersion')! > 1) {
|
|
||||||
window.log.warn(
|
window.log.warn(
|
||||||
'Got group sync for v2 group: ',
|
'Got group sync for v2 group: ',
|
||||||
conversation.idForLogging()
|
conversation.idForLogging()
|
||||||
|
|
|
@ -142,8 +142,7 @@ export class ConversationModel extends window.Backbone.Model<
|
||||||
const e164 = this.get('e164');
|
const e164 = this.get('e164');
|
||||||
return `${uuid || e164} (${this.id})`;
|
return `${uuid || e164} (${this.id})`;
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
if (this.isGroupV2()) {
|
||||||
if (this.get('groupVersion')! > 1) {
|
|
||||||
return `groupv2(${this.get('groupId')})`;
|
return `groupv2(${this.get('groupId')})`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,6 +266,10 @@ export class ConversationModel extends window.Backbone.Model<
|
||||||
return fromEncodedBinaryToArrayBuffer(groupID).byteLength === 16;
|
return fromEncodedBinaryToArrayBuffer(groupID).byteLength === 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isGroupV2(): boolean {
|
||||||
|
return (this.get('groupVersion') || 0) === 2;
|
||||||
|
}
|
||||||
|
|
||||||
isEverUnregistered(): boolean {
|
isEverUnregistered(): boolean {
|
||||||
return Boolean(this.get('discoveredUnregisteredAt'));
|
return Boolean(this.get('discoveredUnregisteredAt'));
|
||||||
}
|
}
|
||||||
|
@ -488,7 +491,7 @@ export class ConversationModel extends window.Backbone.Model<
|
||||||
}
|
}
|
||||||
|
|
||||||
async fetchLatestGroupV2Data(): Promise<void> {
|
async fetchLatestGroupV2Data(): Promise<void> {
|
||||||
if (this.get('groupVersion') !== 2) {
|
if (!this.isGroupV2()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -520,7 +523,7 @@ export class ConversationModel extends window.Backbone.Model<
|
||||||
}
|
}
|
||||||
|
|
||||||
getGroupV2Info(groupChange?: ArrayBuffer): WhatIsThis {
|
getGroupV2Info(groupChange?: ArrayBuffer): WhatIsThis {
|
||||||
if (this.isPrivate() || this.get('groupVersion') !== 2) {
|
if (this.isPrivate() || !this.isGroupV2()) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
|
@ -2571,7 +2574,7 @@ export class ConversationModel extends window.Backbone.Model<
|
||||||
receivedAt: number,
|
receivedAt: number,
|
||||||
options: { fromSync?: unknown; fromGroupUpdate?: unknown } = {}
|
options: { fromSync?: unknown; fromGroupUpdate?: unknown } = {}
|
||||||
): Promise<boolean | null | MessageModel | void> {
|
): Promise<boolean | null | MessageModel | void> {
|
||||||
if (this.get('groupVersion') === 2) {
|
if (this.isGroupV2()) {
|
||||||
if (providedSource || receivedAt) {
|
if (providedSource || receivedAt) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'updateExpirationTimer: GroupV2 timers are not updated this way'
|
'updateExpirationTimer: GroupV2 timers are not updated this way'
|
||||||
|
@ -3494,7 +3497,7 @@ export class ConversationModel extends window.Backbone.Model<
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.get('groupVersion') !== 2) {
|
if (!this.isGroupV2()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -148,7 +148,7 @@ async function generateManifest(
|
||||||
// eslint-disable-next-line no-await-in-loop
|
// eslint-disable-next-line no-await-in-loop
|
||||||
storageRecord.contact = await toContactRecord(conversation);
|
storageRecord.contact = await toContactRecord(conversation);
|
||||||
identifier.type = ITEM_TYPE.CONTACT;
|
identifier.type = ITEM_TYPE.CONTACT;
|
||||||
} else if ((conversation.get('groupVersion') || 0) > 1) {
|
} else if (conversation.isGroupV2()) {
|
||||||
storageRecord = new window.textsecure.protobuf.StorageRecord();
|
storageRecord = new window.textsecure.protobuf.StorageRecord();
|
||||||
// eslint-disable-next-line no-await-in-loop
|
// eslint-disable-next-line no-await-in-loop
|
||||||
storageRecord.groupV2 = await toGroupV2Record(conversation);
|
storageRecord.groupV2 = await toGroupV2Record(conversation);
|
||||||
|
|
|
@ -166,7 +166,7 @@ export async function toAccountRecord(
|
||||||
pinnedConversationRecord.legacyGroupId = fromEncodedBinaryToArrayBuffer(
|
pinnedConversationRecord.legacyGroupId = fromEncodedBinaryToArrayBuffer(
|
||||||
groupId
|
groupId
|
||||||
);
|
);
|
||||||
} else if ((pinnedConversation.get('groupVersion') || 0) > 1) {
|
} else if (pinnedConversation.isGroupV2()) {
|
||||||
pinnedConversationRecord.identifier = 'groupMasterKey';
|
pinnedConversationRecord.identifier = 'groupMasterKey';
|
||||||
const masterKey = pinnedConversation.get('masterKey');
|
const masterKey = pinnedConversation.get('masterKey');
|
||||||
if (!masterKey) {
|
if (!masterKey) {
|
||||||
|
|
|
@ -2139,7 +2139,7 @@ Whisper.ConversationView = Whisper.View.extend({
|
||||||
|
|
||||||
let model = providedMembers || this.model.contactCollection;
|
let model = providedMembers || this.model.contactCollection;
|
||||||
|
|
||||||
if (!providedMembers && this.model.get('groupVersion') === 2) {
|
if (!providedMembers && this.model.isGroupV2()) {
|
||||||
model = new Whisper.GroupConversationCollection(
|
model = new Whisper.GroupConversationCollection(
|
||||||
this.model.get('membersV2').map(({ conversationId, role }: any) => ({
|
this.model.get('membersV2').map(({ conversationId, role }: any) => ({
|
||||||
conversation: window.ConversationController.get(conversationId),
|
conversation: window.ConversationController.get(conversationId),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue