mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-04-21 17:08:11 +01:00
Init payments message types
This commit is contained in:
2
ts/textsecure/Types.d.ts
vendored
2
ts/textsecure/Types.d.ts
vendored
@@ -8,6 +8,7 @@ import type { TextAttachmentType } from '../types/Attachment';
|
||||
import type { GiftBadgeStates } from '../components/conversation/Message';
|
||||
import type { MIMEType } from '../types/MIME';
|
||||
import type { DurationInSeconds } from '../util/durations';
|
||||
import type { AnyPaymentEvent } from '../types/Payment';
|
||||
|
||||
export {
|
||||
IdentityKeyType,
|
||||
@@ -211,6 +212,7 @@ export type ProcessedDataMessage = {
|
||||
expireTimer: DurationInSeconds;
|
||||
profileKey?: string;
|
||||
timestamp: number;
|
||||
payment?: AnyPaymentEvent;
|
||||
quote?: ProcessedQuote;
|
||||
contact?: ReadonlyArray<ProcessedContact>;
|
||||
preview?: ReadonlyArray<ProcessedPreview>;
|
||||
|
||||
@@ -29,6 +29,8 @@ import { WarnOnlyError } from './Errors';
|
||||
import { GiftBadgeStates } from '../components/conversation/Message';
|
||||
import { APPLICATION_OCTET_STREAM, stringToMIMEType } from '../types/MIME';
|
||||
import { SECOND, DurationInSeconds } from '../util/durations';
|
||||
import type { AnyPaymentEvent } from '../types/Payment';
|
||||
import { PaymentEventKind } from '../types/Payment';
|
||||
|
||||
const FLAGS = Proto.DataMessage.Flags;
|
||||
export const ATTACHMENT_MAX = 32;
|
||||
@@ -123,6 +125,38 @@ export function processGroupV2Context(
|
||||
};
|
||||
}
|
||||
|
||||
export function processPayment(
|
||||
payment?: Proto.DataMessage.IPayment | null
|
||||
): AnyPaymentEvent | undefined {
|
||||
if (!payment) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (payment.notification != null) {
|
||||
return {
|
||||
kind: PaymentEventKind.Notification,
|
||||
note: payment.notification.note ?? null,
|
||||
};
|
||||
}
|
||||
|
||||
if (payment.activation != null) {
|
||||
if (
|
||||
payment.activation.type ===
|
||||
Proto.DataMessage.Payment.Activation.Type.REQUEST
|
||||
) {
|
||||
return { kind: PaymentEventKind.ActivationRequest };
|
||||
}
|
||||
if (
|
||||
payment.activation.type ===
|
||||
Proto.DataMessage.Payment.Activation.Type.ACTIVATED
|
||||
) {
|
||||
return { kind: PaymentEventKind.Activation };
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function processQuote(
|
||||
quote?: Proto.DataMessage.IQuote | null
|
||||
): ProcessedQuote | undefined {
|
||||
@@ -305,6 +339,7 @@ export function processDataMessage(
|
||||
? Bytes.toBase64(message.profileKey)
|
||||
: undefined,
|
||||
timestamp,
|
||||
payment: processPayment(message.payment),
|
||||
quote: processQuote(message.quote),
|
||||
contact: processContact(message.contact),
|
||||
preview: processPreview(message.preview),
|
||||
|
||||
Reference in New Issue
Block a user