Skip to content

Commit

Permalink
feat: Added archive-all-chats-router
Browse files Browse the repository at this point in the history
  • Loading branch information
icleitoncosta committed Jul 12, 2022
1 parent 70909e5 commit 8c7d6fa
Show file tree
Hide file tree
Showing 2 changed files with 130 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/controller/deviceController.js
Expand Up @@ -262,6 +262,19 @@ export async function archiveChat(req, res) {
}
}

export async function archiveAllChats(req, res) {
try {
const chats = await req.client.getAllChats();
for (const chat of chats) {
await req.client.archiveChat(`${chat.chatId}`, true);
}
return res.status(201).json({ status: 'success' });
} catch (e) {
req.logger.error(e);
return res.status(500).json({ status: 'error', message: 'Error on archive all chats' });
}
}

export async function deleteMessage(req, res) {
const { phone, messageId } = req.body;

Expand Down
117 changes: 117 additions & 0 deletions src/swagger.json
Expand Up @@ -3619,6 +3619,116 @@
"deprecated": false
}
},

"/archive-all-chats": {
"post": {
"tags": ["Chat"],
"summary": "Archive all chats",
"description": "Archive all chats in device",
"operationId": "archiveAllChats",
"parameters": [],
"requestBody": {
"description": "",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/archiveAllChatsRequest"
},
"example": {}
}
},
"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": "36"
}
}
},
"ETag": {
"content": {
"text/plain": {
"schema": {
"type": "string"
},
"example": "W/\"24-Xm9Fmv/piJ8aftrp5VK0tqiuuAc\""
}
}
},
"Date": {
"content": {
"text/plain": {
"schema": {
"type": "string"
},
"example": "Fri, 14 May 2021 13:37: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/archiveAllChatsRequest"
},
"example": {
"status": "success"
}
}
}
}
},
"deprecated": false
}
},
"/clear-chat": {
"post": {
"tags": ["Chat"],
Expand Down Expand Up @@ -15401,6 +15511,13 @@
"callId": "89898ADSd5456SD5656DSADSAD322"
}
},
"archiveAllChatsRequest": {
"title": "archiveAllChatsRequest",
"required": [""],
"type": "object",
"properties": {},
"example": {}
},
"SendFileRequest": {
"title": "SendFileRequest",
"required": ["phone", "base64", "isGroup"],
Expand Down

0 comments on commit 8c7d6fa

Please sign in to comment.