From d434a2ab7842b0e24f8eba1f513590f3ed23e62d Mon Sep 17 00:00:00 2001 From: M SHAH Date: Sun, 22 Dec 2024 16:57:46 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20`pinMessage`=20#3256?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/Client.ts | 19 +++++++++++++++++-- src/api/model/message.ts | 3 +++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/api/Client.ts b/src/api/Client.ts index 256531e50..28cb32773 100644 --- a/src/api/Client.ts +++ b/src/api/Client.ts @@ -2,7 +2,7 @@ import { default as mime } from 'mime-types'; import { Page, EvaluateFunc, PageEvent } from 'puppeteer'; import { Chat, LiveLocationChangedEvent, ChatState, ChatMuteDuration, GroupChatCreationResponse, EphemeralDuration } from './model/chat'; import { BusinessProfile, Contact, NumberCheck } from './model/contact'; -import { Message, MessageInfo, PollData } from './model/message'; +import { Message, MessageInfo, MessagePinDuration, PollData } from './model/message'; import { default as axios, AxiosRequestConfig} from 'axios'; import { NewCommunityGroup, ParticipantChangedEventModel, GenericGroupChangeEvent, GroupMetadata } from './model/group-metadata'; import { useragent } from '../config/puppeteer.config' @@ -273,6 +273,7 @@ declare module WAPI { const simulateRecording: (to: string, on: boolean) => Promise; const archiveChat: (id: string, archive: boolean) => Promise; const pinChat: (id: string, pin: boolean) => Promise; + const pinMessage: (id: string, pin: boolean, pinDuration: string) => Promise; const markAllRead: () => Boolean; const isConnected: () => Boolean; const logout: () => Boolean; @@ -2441,7 +2442,7 @@ public async testCallback(callbackToTest: SimpleListener, testData: any) : Prom * Pin/Unpin chats * * @param id The id of the conversation - * @param archive boolean true => pin, false => unpin + * @param pin boolean true => pin, false => unpin * @return boolean true: worked */ public async pinChat(id: ChatId, pin: boolean) : Promise{ @@ -2451,6 +2452,20 @@ public async testCallback(callbackToTest: SimpleListener, testData: any) : Prom ) as Promise; } + /** + * Pin/Unpin message + * + * @param id The id of the message + * @param pin boolean true => pin, false => unpin + * @param pinDuration The length of time to pin the message. Default `ThirtyDays` + * @return boolean true: worked + */ + public async pinMessage(id: MessageId, pin: boolean, pinDuration: MessagePinDuration = "ThirtyDays") : Promise{ + return await this.pup( + ({ id, pin, pinDuration }) => WAPI.pinMessage(id, pin, pinDuration), + { id, pin, pinDuration } + ) as Promise; + } /** * diff --git a/src/api/model/message.ts b/src/api/model/message.ts index 25baaa6f8..3f1c64512 100644 --- a/src/api/model/message.ts +++ b/src/api/model/message.ts @@ -3,6 +3,9 @@ import { Button, Row, Section } from "./button"; import { Chat } from "./chat"; import { Contact } from "./contact"; + +export type MessagePinDuration = "FifteenSeconds" | "FiveSeconds" | "OneDay" | "OneMinute" | "SevenDays" | "ThirtyDays" + export interface Message { /** * The ID of the selected button