mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-05-08 08:58:38 +01:00
DOE for stories
This commit is contained in:
@@ -109,6 +109,7 @@ import {
|
||||
ContactSyncEvent,
|
||||
GroupEvent,
|
||||
GroupSyncEvent,
|
||||
StoryRecipientUpdateEvent,
|
||||
} from './messageReceiverEvents';
|
||||
import * as log from '../logging/log';
|
||||
import * as durations from '../util/durations';
|
||||
@@ -579,6 +580,11 @@ export default class MessageReceiver
|
||||
handler: (ev: EnvelopeEvent) => void
|
||||
): void;
|
||||
|
||||
public override addEventListener(
|
||||
name: 'storyRecipientUpdate',
|
||||
handler: (ev: StoryRecipientUpdateEvent) => void
|
||||
): void;
|
||||
|
||||
public override addEventListener(name: string, handler: EventHandler): void {
|
||||
return super.addEventListener(name, handler);
|
||||
}
|
||||
@@ -1821,7 +1827,8 @@ export default class MessageReceiver
|
||||
const ev = new SentEvent(
|
||||
{
|
||||
destination: dropNull(destination),
|
||||
destinationUuid: dropNull(destinationUuid),
|
||||
destinationUuid:
|
||||
dropNull(destinationUuid) || envelope.destinationUuid.toString(),
|
||||
timestamp: timestamp?.toNumber(),
|
||||
serverTimestamp: envelope.serverTimestamp,
|
||||
device: envelope.sourceDevice,
|
||||
@@ -1931,7 +1938,7 @@ export default class MessageReceiver
|
||||
|
||||
isAllowedToReply.set(
|
||||
destinationUuid,
|
||||
Boolean(recipient.isAllowedToReply)
|
||||
recipient.isAllowedToReply !== false
|
||||
);
|
||||
});
|
||||
|
||||
@@ -2572,6 +2579,18 @@ export default class MessageReceiver
|
||||
return;
|
||||
}
|
||||
|
||||
if (sentMessage.storyMessageRecipients && sentMessage.isRecipientUpdate) {
|
||||
const ev = new StoryRecipientUpdateEvent(
|
||||
{
|
||||
destinationUuid: envelope.destinationUuid.toString(),
|
||||
timestamp: envelope.timestamp,
|
||||
storyMessageRecipients: sentMessage.storyMessageRecipients,
|
||||
},
|
||||
this.removeFromCache.bind(this, envelope)
|
||||
);
|
||||
return this.dispatchAndWait(ev);
|
||||
}
|
||||
|
||||
if (!sentMessage || !sentMessage.message) {
|
||||
throw new Error(
|
||||
'MessageReceiver.handleSyncMessage: sync sent message was missing message'
|
||||
|
||||
@@ -1232,8 +1232,9 @@ export default class MessageSender {
|
||||
isUpdate,
|
||||
urgent,
|
||||
options,
|
||||
storyMessageRecipients,
|
||||
}: Readonly<{
|
||||
encodedDataMessage: Uint8Array;
|
||||
encodedDataMessage?: Uint8Array;
|
||||
timestamp: number;
|
||||
destination: string | undefined;
|
||||
destinationUuid: string | null | undefined;
|
||||
@@ -1243,13 +1244,21 @@ export default class MessageSender {
|
||||
isUpdate?: boolean;
|
||||
urgent: boolean;
|
||||
options?: SendOptionsType;
|
||||
storyMessageRecipients?: Array<{
|
||||
destinationUuid: string;
|
||||
distributionListIds: Array<string>;
|
||||
isAllowedToReply: boolean;
|
||||
}>;
|
||||
}>): Promise<CallbackResultType> {
|
||||
const myUuid = window.textsecure.storage.user.getCheckedUuid();
|
||||
|
||||
const dataMessage = Proto.DataMessage.decode(encodedDataMessage);
|
||||
const sentMessage = new Proto.SyncMessage.Sent();
|
||||
sentMessage.timestamp = Long.fromNumber(timestamp);
|
||||
sentMessage.message = dataMessage;
|
||||
|
||||
if (encodedDataMessage) {
|
||||
const dataMessage = Proto.DataMessage.decode(encodedDataMessage);
|
||||
sentMessage.message = dataMessage;
|
||||
}
|
||||
if (destination) {
|
||||
sentMessage.destination = destination;
|
||||
}
|
||||
@@ -1261,6 +1270,19 @@ export default class MessageSender {
|
||||
expirationStartTimestamp
|
||||
);
|
||||
}
|
||||
if (storyMessageRecipients) {
|
||||
sentMessage.storyMessageRecipients = storyMessageRecipients.map(
|
||||
recipient => {
|
||||
const storyMessageRecipient =
|
||||
new Proto.SyncMessage.Sent.StoryMessageRecipient();
|
||||
storyMessageRecipient.destinationUuid = recipient.destinationUuid;
|
||||
storyMessageRecipient.distributionListIds =
|
||||
recipient.distributionListIds;
|
||||
storyMessageRecipient.isAllowedToReply = recipient.isAllowedToReply;
|
||||
return storyMessageRecipient;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if (isUpdate) {
|
||||
sentMessage.isRecipientUpdate = true;
|
||||
|
||||
@@ -418,3 +418,18 @@ export class ViewSyncEvent extends ConfirmableEvent {
|
||||
super('viewSync', confirm);
|
||||
}
|
||||
}
|
||||
|
||||
export type StoryRecipientUpdateData = Readonly<{
|
||||
destinationUuid: string;
|
||||
storyMessageRecipients: Array<Proto.SyncMessage.Sent.IStoryMessageRecipient>;
|
||||
timestamp: number;
|
||||
}>;
|
||||
|
||||
export class StoryRecipientUpdateEvent extends ConfirmableEvent {
|
||||
constructor(
|
||||
public readonly data: StoryRecipientUpdateData,
|
||||
confirm: ConfirmCallback
|
||||
) {
|
||||
super('storyRecipientUpdate', confirm);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user