6545ca274c
refactored `SentMessagePersistenceService` to be thin wrapper over `saveMessagesAndEnqueueContactCreation` this fixes a bug where the old logic did not call match participants causing messages to not show up
26 lines
807 B
TypeScript
26 lines
807 B
TypeScript
import { isNonEmptyString } from '@sniptt/guards';
|
|
|
|
import { type SendMessageResult } from 'src/modules/messaging/message-outbound-manager/types/send-message-result.type';
|
|
|
|
export const resolveOutboundThreadExternalId = ({
|
|
sendResult,
|
|
inReplyTo,
|
|
}: {
|
|
sendResult: SendMessageResult;
|
|
inReplyTo?: string;
|
|
}): string => {
|
|
if (isNonEmptyString(sendResult.threadExternalId)) {
|
|
return sendResult.threadExternalId;
|
|
}
|
|
|
|
// IMAP/SMTP have no server-side thread id. Reuse the parent's Message-ID so
|
|
// the reply attaches to the same thread the parent stored under.
|
|
if (isNonEmptyString(inReplyTo)) {
|
|
return inReplyTo;
|
|
}
|
|
|
|
// New IMAP/SMTP send: own Message-ID is unique per RFC822, so unrelated
|
|
// sends never collide on a shared empty thread key.
|
|
return sendResult.headerMessageId;
|
|
};
|