Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
81f9df000a | ||
|
|
0dcb31c108 | ||
|
|
cd4140fda9 | ||
|
|
117cc25cdb | ||
|
|
832ad26151 | ||
|
|
5a344cd8ad | ||
|
|
0b0a67cdad | ||
|
|
a326a240f0 | ||
|
|
dfdb033769 | ||
|
|
a31af45d97 | ||
|
|
cae955c483 | ||
|
|
0bfff5259e | ||
|
|
0fa83e603b |
No files matched your search
@@ -55,6 +55,7 @@ jobs:
|
||||
flavor: latest=false
|
||||
tags: |
|
||||
type=raw,value=${{ matrix.tag }}
|
||||
type=raw,value={{tag}}-${{ matrix.tag }}
|
||||
|
||||
- name: Login to image repository
|
||||
if: github.ref_type == 'tag'
|
||||
|
||||
@@ -49,16 +49,6 @@ Not running Chromium saves you CPU and Memory, so you can run more instances on
|
||||
⚠ Read the article before using **NOWEB** engine
|
||||
[How to avoid blocking ->]({{< relref " /docs/overview/how-to-avoid-blocking" >}}).
|
||||
|
||||
### MOBILE (experimental)
|
||||
{{< alert icon="👉" text="<b>Experimental engine!</b><br/>Please contact us on <a href='https://www.patreon.com/wa_http_api' target='_blank'>Patreon -></a> or <a href='https://boosty.to/wa-http-api' target='_blank'>Boosty -></a> if you're interested in using it.<br>Available for <a href='https://waha.devlike.pro/docs/how-to/plus-version/#tiers' target='_blank'>PRO</a> subscribers only" />}}
|
||||
|
||||
- `WHATSAPP_DEFAULT_ENGINE=MOBILE`
|
||||
- [https://github.com/WhiskeySockets/Baileys](https://github.com/WhiskeySockets/Baileys)
|
||||
|
||||
**MOBILE** engine **does not require a browser and a mobile device** to work with WhatsApp, it does so directly using a WebSocket.
|
||||
You don't have to use a mobile device to run this engine.
|
||||
|
||||
|
||||
### VENOM
|
||||
|
||||
- `WHATSAPP_DEFAULT_ENGINE=VENOM`
|
||||
@@ -96,7 +86,7 @@ Here, you will find a list of supported endpoints and webhooks per engine.
|
||||
If you don't specify `WHATSAPP_DEFAULT_ENGINE` environment variable - look at **WEBJS** engine,
|
||||
it's the engine WAHA runs by default.
|
||||
|
||||
### Engine
|
||||
### Protocols
|
||||
|
||||
| | WEBJS | NOWEB | VENOM |
|
||||
|--------------------------------------------------------------|:-----:|:-----:|:-----:|
|
||||
@@ -166,24 +156,26 @@ please [create an issue](https://github.com/devlikeapro/whatsapp-http-api/issues
|
||||
| `POST /api/contacts/block` | ✔️ | ➖ | ➖ |
|
||||
| `POST /api/contacts/unblock` | ✔️ | ➖ | ➖ |
|
||||
|
||||
| **Groups** | WEBJS | NOWEB | VENOM |
|
||||
|--------------------------------------------------------------------|:-----:|:-----:|:-----:|
|
||||
| `POST /api/{session}/groups` | ✔️ | ✔️ | ➖ |
|
||||
| `GET /api/{session}/groups` | ✔️ | ✔️ | ➖ |
|
||||
| `GET /api/{session}/groups/{id}` | ✔️ | ✔️ | ➖ |
|
||||
| `DELETE /api/{session}/groups/{id}` | ✔️ | ➖ | ➖ |
|
||||
| `GET /api/{session}/groups/{id}/settings/security/info-admin-only` | ✔️ | ➖ | ➖ |
|
||||
| `PUT /api/{session}/groups/{id}/settings/security/info-admin-only` | ✔️ | ➖ | ➖ |
|
||||
| `POST /api/{session}/groups/{id}/leave` | ✔️ | ✔️ | ➖ |
|
||||
| `PUT /api/{session}/groups/{id}/description` | ✔️ | ✔️ | ➖ |
|
||||
| `PUT /api/{session}/groups/{id}/subject` | ✔️ | ✔️ | ➖ |
|
||||
| `GET /api/{session}/groups/{id}/invite-code` | ✔️ | ✔️ | ➖ |
|
||||
| `POST /api/{session}/groups/{id}/invite-code/revoke` | ✔️ | ✔️ | ➖ |
|
||||
| `GET /api/{session}/groups/{id}/participants` | ✔️ | ✔️ | ➖ |
|
||||
| `POST /api/{session}/groups/{id}/participants/add` | ✔️ | ✔️ | ➖ |
|
||||
| `POST /api/{session}/groups/{id}/participants/remove` | ✔️ | ✔️ | ➖ |
|
||||
| `POST /api/{session}/groups/{id}/admin/promote` | ✔️ | ✔️ | ➖ |
|
||||
| `POST /api/{session}/groups/{id}/admin/demote` | ✔️ | ✔️ | ➖ |
|
||||
| **Groups** | WEBJS | NOWEB | VENOM |
|
||||
|------------------------------------------------------------------------|:-----:|:-----:|:-----:|
|
||||
| `POST /api/{session}/groups` | ✔️ | ✔️ | ➖ |
|
||||
| `GET /api/{session}/groups` | ✔️ | ✔️ | ➖ |
|
||||
| `GET /api/{session}/groups/{id}` | ✔️ | ✔️ | ➖ |
|
||||
| `DELETE /api/{session}/groups/{id}` | ✔️ | ➖ | ➖ |
|
||||
| `GET /api/{session}/groups/{id}/settings/security/info-admin-only` | ✔️ | ➖ | ➖ |
|
||||
| `PUT /api/{session}/groups/{id}/settings/security/info-admin-only` | ✔️ | ➖ | ➖ |
|
||||
| `GET /api/{session}/groups/{id}/settings/security/messages-admin-only` | ✔️ | ➖ | ➖ |
|
||||
| `PUT /api/{session}/groups/{id}/settings/security/messages-admin-only` | ✔️ | ➖ | ➖ |
|
||||
| `POST /api/{session}/groups/{id}/leave` | ✔️ | ✔️ | ➖ |
|
||||
| `PUT /api/{session}/groups/{id}/description` | ✔️ | ✔️ | ➖ |
|
||||
| `PUT /api/{session}/groups/{id}/subject` | ✔️ | ✔️ | ➖ |
|
||||
| `GET /api/{session}/groups/{id}/invite-code` | ✔️ | ✔️ | ➖ |
|
||||
| `POST /api/{session}/groups/{id}/invite-code/revoke` | ✔️ | ✔️ | ➖ |
|
||||
| `GET /api/{session}/groups/{id}/participants` | ✔️ | ✔️ | ➖ |
|
||||
| `POST /api/{session}/groups/{id}/participants/add` | ✔️ | ✔️ | ➖ |
|
||||
| `POST /api/{session}/groups/{id}/participants/remove` | ✔️ | ✔️ | ➖ |
|
||||
| `POST /api/{session}/groups/{id}/admin/promote` | ✔️ | ✔️ | ➖ |
|
||||
| `POST /api/{session}/groups/{id}/admin/demote` | ✔️ | ✔️ | ➖ |
|
||||
|
||||
| | WEBJS | NOWEB | VENOM |
|
||||
|---------------------------------------------------|:-----:|:-----:|:-----:|
|
||||
@@ -196,10 +188,13 @@ please [create an issue](https://github.com/devlikeapro/whatsapp-http-api/issues
|
||||
| `GET /api/version` | ➖ | ✔️ | ➖ |
|
||||
| `GET /health`  | ✔️ | ✔️ | ✔️ |
|
||||
|
||||
### Webhooks
|
||||
|
||||
| **Webhooks** | WEBJS | NOWEB | VENOM |
|
||||
|-----------------------------------------------------|:-----:|:-----:|:-----:|
|
||||
| `message` | ✔️ | ✔️ | ✔️ |
|
||||
| `message` with files  | ✔️ | ✔️ | ✔️ |
|
||||
| `message.reaction` | ✔️ | ✔️ | ➖ |
|
||||
| `message.any` | ✔️ | ✔️ | ✔️ |
|
||||
| `message.ack` | ✔️ | ✔️ | ✔️ |
|
||||
| `message.revoked` | ✔️ | ➖ | ➖ |
|
||||
|
||||
@@ -87,22 +87,47 @@ Request:
|
||||
}
|
||||
```
|
||||
|
||||
### Settings
|
||||
#### Security for group info
|
||||
### Security - update group info
|
||||
Updates the group settings to only allow admins to edit group info (title, description, photo).
|
||||
`PUT /api/{session}/groups/{groupId}/settings/security/info-admin-only`
|
||||
```json
|
||||
{
|
||||
"adminsOnly": true
|
||||
}
|
||||
```
|
||||
|
||||
Get the group settings to only allow admins to edit group info (title, description, photo).
|
||||
|
||||
`GET /api/{session}/groups/{groupId}/settings/security/info-admin-only`
|
||||
```json
|
||||
{
|
||||
"adminsOnly": true
|
||||
}
|
||||
```
|
||||
`PUT /api/{session}/groups/{groupId}/settings/security/info-admin-only`
|
||||
|
||||
The request doesn't require any request's body and
|
||||
**can't be used to disable the security setting (allow ANY to edit group info)**.
|
||||
If you wish to have that ability - please [create an issue](https://github.com/devlikeapro/whatsapp-http-api/issues)
|
||||
Returns `true` if the setting was properly updated. This can return false if the user does not have the necessary permissions.
|
||||
|
||||
|
||||
### Security - who can send messages
|
||||
Updates the group settings to only allow admins to send messages.
|
||||
|
||||
`PUT /api/{session}/groups/{groupId}/settings/security/messages-admin-only`
|
||||
```json
|
||||
{
|
||||
"adminsOnly": true
|
||||
}
|
||||
```
|
||||
Returns `true` if the setting was properly updated. This can return false if the user does not have the necessary permissions.
|
||||
|
||||
Get the group settings to only allow admins to send messages.
|
||||
|
||||
`GET /api/{session}/groups/{groupId}/settings/security/messages-admin-only`
|
||||
```json
|
||||
{
|
||||
"adminsOnly": true
|
||||
}
|
||||
```
|
||||
|
||||
### Participants
|
||||
|
||||
#### Get participants
|
||||
|
||||
@@ -226,6 +226,43 @@ Fired on all message creations, including your own. The payload is the same as f
|
||||
}
|
||||
```
|
||||
|
||||
### message.reaction
|
||||
Receive events when a message is reacted to by a user (or **yourself** reacting to a message).
|
||||
- `payload.reaction.text` - emoji that was used to react to the message. It'll be an empty string if the reaction was removed.
|
||||
- `payload.reaction.messageId` - id of the message that was reacted to.
|
||||
|
||||
```json
|
||||
{
|
||||
"event": "message.reaction",
|
||||
"session": "default",
|
||||
"me": {
|
||||
"id": "79222222222@c.us",
|
||||
"pushName": "WAHA"
|
||||
},
|
||||
"payload": {
|
||||
"id": "false_79111111@c.us_11111111111111111111111111111111",
|
||||
"from": "79111111@c.us",
|
||||
"fromMe": false,
|
||||
"participant": "79111111@c.us",
|
||||
"to": "79111111@c.us",
|
||||
"timestamp": 1710481111.853,
|
||||
"reaction": {
|
||||
"text": "🙏",
|
||||
"messageId": "true_79111111@c.us_11111111111111111111111111111111"
|
||||
}
|
||||
},
|
||||
"engine": "WEBJS",
|
||||
"environment": {
|
||||
"version": "2024.3.3",
|
||||
"engine": "WEBJS",
|
||||
"tier": "PLUS",
|
||||
"browser": "/usr/bin/google-chrome-stable"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
{{< alert icon="👉" text="NOWEB engine note - reactions were sent in 'message' and 'message.any' events, not it's available only in 'message.reaction'!" />}}
|
||||
|
||||
### message.ack
|
||||
Receive events when server or recipient gets the message, read or played it.
|
||||
|
||||
|
||||
@@ -19,6 +19,20 @@ If you wish to get and read Release Notes - read them on one of our platforms, *
|
||||
|
||||
You even can **subscribe to get new updates** there!
|
||||
|
||||
## 2024.3
|
||||
- Add [message.reaction]({{< relref "/docs/how-to/webhooks#messagereaction" >}}) webhook in **WEBJS** and **NOWEB** engines ([#275](https://github.com/devlikeapro/whatsapp-http-api/issues/275)).
|
||||
- **NOWEB** engine note - reactions were sent in `'message'` and `'message.any'` events, not it's available **only** in `'message.reaction'`!
|
||||
- Add security settings [Security - who can send messages]({{< relref "/docs/how-to/groups##security---who-can-send-messages" >}}) `PUT /api/{session}/groups/{groupId}/settings/security/messages-admin-only` ([#274](https://github.com/devlikeapro/whatsapp-http-api/issues/274))
|
||||
|
||||
### 👉 Breaking changes
|
||||
- **NOWEB** - reactions were sent in `'message'` and `'message.any'` events, not it's available **only** in `'message.reaction'`!
|
||||
- Add **required body** in `PUT /api/{session}/groups/{groupId}/settings/security/info-admin-only` endpoint.
|
||||
```json
|
||||
{
|
||||
"adminsOnly": false
|
||||
}
|
||||
```
|
||||
|
||||
## 2024.2
|
||||
- Add support for [MongoDB as storage for Session data]({{< relref "/docs/how-to/storages" >}})
|
||||
- Support persistent file storage for media files - [now you can save media files between container restarts]({{< relref "/docs/how-to/storages#media" >}})
|
||||
|
||||
@@ -9,11 +9,9 @@
|
||||
<img src='/images/logo.png' title='WhatsApp HTTP API' alt='logo' width='100' />
|
||||
</div>
|
||||
<p class='lead'>{{ .Params.lead | safeHTML }}</p>
|
||||
<code>
|
||||
docker run -it -p 3000:3000/tcp devlikeapro/whatsapp-http-api
|
||||
</code>
|
||||
<br />
|
||||
<br />
|
||||
<div class="code-block highlight d-none d-md-block">
|
||||
<pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash" style='padding: 0'>docker run -it -p 3000:3000/tcp devlikeapro/whatsapp-http-api</code></pre>
|
||||
</div>
|
||||
<a class='btn btn-primary btn-lg px-4 mb-2'
|
||||
href='/docs/{{ if .Site.Params.options.docsVersioning }}{{ .Site.Params.docsVersion }}/{{ end }}overview/introduction/'
|
||||
role='button'>Get Started</a>
|
||||
|
||||
@@ -11,6 +11,7 @@ import { ApiOperation, ApiSecurity, ApiTags } from '@nestjs/swagger';
|
||||
|
||||
import { SessionManager } from '../core/abc/manager.abc';
|
||||
import { WhatsappSession } from '../core/abc/session.abc';
|
||||
import { MessageContactVcardRequest } from '../structures/chatting.dto';
|
||||
import {
|
||||
CreateGroupRequest,
|
||||
DescriptionRequest,
|
||||
@@ -56,11 +57,12 @@ export class GroupsController {
|
||||
summary:
|
||||
'Updates the group settings to only allow admins to edit group info (title, description, photo).',
|
||||
})
|
||||
setGroupAdminOnly(
|
||||
setInfoAdminOnly(
|
||||
@SessionParam session: WhatsappSession,
|
||||
@Param('id') id: string,
|
||||
@Body() request: SettingsSecurityChangeInfo,
|
||||
) {
|
||||
return session.setInfoAdminsOnly(id, true);
|
||||
return session.setInfoAdminsOnly(id, request.adminsOnly);
|
||||
}
|
||||
|
||||
@Get(':id/settings/security/info-admin-only')
|
||||
@@ -76,6 +78,32 @@ export class GroupsController {
|
||||
return session.getInfoAdminsOnly(id);
|
||||
}
|
||||
|
||||
@Put(':id/settings/security/messages-admin-only')
|
||||
@SessionApiParam
|
||||
@ApiOperation({
|
||||
summary:
|
||||
'Updates the group settings to only allow admins to send messages.',
|
||||
})
|
||||
setMessagesAdminOnly(
|
||||
@SessionParam session: WhatsappSession,
|
||||
@Param('id') id: string,
|
||||
@Body() request: SettingsSecurityChangeInfo,
|
||||
) {
|
||||
return session.setMessagesAdminsOnly(id, request.adminsOnly);
|
||||
}
|
||||
|
||||
@Get(':id/settings/security/messages-admin-only')
|
||||
@SessionApiParam
|
||||
@ApiOperation({
|
||||
summary: 'Gets the group settings to only allow admins to send messages.',
|
||||
})
|
||||
getMessagesAdminOnly(
|
||||
@SessionParam session: WhatsappSession,
|
||||
@Param('id') id: string,
|
||||
): Promise<SettingsSecurityChangeInfo> {
|
||||
return session.getMessagesAdminsOnly(id);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
@SessionApiParam
|
||||
@ApiOperation({ summary: 'Delete the group.' })
|
||||
|
||||
@@ -338,6 +338,14 @@ export abstract class WhatsappSession {
|
||||
throw new NotImplementedByEngineError();
|
||||
}
|
||||
|
||||
public getMessagesAdminsOnly(id): Promise<SettingsSecurityChangeInfo> {
|
||||
throw new NotImplementedByEngineError();
|
||||
}
|
||||
|
||||
public setMessagesAdminsOnly(id, value) {
|
||||
throw new NotImplementedByEngineError();
|
||||
}
|
||||
|
||||
public deleteGroup(id) {
|
||||
throw new NotImplementedByEngineError();
|
||||
}
|
||||
|
||||
@@ -55,7 +55,10 @@ import {
|
||||
WAHAChatPresences,
|
||||
WAHAPresenceData,
|
||||
} from '../../../structures/presence.dto';
|
||||
import { WAMessage } from '../../../structures/responses.dto';
|
||||
import {
|
||||
WAMessage,
|
||||
WAMessageReaction,
|
||||
} from '../../../structures/responses.dto';
|
||||
import { MeInfo } from '../../../structures/sessions.dto';
|
||||
import { BROADCAST_ID, TextStatus } from '../../../structures/status.dto';
|
||||
import {
|
||||
@@ -133,7 +136,7 @@ export class WhatsappSessionNoWebCore extends WhatsappSession {
|
||||
keys: makeCacheableSignalKeyStore(state.keys, logger),
|
||||
},
|
||||
printQRInTerminal: true,
|
||||
browser: Browsers.macOS('Chrome'),
|
||||
browser: Browsers.ubuntu('Chrome'),
|
||||
logger: logger,
|
||||
mobile: false,
|
||||
defaultQueryTimeoutMs: undefined,
|
||||
@@ -585,6 +588,12 @@ export class WhatsappSessionNoWebCore extends WhatsappSession {
|
||||
this.handleIncomingMessages(messages, handler, false);
|
||||
});
|
||||
return true;
|
||||
case WAHAEvents.MESSAGE_REACTION:
|
||||
this.sock.ev.on(BaileysEvents.MESSAGES_UPSERT, ({ messages }) => {
|
||||
const reactions = this.processMessageReaction(messages);
|
||||
reactions.map(handler);
|
||||
});
|
||||
return true;
|
||||
case WAHAEvents.MESSAGE_ANY:
|
||||
this.sock.ev.on(BaileysEvents.MESSAGES_UPSERT, ({ messages }) =>
|
||||
this.handleIncomingMessages(messages, handler, true),
|
||||
@@ -641,6 +650,8 @@ export class WhatsappSessionNoWebCore extends WhatsappSession {
|
||||
// if there is no text or media message
|
||||
if (!message) return;
|
||||
if (!message.message) return;
|
||||
// Ignore reactions, we have dedicated handler for that
|
||||
if (message.message.reactionMessage) return;
|
||||
// Ignore poll votes, we have dedicated handler for that
|
||||
if (message.message.pollUpdateMessage) return;
|
||||
// Do not include my messages
|
||||
@@ -651,6 +662,34 @@ export class WhatsappSessionNoWebCore extends WhatsappSession {
|
||||
}
|
||||
}
|
||||
|
||||
private processMessageReaction(messages: any[]): WAMessageReaction[] {
|
||||
const reactions = [];
|
||||
for (const message of messages) {
|
||||
if (!message) return;
|
||||
if (!message.message) return;
|
||||
if (!message.message.reactionMessage) return;
|
||||
|
||||
const id = buildMessageId(message.key);
|
||||
const fromToParticipant = getFromToParticipant(message);
|
||||
const reactionMessage = message.message.reactionMessage;
|
||||
const messageId = buildMessageId(reactionMessage.key);
|
||||
const reaction: WAMessageReaction = {
|
||||
id: id,
|
||||
timestamp: message.messageTimestamp,
|
||||
from: toCusFormat(fromToParticipant.from),
|
||||
fromMe: message.key.fromMe,
|
||||
to: toCusFormat(fromToParticipant.to),
|
||||
participant: toCusFormat(fromToParticipant.participant),
|
||||
reaction: {
|
||||
text: reactionMessage.text,
|
||||
messageId: messageId,
|
||||
},
|
||||
};
|
||||
reactions.push(reaction);
|
||||
}
|
||||
return reactions;
|
||||
}
|
||||
|
||||
private processIncomingMessage(message) {
|
||||
return this.downloadMedia(message)
|
||||
.then(this.toWAMessage)
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
GroupChat,
|
||||
Location,
|
||||
Message,
|
||||
Reaction,
|
||||
} from 'whatsapp-web.js';
|
||||
import { Message as MessageInstance } from 'whatsapp-web.js/src/structures';
|
||||
|
||||
@@ -39,7 +40,10 @@ import {
|
||||
ParticipantsRequest,
|
||||
SettingsSecurityChangeInfo,
|
||||
} from '../../../structures/groups.dto';
|
||||
import { WAMessage } from '../../../structures/responses.dto';
|
||||
import {
|
||||
WAMessage,
|
||||
WAMessageReaction,
|
||||
} from '../../../structures/responses.dto';
|
||||
import { MeInfo } from '../../../structures/sessions.dto';
|
||||
import { WAMessageRevokedBody } from '../../../structures/webhooks.dto';
|
||||
import { IEngineMediaProcessor } from '../../abc/media.abc';
|
||||
@@ -377,6 +381,7 @@ export class WhatsappSessionWebJSCore extends WhatsappSession {
|
||||
public async getInfoAdminsOnly(id): Promise<SettingsSecurityChangeInfo> {
|
||||
const groupChat = (await this.whatsapp.getChatById(id)) as GroupChat;
|
||||
return {
|
||||
// Undocumented property, can be changed in the future
|
||||
// @ts-ignore
|
||||
adminsOnly: groupChat.groupMetadata.restrict,
|
||||
};
|
||||
@@ -387,6 +392,21 @@ export class WhatsappSessionWebJSCore extends WhatsappSession {
|
||||
return groupChat.setInfoAdminsOnly(value);
|
||||
}
|
||||
|
||||
public async getMessagesAdminsOnly(id): Promise<SettingsSecurityChangeInfo> {
|
||||
const groupChat = (await this.whatsapp.getChatById(id)) as GroupChat;
|
||||
// @ts-ignore
|
||||
return {
|
||||
// Undocumented property, can be changed in the future
|
||||
// @ts-ignore
|
||||
adminsOnly: groupChat.groupMetadata.announce,
|
||||
};
|
||||
}
|
||||
|
||||
public async setMessagesAdminsOnly(id, value) {
|
||||
const groupChat = (await this.whatsapp.getChatById(id)) as GroupChat;
|
||||
return groupChat.setMessagesAdminsOnly(value);
|
||||
}
|
||||
|
||||
public getGroups() {
|
||||
return this.whatsapp
|
||||
.getChats()
|
||||
@@ -520,6 +540,11 @@ export class WhatsappSessionWebJSCore extends WhatsappSession {
|
||||
},
|
||||
);
|
||||
return true;
|
||||
case WAHAEvents.MESSAGE_REACTION:
|
||||
this.whatsapp.on('message_reaction', (message) =>
|
||||
handler(this.processMessageReaction(message)),
|
||||
);
|
||||
return true;
|
||||
case WAHAEvents.MESSAGE_ANY:
|
||||
this.whatsapp.on(Events.MESSAGE_CREATE, (message) =>
|
||||
this.processIncomingMessage(message).then(handler),
|
||||
@@ -557,6 +582,21 @@ export class WhatsappSessionWebJSCore extends WhatsappSession {
|
||||
return await this.toWAMessage(message);
|
||||
}
|
||||
|
||||
private processMessageReaction(reaction: Reaction): WAMessageReaction {
|
||||
return {
|
||||
id: reaction.id._serialized,
|
||||
from: reaction.senderId,
|
||||
fromMe: reaction.id.fromMe,
|
||||
participant: reaction.senderId,
|
||||
to: reaction.id.remote,
|
||||
timestamp: reaction.timestamp,
|
||||
reaction: {
|
||||
text: reaction.reaction,
|
||||
messageId: reaction.msgId._serialized,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
protected toWAMessage(message: Message): Promise<WAMessage> {
|
||||
// @ts-ignore
|
||||
return Promise.resolve({
|
||||
|
||||
@@ -3,6 +3,7 @@ export const SECOND = 1000;
|
||||
export enum WAHAEvents {
|
||||
SESSION_STATUS = 'session.status',
|
||||
MESSAGE = 'message',
|
||||
MESSAGE_REACTION = 'message.reaction',
|
||||
MESSAGE_ANY = 'message.any',
|
||||
MESSAGE_ACK = 'message.ack',
|
||||
MESSAGE_REVOKED = 'message.revoked',
|
||||
|
||||
@@ -9,7 +9,7 @@ export class Participant {
|
||||
}
|
||||
|
||||
export class SettingsSecurityChangeInfo {
|
||||
adminsOnly: boolean;
|
||||
adminsOnly: boolean = true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,7 +30,7 @@ export class WAMedia {
|
||||
filename?: string;
|
||||
}
|
||||
|
||||
export class WAMessage {
|
||||
class WAMessageBase {
|
||||
@MessageIdProperty()
|
||||
id: string;
|
||||
|
||||
@@ -65,7 +65,9 @@ export class WAMessage {
|
||||
description: 'For groups - participant who sent the message',
|
||||
})
|
||||
participant: string;
|
||||
}
|
||||
|
||||
export class WAMessage extends WAMessageBase {
|
||||
@ApiProperty({
|
||||
description: 'Message content',
|
||||
})
|
||||
@@ -121,3 +123,25 @@ export class WAMessage {
|
||||
})
|
||||
_data?: any;
|
||||
}
|
||||
|
||||
export class WAReaction {
|
||||
@ApiProperty({
|
||||
description:
|
||||
'Reaction to the message. Either the reaction (emoji) or empty string to remove the reaction',
|
||||
})
|
||||
text: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Message ID for the message to react to',
|
||||
example: 'false_11111111111@c.us_AAAAAAAAAAAAAAAAAAAA',
|
||||
})
|
||||
messageId: string;
|
||||
}
|
||||
|
||||
export class WAMessageReaction extends WAMessageBase {
|
||||
@ApiProperty({
|
||||
description:
|
||||
'Reaction to the message. Either the reaction (emoji) or empty string to remove the reaction',
|
||||
})
|
||||
reaction: WAReaction;
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
import { WAHAEnvironment } from './environment.dto';
|
||||
import { WAHAChatPresences } from './presence.dto';
|
||||
import { ChatIdProperty, MessageIdProperty } from './properties.dto';
|
||||
import { WAMessage } from './responses.dto';
|
||||
import { WAMessage, WAMessageReaction } from './responses.dto';
|
||||
import { MeInfo } from './sessions.dto';
|
||||
|
||||
export class WAMessageAckBody {
|
||||
@@ -134,6 +134,16 @@ class WAHAWebhookMessage extends WAHAWebhook {
|
||||
payload: WAMessage;
|
||||
}
|
||||
|
||||
class WAHAWebhookMessageReaction extends WAHAWebhook {
|
||||
@ApiProperty({
|
||||
description:
|
||||
'The event is triggered when a user reacts or removes a reaction.',
|
||||
})
|
||||
event = WAHAEvents.MESSAGE_REACTION;
|
||||
|
||||
payload: WAMessageReaction;
|
||||
}
|
||||
|
||||
class WAHAWebhookMessageAny extends WAHAWebhook {
|
||||
@ApiProperty({
|
||||
description: 'Fired on all message creations, including your own.',
|
||||
@@ -223,6 +233,7 @@ class WAHAWebhookPollVoteFailed extends WAHAWebhook {
|
||||
const WAHA_WEBHOOKS = [
|
||||
WAHAWebhookSessionStatus,
|
||||
WAHAWebhookMessage,
|
||||
WAHAWebhookMessageReaction,
|
||||
WAHAWebhookMessageAny,
|
||||
WAHAWebhookMessageAck,
|
||||
WAHAWebhookMessageRevoked,
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ export function getEngineName(): string {
|
||||
}
|
||||
|
||||
export const VERSION: WAHAEnvironment = {
|
||||
version: '2024.3.1',
|
||||
version: '2024.3.6',
|
||||
engine: getEngineName(),
|
||||
tier: getWAHAVersion(),
|
||||
browser: getBrowserExecutablePath(),
|
||||
|
||||
@@ -1300,10 +1300,10 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@pedroslopez/moduleraid@npm:^5.0.2":
|
||||
version: 5.0.2
|
||||
resolution: "@pedroslopez/moduleraid@npm:5.0.2"
|
||||
checksum: b5668cb8d602e3fae0bcd75172f53b301814582ec288f4413127377a8be007aafc63846855431b6096a70dc9f113b059f6286bbc254f3bdbec435ba517dae36f
|
||||
"@pedroslopez/moduleraid@github:wwebjs/moduleRaid":
|
||||
version: 6.0.2
|
||||
resolution: "@pedroslopez/moduleraid@https://github.com/wwebjs/moduleRaid.git#commit=2ba8baadbc2a73305775ca72325102ed2c629f89"
|
||||
checksum: 399d08f1bc7703f73f7ec5e80618139f6ed4a95cd05baa87a9c6c69d8cd0fbd299e1c757414fed2e160c9ec6dfb0f4b8e5fc08261b97bfb7f248dc16c28e9f83
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@@ -13349,9 +13349,9 @@ __metadata:
|
||||
|
||||
"whatsapp-web.js@https://github.com/devlikeapro/whatsapp-web.js#main-fork":
|
||||
version: 1.23.1-alpha.5
|
||||
resolution: "whatsapp-web.js@https://github.com/devlikeapro/whatsapp-web.js.git#commit=9587dc75e22e30bceb87e0cde4bd46ea7674d0d4"
|
||||
resolution: "whatsapp-web.js@https://github.com/devlikeapro/whatsapp-web.js.git#commit=1f9c956cd13cc75c211d14e82cf9b5fd665f9b03"
|
||||
dependencies:
|
||||
"@pedroslopez/moduleraid": ^5.0.2
|
||||
"@pedroslopez/moduleraid": "github:wwebjs/moduleRaid"
|
||||
adm-zip: ^0.5.10
|
||||
archiver: ^5.3.1
|
||||
fluent-ffmpeg: 2.1.2
|
||||
@@ -13368,7 +13368,7 @@ __metadata:
|
||||
optional: true
|
||||
unzipper:
|
||||
optional: true
|
||||
checksum: 9be4cefbf1c3eea3e7dbdaf681cd6588665e18a536b455b562fd5155d011e46039f646e87d76e434107d7e0de61c6a3772b07da62dc4b449043f59bbc011f32a
|
||||
checksum: 03894e8cf847876aac6a543aada3cccce2010069231fb2165d5895598a32f883d5269f5593afa0b369b2bb93a9399a5214d582b3a37b6cf5bda804edf07912d0
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
|
||||
Reference in new issue
Block a user