Skip to content

Commit

Permalink
Merge pull request #334 from Secreto31126/emitters-update
Browse files Browse the repository at this point in the history
Emitters update
  • Loading branch information
Secreto31126 committed May 18, 2024
2 parents e8d0011 + a657fe9 commit e6b5293
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "whatsapp-api-js",
"version": "3.0.1",
"version": "3.1.0",
"author": "Secreto31126",
"description": "A TypeScript server agnostic Whatsapp's Official API framework",
"license": "MIT",
Expand Down
10 changes: 10 additions & 0 deletions src/emitters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ export type OnSentArgs = {
* The message id, undefined if parsed is set to false
*/
id?: string;
/**
* If true, the message send was delayed until quality can be validated and it will
* either be sent or dropped at this point. Undefined if parsed is set to false or
* the message_status property is not present in the response.
*/
held_for_quality_assessment?: boolean;
/**
* The parsed response from the server, undefined if parsed is set to false
*/
Expand Down Expand Up @@ -131,6 +137,10 @@ export type OnStatusArgs = {
* The message ID
*/
id: string;
/**
* The message timestamp
*/
timestamp: string;
/**
* The conversation object
*/
Expand Down
10 changes: 10 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,14 @@ export class WhatsAppAPI {
? response.messages[0].id
: undefined
: undefined,
held_for_quality_assessment: response
? "messages" in response
? "message_status" in response.messages[0]
? response.messages[0].message_status ===
"held_for_quality_assessment"
: undefined
: undefined
: undefined,
response
};

Expand Down Expand Up @@ -843,6 +851,7 @@ export class WhatsAppAPI {
const phone = statuses.recipient_id;
const status = statuses.status;
const id = statuses.id;
const timestamp = statuses.timestamp;
const conversation = statuses.conversation;
const pricing = statuses.pricing;
const error = statuses.errors?.[0];
Expand All @@ -853,6 +862,7 @@ export class WhatsAppAPI {
phone,
status,
id,
timestamp,
conversation,
pricing,
error,
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,7 @@ export type ServerSentMessageResponse = {
messages: [
{
id: string;
message_status?: "accepted" | "held_for_quality_assessment";
}
];
};
Expand Down

0 comments on commit e6b5293

Please sign in to comment.