Skip to content

Commit

Permalink
feat: Added WPP.chat.canMarkPlayed function
Browse files Browse the repository at this point in the history
  • Loading branch information
icleitoncosta committed Aug 13, 2022
1 parent c21941f commit 4149eec
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
48 changes: 48 additions & 0 deletions src/chat/functions/canMarkPlayed.ts
@@ -0,0 +1,48 @@
/*!
* Copyright 2022 WPPConnect Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { Stringable } from '../../types';
import { MsgKey, MsgModel } from '../../whatsapp';
import { canMarkPlayed as CanMarkPlayed } from '../../whatsapp/functions';
import { getMessageById } from './getMessageById';

/**
* Get if message can played
*
* @example
* ```javascript
* WPP.chat.canMarkPlayed('[message_id]');
* ```
* @category Message
*/
export async function canMarkPlayed(
messageId: string | MsgKey | MsgModel | Stringable
): Promise<any> {
if (
!(messageId instanceof MsgModel) &&
typeof messageId !== 'string' &&
typeof messageId.toString === 'function'
) {
messageId = messageId.toString();
}

const msg =
messageId instanceof MsgModel
? messageId
: await getMessageById(messageId.toString());

return CanMarkPlayed(msg);
}
4 changes: 3 additions & 1 deletion src/whatsapp/functions/markSeen.ts
Expand Up @@ -40,7 +40,8 @@ export declare function sendSeen(
export declare function markPlayed(msg: MsgModel): Promise<void>;

/**
* @whatsapp 2.2146.9:64850
* @whatsapp 64850
* @whatsapp 242050 >= 2.2228.4
*/
export declare function canMarkPlayed(msg: MsgModel): boolean;

Expand All @@ -57,6 +58,7 @@ exportModule(
exports,
{
markPlayed: 'markPlayed',
canMarkPlayed: 'canMarkPlayed',
},
(m) => m.markPlayed
);

0 comments on commit 4149eec

Please sign in to comment.