Skip to content

Commit

Permalink
feat: Send Reaction to Message
Browse files Browse the repository at this point in the history
  • Loading branch information
icleitoncosta committed Jul 19, 2022
1 parent 86208a5 commit 00af818
Show file tree
Hide file tree
Showing 3 changed files with 160 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/controller/deviceController.js
Expand Up @@ -301,6 +301,18 @@ export async function deleteMessage(req, res) {
return res.status(500).json({ status: 'error', message: 'Error on delete message' });
}
}
export async function reactMessage(req, res) {
const { msgId, reaction } = req.body;

try {
await req.client.sendReactionToMessage(msgId, reaction);

return res.status(200).json({ status: 'success', response: { message: 'Reaction sended' } });
} catch (e) {
req.logger.error(e);
return res.status(500).json({ status: 'error', message: 'Error on send reaction to message' });
}
}

export async function reply(req, res) {
const { phone, text, messageid } = req.body;
Expand Down
1 change: 1 addition & 0 deletions src/routes/index.js
Expand Up @@ -182,6 +182,7 @@ routes.post('/api/:session/clear-chat', verifyToken, statusConnection, DeviceCon
routes.post('/api/:session/delete-chat', verifyToken, statusConnection, DeviceController.deleteChat);
routes.post('/api/:session/delete-all-chats', verifyToken, statusConnection, DeviceController.deleteAllChats);
routes.post('/api/:session/delete-message', verifyToken, statusConnection, DeviceController.deleteMessage);
routes.post('/api/:session/react-message', verifyToken, statusConnection, DeviceController.reactMessage);
routes.post('/api/:session/forward-messages', verifyToken, statusConnection, DeviceController.forwardMessages);
routes.post('/api/:session/mark-unseen', verifyToken, statusConnection, DeviceController.markUnseenMessage);
routes.post('/api/:session/pin-chat', verifyToken, statusConnection, DeviceController.pinChat);
Expand Down
147 changes: 147 additions & 0 deletions src/swagger.json
Expand Up @@ -4177,6 +4177,119 @@
"deprecated": false
}
},
"/react-message": {
"post": {
"tags": ["Chat"],
"summary": "React Message",
"description": "React Message with Emoji",
"operationId": "ReactMessage",
"parameters": [],
"requestBody": {
"description": "",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ReactMessageRequest"
},
"example": {
"msgId": "false_556593077171@c.us_1B69CFDC0BDBAB37B2B628D90CBA0F47",
"reaction": "🤯"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "OK",
"headers": {
"X-Powered-By": {
"content": {
"text/plain": {
"schema": {
"type": "string"
},
"example": "Express"
}
}
},
"Access-Control-Allow-Origin": {
"content": {
"text/plain": {
"schema": {
"type": "string"
},
"example": "*"
}
}
},
"Content-Length": {
"content": {
"text/plain": {
"schema": {
"type": "string"
},
"example": "48"
}
}
},
"ETag": {
"content": {
"text/plain": {
"schema": {
"type": "string"
},
"example": "W/\"30-qy+RPELj2ZbNf7LuA11j8OW31yc\""
}
}
},
"Date": {
"content": {
"text/plain": {
"schema": {
"type": "string"
},
"example": "Thu, 13 May 2021 19:35:24 GMT"
}
}
},
"Connection": {
"content": {
"text/plain": {
"schema": {
"type": "string"
},
"example": "keep-alive"
}
}
},
"Keep-Alive": {
"content": {
"text/plain": {
"schema": {
"type": "string"
},
"example": "timeout=5"
}
}
}
},
"content": {
"application/json; charset=utf-8": {
"schema": {
"$ref": "#/components/schemas/ReactMessage"
},
"example": {
"status": "Success",
"message": "Reação enviada"
}
}
}
}
},
"deprecated": false
}
},
"/mark-unseen": {
"post": {
"tags": ["Chat"],
Expand Down Expand Up @@ -15486,6 +15599,40 @@
"message": "Message deleted"
}
},
"ReactMessageRequest": {
"title": "ReactMessageRequest",
"required": ["msgId", "reaction"],
"type": "object",
"properties": {
"msgId": {
"type": "string"
},
"reaction": {
"type": "string"
}
},
"example": {
"phone": "false_556593077171@c.us_1B69CFDC0BDBAB37B2B628D90CBA0F47",
"messageId": "🤯"
}
},
"ReactMessage": {
"title": "ReactMessage",
"required": ["status", "message"],
"type": "object",
"properties": {
"status": {
"type": "string"
},
"message": {
"type": "string"
}
},
"example": {
"status": "Success",
"message": "Reação enviada"
}
},
"MarkUnseenRequest": {
"title": "MarkUnseenRequest",
"required": ["phone"],
Expand Down

0 comments on commit 00af818

Please sign in to comment.