Skip to content

Commit d434a2a

Browse files
committed
✨ feat: pinMessage #3256
1 parent b6a9cd6 commit d434a2a

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

src/api/Client.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { default as mime } from 'mime-types';
22
import { Page, EvaluateFunc, PageEvent } from 'puppeteer';
33
import { Chat, LiveLocationChangedEvent, ChatState, ChatMuteDuration, GroupChatCreationResponse, EphemeralDuration } from './model/chat';
44
import { BusinessProfile, Contact, NumberCheck } from './model/contact';
5-
import { Message, MessageInfo, PollData } from './model/message';
5+
import { Message, MessageInfo, MessagePinDuration, PollData } from './model/message';
66
import { default as axios, AxiosRequestConfig} from 'axios';
77
import { NewCommunityGroup, ParticipantChangedEventModel, GenericGroupChangeEvent, GroupMetadata } from './model/group-metadata';
88
import { useragent } from '../config/puppeteer.config'
@@ -273,6 +273,7 @@ declare module WAPI {
273273
const simulateRecording: (to: string, on: boolean) => Promise<boolean>;
274274
const archiveChat: (id: string, archive: boolean) => Promise<boolean>;
275275
const pinChat: (id: string, pin: boolean) => Promise<boolean>;
276+
const pinMessage: (id: string, pin: boolean, pinDuration: string) => Promise<boolean>;
276277
const markAllRead: () => Boolean;
277278
const isConnected: () => Boolean;
278279
const logout: () => Boolean;
@@ -2441,7 +2442,7 @@ public async testCallback(callbackToTest: SimpleListener, testData: any) : Prom
24412442
* Pin/Unpin chats
24422443
*
24432444
* @param id The id of the conversation
2444-
* @param archive boolean true => pin, false => unpin
2445+
* @param pin boolean true => pin, false => unpin
24452446
* @return boolean true: worked
24462447
*/
24472448
public async pinChat(id: ChatId, pin: boolean) : Promise<boolean>{
@@ -2451,6 +2452,20 @@ public async testCallback(callbackToTest: SimpleListener, testData: any) : Prom
24512452
) as Promise<boolean>;
24522453
}
24532454

2455+
/**
2456+
* Pin/Unpin message
2457+
*
2458+
* @param id The id of the message
2459+
* @param pin boolean true => pin, false => unpin
2460+
* @param pinDuration The length of time to pin the message. Default `ThirtyDays`
2461+
* @return boolean true: worked
2462+
*/
2463+
public async pinMessage(id: MessageId, pin: boolean, pinDuration: MessagePinDuration = "ThirtyDays") : Promise<boolean>{
2464+
return await this.pup(
2465+
({ id, pin, pinDuration }) => WAPI.pinMessage(id, pin, pinDuration),
2466+
{ id, pin, pinDuration }
2467+
) as Promise<boolean>;
2468+
}
24542469

24552470
/**
24562471
*

src/api/model/message.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import { Button, Row, Section } from "./button";
33
import { Chat } from "./chat";
44
import { Contact } from "./contact";
55

6+
7+
export type MessagePinDuration = "FifteenSeconds" | "FiveSeconds" | "OneDay" | "OneMinute" | "SevenDays" | "ThirtyDays"
8+
69
export interface Message {
710
/**
811
* The ID of the selected button

0 commit comments

Comments
 (0)