A couple cleanups in createSentMessage
This commit is contained in:
parent
d11283f0f1
commit
79aba6bff4
1 changed files with 18 additions and 8 deletions
|
@ -9,7 +9,7 @@ import {
|
||||||
PlaintextContent,
|
PlaintextContent,
|
||||||
} from '@signalapp/signal-client';
|
} from '@signalapp/signal-client';
|
||||||
|
|
||||||
import { DataMessageClass } from './textsecure.d';
|
import { DataMessageClass, SyncMessageClass } from './textsecure.d';
|
||||||
import { SessionResetsType } from './textsecure/Types.d';
|
import { SessionResetsType } from './textsecure/Types.d';
|
||||||
import { MessageAttributesType } from './model-types.d';
|
import { MessageAttributesType } from './model-types.d';
|
||||||
import { WhatIsThis } from './window.d';
|
import { WhatIsThis } from './window.d';
|
||||||
|
@ -3018,12 +3018,21 @@ export async function startApp(): Promise<void> {
|
||||||
|
|
||||||
function createSentMessage(data: WhatIsThis, descriptor: MessageDescriptor) {
|
function createSentMessage(data: WhatIsThis, descriptor: MessageDescriptor) {
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
let sentTo = [];
|
const timestamp = data.timestamp || now;
|
||||||
|
|
||||||
|
const unidentifiedStatus: Array<SyncMessageClass.Sent.UnidentifiedDeliveryStatus> = Array.isArray(
|
||||||
|
data.unidentifiedStatus
|
||||||
|
)
|
||||||
|
? data.unidentifiedStatus
|
||||||
|
: [];
|
||||||
|
|
||||||
|
let sentTo: Array<string> = [];
|
||||||
|
|
||||||
|
if (unidentifiedStatus.length) {
|
||||||
|
sentTo = unidentifiedStatus
|
||||||
|
.map(item => item.destinationUuid || item.destination)
|
||||||
|
.filter(isNotNil);
|
||||||
|
|
||||||
if (data.unidentifiedStatus && data.unidentifiedStatus.length) {
|
|
||||||
sentTo = data.unidentifiedStatus.map(
|
|
||||||
(item: WhatIsThis) => item.destinationUuid || item.destination
|
|
||||||
);
|
|
||||||
const unidentified = window._.filter(data.unidentifiedStatus, item =>
|
const unidentified = window._.filter(data.unidentifiedStatus, item =>
|
||||||
Boolean(item.unidentified)
|
Boolean(item.unidentified)
|
||||||
);
|
);
|
||||||
|
@ -3037,17 +3046,18 @@ export async function startApp(): Promise<void> {
|
||||||
source: window.textsecure.storage.user.getNumber(),
|
source: window.textsecure.storage.user.getNumber(),
|
||||||
sourceUuid: window.textsecure.storage.user.getUuid(),
|
sourceUuid: window.textsecure.storage.user.getUuid(),
|
||||||
sourceDevice: data.device,
|
sourceDevice: data.device,
|
||||||
sent_at: data.timestamp,
|
sent_at: timestamp,
|
||||||
serverTimestamp: data.serverTimestamp,
|
serverTimestamp: data.serverTimestamp,
|
||||||
sent_to: sentTo,
|
sent_to: sentTo,
|
||||||
received_at: data.receivedAtCounter,
|
received_at: data.receivedAtCounter,
|
||||||
received_at_ms: data.receivedAtDate,
|
received_at_ms: data.receivedAtDate,
|
||||||
conversationId: descriptor.id,
|
conversationId: descriptor.id,
|
||||||
|
timestamp,
|
||||||
type: 'outgoing',
|
type: 'outgoing',
|
||||||
sent: true,
|
sent: true,
|
||||||
unidentifiedDeliveries: data.unidentifiedDeliveries || [],
|
unidentifiedDeliveries: data.unidentifiedDeliveries || [],
|
||||||
expirationStartTimestamp: Math.min(
|
expirationStartTimestamp: Math.min(
|
||||||
data.expirationStartTimestamp || data.timestamp || now,
|
data.expirationStartTimestamp || timestamp,
|
||||||
now
|
now
|
||||||
),
|
),
|
||||||
} as WhatIsThis);
|
} as WhatIsThis);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue