Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEVEXP-375: Enhance DX for ttl field in SendMessageRequest #56

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { getAppIdFromConfig, getContactIdFromConfig, initConversationService, pr
queue: 'HIGH_PRIORITY',
processing_strategy: 'DEFAULT',
channel_priority_order: ['MESSENGER'],
ttl_seconds: 60,
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class ConversationEventService {
contact_id: message.contact_id!,
},
message: this.buildContactMessage(contactMessage),
ttl: '5s',
ttl_seconds: 5,
channel_properties: {
MESSENGER_NOTIFICATION_TYPE: 'NO_PUSH',
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export interface SendMessageRequestBase<T extends Recipient> {
/** @see Recipient */
recipient: T;
/** The timeout allotted for sending the message, expressed in seconds. Passed to channels which support it and emulated by the Conversation API for channels without ttl support but with message retract/unsend functionality. Channel failover will not be performed for messages with an expired TTL. The format is an integer with the suffix `s` (for seconds). Valid integer range is 3 to 315,576,000,000 (inclusive). Example values include `10s` (10 seconds) and `86400s` (24 hours). */
ttl?: string;
ttl_seconds?: number;
JPPortier marked this conversation as resolved.
Show resolved Hide resolved
/** Overrides the app\'s [Processing Mode](../../../../../conversation/processing-modes/). Default value is `DEFAULT`. */
processing_strategy?: ProcessingStrategy;
/** An arbitrary identifier that will be propagated to callbacks related to this message, including MO replies. Only applicable to messages sent with the `CONVERSATION` processing mode. Up to 128 characters long. */
Expand Down
6 changes: 6 additions & 0 deletions packages/conversation/src/rest/v1/messages/messages-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,12 @@ export class MessagesApi extends ConversationDomainApi {
'Accept': 'application/json',
};

// Special fields handling: ttl_seconds: number => ttl: string
if (data.sendMessageRequestBody.ttl_seconds !== undefined) {
(data as any).sendMessageRequestBody.ttl = data.sendMessageRequestBody.ttl_seconds + 's';
delete data.sendMessageRequestBody.ttl_seconds;
JPPortier marked this conversation as resolved.
Show resolved Hide resolved
}

const body: RequestBody = data['sendMessageRequestBody']
? JSON.stringify(data['sendMessageRequestBody'])
: '{}';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ describe('MessagesApi', () => {
message: {
...messageBuilder.text(textMessageItem),
},
ttl_seconds: 20,
};
const requestDataWithContactId: SendMessageRequestData<ContactId> = {
sendMessageRequestBody: {
Expand Down
Loading