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