Remove isPrivate, isMe, isGroupV1, isGroupV2 from model

This commit is contained in:
Josh Perez 2021-06-07 12:39:13 -04:00 committed by GitHub
parent eaf4036fc8
commit d4875fd8f4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 377 additions and 267 deletions

View file

@ -43,6 +43,7 @@ import {
set as setUniversalExpireTimer,
} from '../util/universalExpireTimer';
import { ourProfileKeyService } from './ourProfileKey';
import { isGroupV1, isGroupV2 } from '../util/whatTypeOfConversation';
const { updateConversation } = dataInterface;
@ -241,7 +242,7 @@ export async function toAccountRecord(
uuid: pinnedConversation.get('uuid'),
e164: pinnedConversation.get('e164'),
};
} else if (pinnedConversation.isGroupV1()) {
} else if (isGroupV1(pinnedConversation.attributes)) {
pinnedConversationRecord.identifier = 'legacyGroupId';
const groupId = pinnedConversation.get('groupId');
if (!groupId) {
@ -252,7 +253,7 @@ export async function toAccountRecord(
pinnedConversationRecord.legacyGroupId = fromEncodedBinaryToArrayBuffer(
groupId
);
} else if (pinnedConversation.isGroupV2()) {
} else if (isGroupV2(pinnedConversation.attributes)) {
pinnedConversationRecord.identifier = 'groupMasterKey';
const masterKey = pinnedConversation.get('masterKey');
if (!masterKey) {
@ -508,7 +509,7 @@ export async function mergeGroupV1Record(
// where the binary representation of its ID matches a v2 record in memory.
// Here we ensure that the record we're about to process is GV1 otherwise
// we drop the update.
if (conversation && !conversation.isGroupV1()) {
if (conversation && !isGroupV1(conversation.attributes)) {
throw new Error(
`Record has group type mismatch ${conversation.idForLogging()}`
);
@ -565,7 +566,7 @@ export async function mergeGroupV1Record(
let hasPendingChanges: boolean;
if (conversation.isGroupV1()) {
if (isGroupV1(conversation.attributes)) {
addUnknownFields(groupV1Record, conversation);
hasPendingChanges = doesRecordHavePendingChanges(
@ -684,7 +685,7 @@ export async function mergeGroupV2Record(
const isFirstSync = !window.storage.get('storageFetchComplete');
const dropInitialJoinMessage = isFirstSync;
if (conversation.isGroupV1()) {
if (isGroupV1(conversation.attributes)) {
// If we found a GroupV1 conversation from this incoming GroupV2 record, we need to
// migrate it!