Introduce Service Id Types
Co-authored-by: Scott Nonnenberg <scott@signal.org>
This commit is contained in:
parent
414c0a58d3
commit
366b875fd2
269 changed files with 5832 additions and 5550 deletions
|
@ -7,6 +7,8 @@ import type { ConversationQueueJobData } from '../jobs/conversationJobQueue';
|
|||
import type { StoryDataType } from '../state/ducks/stories';
|
||||
import * as Errors from '../types/errors';
|
||||
import type { StoryMessageRecipientsType } from '../types/Stories';
|
||||
import type { StoryDistributionIdString } from '../types/StoryDistributionId';
|
||||
import type { ServiceIdString } from '../types/ServiceId';
|
||||
import * as log from '../logging/log';
|
||||
import { DAY } from './durations';
|
||||
import { StoryRecipientUpdateEvent } from '../textsecure/messageReceiverEvents';
|
||||
|
@ -21,7 +23,6 @@ import { getMessageById } from '../messages/getMessageById';
|
|||
import { strictAssert } from './assert';
|
||||
import { repeat, zipObject } from './iterables';
|
||||
import { isOlderThan } from './timestamp';
|
||||
import { getTaggedConversationUuid } from './getConversationUuid';
|
||||
|
||||
export async function deleteStoryForEveryone(
|
||||
stories: ReadonlyArray<StoryDataType>,
|
||||
|
@ -56,9 +57,9 @@ export async function deleteStoryForEveryone(
|
|||
|
||||
const conversationIds = new Set(Object.keys(story.sendStateByConversationId));
|
||||
const newStoryRecipients = new Map<
|
||||
string,
|
||||
ServiceIdString,
|
||||
{
|
||||
distributionListIds: Set<string>;
|
||||
distributionListIds: Set<StoryDistributionIdString>;
|
||||
isAllowedToReply: boolean;
|
||||
}
|
||||
>();
|
||||
|
@ -79,14 +80,14 @@ export async function deleteStoryForEveryone(
|
|||
return;
|
||||
}
|
||||
|
||||
const destinationUuid =
|
||||
window.ConversationController.get(recipientId)?.get('uuid');
|
||||
const destinationServiceId =
|
||||
window.ConversationController.get(recipientId)?.getServiceId();
|
||||
|
||||
if (!destinationUuid) {
|
||||
if (!destinationServiceId) {
|
||||
return;
|
||||
}
|
||||
|
||||
newStoryRecipients.set(destinationUuid, {
|
||||
newStoryRecipients.set(destinationServiceId, {
|
||||
distributionListIds: new Set(),
|
||||
isAllowedToReply: sendState.isAllowedToReplyToStory !== false,
|
||||
});
|
||||
|
@ -116,10 +117,10 @@ export async function deleteStoryForEveryone(
|
|||
return;
|
||||
}
|
||||
|
||||
const destinationUuid =
|
||||
window.ConversationController.get(conversationId)?.get('uuid');
|
||||
const destinationServiceId =
|
||||
window.ConversationController.get(conversationId)?.getServiceId();
|
||||
|
||||
if (!destinationUuid) {
|
||||
if (!destinationServiceId) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -135,7 +136,7 @@ export async function deleteStoryForEveryone(
|
|||
|
||||
// Build complete list of new story recipients (not counting ones that
|
||||
// are in the deleted story).
|
||||
let recipient = newStoryRecipients.get(destinationUuid);
|
||||
let recipient = newStoryRecipients.get(destinationServiceId);
|
||||
if (!recipient) {
|
||||
const isAllowedToReply =
|
||||
sendStateByConversationId[conversationId].isAllowedToReplyToStory;
|
||||
|
@ -144,7 +145,7 @@ export async function deleteStoryForEveryone(
|
|||
isAllowedToReply: isAllowedToReply !== false,
|
||||
};
|
||||
|
||||
newStoryRecipients.set(destinationUuid, recipient);
|
||||
newStoryRecipients.set(destinationServiceId, recipient);
|
||||
}
|
||||
|
||||
recipient.distributionListIds.add(item.storyDistributionListId);
|
||||
|
@ -157,26 +158,17 @@ export async function deleteStoryForEveryone(
|
|||
|
||||
const newStoryMessageRecipients: StoryMessageRecipientsType = [];
|
||||
|
||||
newStoryRecipients.forEach((recipientData, destinationUuid) => {
|
||||
const recipient = window.ConversationController.get(destinationUuid);
|
||||
if (!recipient) {
|
||||
return;
|
||||
}
|
||||
const taggedUuid = getTaggedConversationUuid(recipient.attributes);
|
||||
if (!taggedUuid) {
|
||||
return;
|
||||
}
|
||||
newStoryRecipients.forEach((recipientData, destinationServiceId) => {
|
||||
newStoryMessageRecipients.push({
|
||||
destinationAci: taggedUuid.aci,
|
||||
destinationPni: taggedUuid.pni,
|
||||
destinationServiceId,
|
||||
distributionListIds: Array.from(recipientData.distributionListIds),
|
||||
isAllowedToReply: recipientData.isAllowedToReply,
|
||||
});
|
||||
});
|
||||
|
||||
const destinationUuid = ourConversation
|
||||
.getCheckedUuid('deleteStoryForEveryone')
|
||||
.toString();
|
||||
const destinationServiceId = ourConversation.getCheckedServiceId(
|
||||
'deleteStoryForEveryone'
|
||||
);
|
||||
|
||||
log.info(`${logId}: sending DOE to ${conversationIds.size} conversations`);
|
||||
|
||||
|
@ -200,7 +192,7 @@ export async function deleteStoryForEveryone(
|
|||
|
||||
await window.Signal.Data.saveMessage(message.attributes, {
|
||||
jobToInsert,
|
||||
ourUuid: window.textsecure.storage.user.getCheckedUuid().toString(),
|
||||
ourAci: window.textsecure.storage.user.getCheckedAci(),
|
||||
});
|
||||
});
|
||||
} catch (error) {
|
||||
|
@ -216,7 +208,7 @@ export async function deleteStoryForEveryone(
|
|||
// Emulate message for Desktop (this will call deleteForEveryone())
|
||||
const ev = new StoryRecipientUpdateEvent(
|
||||
{
|
||||
destinationUuid,
|
||||
destinationServiceId,
|
||||
timestamp: story.timestamp,
|
||||
storyMessageRecipients: newStoryMessageRecipients,
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue