Improve reaction targeting

This commit is contained in:
trevor-signal 2025-05-13 13:46:30 -04:00 committed by GitHub
commit cc24f0524b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 571 additions and 11 deletions

View file

@ -11,7 +11,7 @@ import type {
QuotedAttachmentType,
QuotedMessageType,
} from '../model-types.d';
import type { ServiceIdString } from '../types/ServiceId';
import type { AciString, ServiceIdString } from '../types/ServiceId';
import { PaymentEventKind } from '../types/Payment';
import type { AnyPaymentEvent } from '../types/Payment';
import type { LocalizerType } from '../types/Util';
@ -35,6 +35,27 @@ export function isStory(
return message.type === 'story';
}
function isFromUs(
message: Pick<ReadonlyMessageAttributesType, 'sourceServiceId'>,
ourAci: AciString
) {
return message.sourceServiceId === ourAci;
}
export function isOutgoingStory(
message: Pick<ReadonlyMessageAttributesType, 'type' | 'sourceServiceId'>,
ourAci: AciString
): boolean {
return isStory(message) && isFromUs(message, ourAci);
}
export function isIncomingStory(
message: Pick<ReadonlyMessageAttributesType, 'type' | 'sourceServiceId'>,
ourAci: AciString
): boolean {
return isStory(message) && !isFromUs(message, ourAci);
}
export type MessageAttributesWithPaymentEvent = ReadonlyMessageAttributesType &
ReadonlyDeep<{
payment: AnyPaymentEvent;