Include and process destinationPniIdentityKey
This commit is contained in:
parent
711e321d16
commit
e031d136a1
11 changed files with 238 additions and 214 deletions
|
@ -5,6 +5,7 @@ import { isNumber, throttle, groupBy } from 'lodash';
|
|||
import { render } from 'react-dom';
|
||||
import { batch as batchDispatch } from 'react-redux';
|
||||
import PQueue from 'p-queue';
|
||||
import pMap from 'p-map';
|
||||
import { v4 as generateUuid } from 'uuid';
|
||||
|
||||
import * as Registration from './util/registration';
|
||||
|
@ -52,6 +53,7 @@ import { GROUP_CREDENTIALS_KEY } from './services/groupCredentialFetcher';
|
|||
import * as KeyboardLayout from './services/keyboardLayout';
|
||||
import * as StorageService from './services/storage';
|
||||
import { usernameIntegrity } from './services/usernameIntegrity';
|
||||
import { updateIdentityKey } from './services/profiles';
|
||||
import { RoutineProfileRefresher } from './routineProfileRefresh';
|
||||
import { isOlderThan } from './util/timestamp';
|
||||
import { isValidReactionEmoji } from './reactions/isValidReactionEmoji';
|
||||
|
@ -2536,46 +2538,74 @@ export async function startApp(): Promise<void> {
|
|||
return confirm();
|
||||
}
|
||||
|
||||
function createSentMessage(
|
||||
async function createSentMessage(
|
||||
data: SentEventData,
|
||||
descriptor: MessageDescriptor
|
||||
) {
|
||||
const now = Date.now();
|
||||
const timestamp = data.timestamp || now;
|
||||
const logId = `createSentMessage(${timestamp})`;
|
||||
|
||||
const ourId = window.ConversationController.getOurConversationIdOrThrow();
|
||||
|
||||
const { unidentifiedStatus = [] } = data;
|
||||
|
||||
const sendStateByConversationId: SendStateByConversationId =
|
||||
unidentifiedStatus.reduce(
|
||||
(
|
||||
result: SendStateByConversationId,
|
||||
{ destinationServiceId, destination, isAllowedToReplyToStory }
|
||||
) => {
|
||||
const conversation = window.ConversationController.get(
|
||||
destinationServiceId || destination
|
||||
);
|
||||
if (!conversation || conversation.id === ourId) {
|
||||
return result;
|
||||
}
|
||||
const sendStateByConversationId: SendStateByConversationId = {
|
||||
[ourId]: {
|
||||
status: SendStatus.Sent,
|
||||
updatedAt: timestamp,
|
||||
},
|
||||
};
|
||||
|
||||
return {
|
||||
...result,
|
||||
[conversation.id]: {
|
||||
isAllowedToReplyToStory,
|
||||
status: SendStatus.Sent,
|
||||
updatedAt: timestamp,
|
||||
},
|
||||
};
|
||||
},
|
||||
{
|
||||
[ourId]: {
|
||||
status: SendStatus.Sent,
|
||||
updatedAt: timestamp,
|
||||
},
|
||||
}
|
||||
for (const {
|
||||
destinationServiceId,
|
||||
destination,
|
||||
isAllowedToReplyToStory,
|
||||
} of unidentifiedStatus) {
|
||||
const conversation = window.ConversationController.get(
|
||||
destinationServiceId || destination
|
||||
);
|
||||
if (!conversation || conversation.id === ourId) {
|
||||
continue;
|
||||
}
|
||||
|
||||
sendStateByConversationId[conversation.id] = {
|
||||
isAllowedToReplyToStory,
|
||||
status: SendStatus.Sent,
|
||||
updatedAt: timestamp,
|
||||
};
|
||||
}
|
||||
|
||||
await pMap(
|
||||
unidentifiedStatus,
|
||||
async ({ destinationServiceId, destinationPniIdentityKey }) => {
|
||||
if (!Bytes.isNotEmpty(destinationPniIdentityKey)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isPniString(destinationServiceId)) {
|
||||
log.warn(
|
||||
`${logId}: received an destinationPniIdentityKey for ` +
|
||||
`an invalid PNI: ${destinationServiceId}`
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const changed = await updateIdentityKey(
|
||||
destinationPniIdentityKey,
|
||||
destinationServiceId,
|
||||
{
|
||||
noOverwrite: true,
|
||||
}
|
||||
);
|
||||
if (changed) {
|
||||
log.info(
|
||||
`${logId}: Updated identity key for ${destinationServiceId}`
|
||||
);
|
||||
}
|
||||
},
|
||||
{ concurrency: 10 }
|
||||
);
|
||||
|
||||
let unidentifiedDeliveries: Array<string> = [];
|
||||
if (unidentifiedStatus.length) {
|
||||
|
@ -2720,7 +2750,7 @@ export async function startApp(): Promise<void> {
|
|||
});
|
||||
}
|
||||
|
||||
const message = createSentMessage(data, messageDescriptor);
|
||||
const message = await createSentMessage(data, messageDescriptor);
|
||||
|
||||
if (data.message.reaction) {
|
||||
strictAssert(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue