Batch and de-duplicate profile key updates

This commit is contained in:
Fedor Indutny 2021-05-11 11:26:44 -07:00 committed by GitHub
parent c2a0072fa1
commit e51260a23f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 31 deletions

View file

@ -1,25 +1,11 @@
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { MessageModel } from '../models/messages';
import { assert } from './assert';
import { ConversationModel } from '../models/conversations';
export async function shouldRespondWithProfileKey(
message: MessageModel
sender: ConversationModel
): Promise<boolean> {
if (!message.isIncoming() || message.get('unidentifiedDeliveryReceived')) {
return false;
}
const sender = message.getContact();
if (!sender) {
assert(
false,
'MessageModel#shouldRespondWithProfileKey had no sender. Returning false'
);
return false;
}
if (sender.isMe() || !sender.getAccepted() || sender.isBlocked()) {
return false;
}