Prune invalid conversations from storage service
This commit is contained in:
parent
d0f1b8892d
commit
f204784afe
|
@ -167,6 +167,20 @@ async function generateManifest(
|
|||
continue;
|
||||
}
|
||||
|
||||
const validationError = conversation.validate();
|
||||
if (validationError) {
|
||||
if (conversation.get('storageID')) {
|
||||
log.warn(
|
||||
'storageService.generateManifest: skipping contact',
|
||||
conversation.idForLogging(),
|
||||
'due to local validation error',
|
||||
validationError
|
||||
);
|
||||
conversation.unset('storageID');
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
storageRecord = new Proto.StorageRecord();
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
storageRecord.contact = await toContactRecord(conversation);
|
||||
|
|
|
@ -35,9 +35,12 @@ import {
|
|||
} from '../util/universalExpireTimer';
|
||||
import { ourProfileKeyService } from './ourProfileKey';
|
||||
import { isGroupV1, isGroupV2 } from '../util/whatTypeOfConversation';
|
||||
import { isValidUuid } from '../types/UUID';
|
||||
import type { ConversationAttributesType } from '../model-types.d';
|
||||
import * as preferredReactionEmoji from '../reactions/preferredReactionEmoji';
|
||||
import { SignalService as Proto } from '../protobuf';
|
||||
import * as log from '../logging/log';
|
||||
import type { WhatIsThis } from '../window.d';
|
||||
|
||||
const { updateConversation } = dataInterface;
|
||||
|
||||
|
@ -730,6 +733,25 @@ export async function mergeContactRecord(
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!isValidUuid(uuid)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const c = new window.Whisper.Conversation(({
|
||||
e164,
|
||||
uuid,
|
||||
type: 'private',
|
||||
} as Partial<ConversationAttributesType>) as WhatIsThis);
|
||||
|
||||
const validationError = c.validate();
|
||||
if (validationError) {
|
||||
log.error(
|
||||
'storageService.mergeContactRecord: invalid contact',
|
||||
validationError
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
const id = window.ConversationController.ensureContactIds({
|
||||
e164,
|
||||
uuid,
|
||||
|
|
Loading…
Reference in New Issue