Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions src/controllers/clientController.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,16 @@ const getContacts = async (req, res) => {
* @throws {Error} If the operation fails, an error is thrown.
*/
const getChats = async (req, res) => {
/*
#swagger.summary = 'Get all current chats'
/* #swagger.summary = 'Get all current chats'
#swagger.description = 'Retrieve all chats for the given session ID.'
#swagger.responses[200] = {
description: 'Retrieved all chats.',
content: {
'application/json': {
schema: { "$ref": "#/definitions/GetChatsResponse" }
}
}
}
*/
try {
const client = sessions.get(req.params.sessionId)
Expand Down Expand Up @@ -377,6 +385,7 @@ const getChats = async (req, res) => {
const getChatsWithSearch = async (req, res) => {
/*
#swagger.summary = 'Get all current chats with optional search parameters'
#swagger.description = 'Retrieve all chats for the given session ID with optional search parameters.'
#swagger.requestBody = {
required: true,
schema: {
Expand All @@ -399,6 +408,14 @@ const getChatsWithSearch = async (req, res) => {
}
},
}
#swagger.responses[200] = {
description: 'Retrieved all chats with search parameters.',
content: {
'application/json': {
schema: {"$ref": "#/definitions/GetChatsResponse"}
}
}
}
*/
try {
const { searchOptions = {} } = req.body
Expand Down
22 changes: 22 additions & 0 deletions swagger.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,28 @@ const doc = {
GetSessionsResponse: {
success: true,
result: ['session1', 'session2']
},
ChatId: {
server: 'c.us | g.us',
user: '1234567890',
_serialized: '1234567890@c.us',
},
Chat: {
id: { $ref: '#/definitions/ChatId' },
name: 'John Doe',
isGroup: false,
unreadCount: 0,
timestamp: 1770140061,
archived: false,
pinned: false,
isMuted: false,
muteExpiration: 0,
// Add other chat properties as needed after create definitions
},
GetChatsResponse: {
success: true,
chats: [ { $ref: '#/definitions/Chat' } ],
error: 'error message if any',
}
}
}
Expand Down
113 changes: 109 additions & 4 deletions swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1541,7 +1541,7 @@
"Client"
],
"summary": "Get all current chats",
"description": "",
"description": "Retrieve all chats for the given session ID.",
"parameters": [
{
"name": "sessionId",
Expand All @@ -1556,7 +1556,14 @@
],
"responses": {
"200": {
"description": "OK"
"description": "Retrieved all chats.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/GetChatsResponse"
}
}
}
},
"403": {
"description": "Forbidden.",
Expand Down Expand Up @@ -1610,7 +1617,7 @@
"Client"
],
"summary": "Get all current chats with optional search parameters",
"description": "",
"description": "Retrieve all chats for the given session ID with optional search parameters.",
"parameters": [
{
"name": "sessionId",
Expand All @@ -1625,7 +1632,14 @@
],
"responses": {
"200": {
"description": "OK"
"description": "Retrieved all chats with search parameters.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/GetChatsResponse"
}
}
}
},
"403": {
"description": "Forbidden.",
Expand Down Expand Up @@ -15071,6 +15085,97 @@
"xml": {
"name": "GetSessionsResponse"
}
},
"ChatId": {
"type": "object",
"properties": {
"server": {
"type": "string",
"example": "c.us | g.us"
},
"user": {
"type": "string",
"example": "1234567890"
},
"_serialized": {
"type": "string",
"example": "1234567890@c.us"
}
},
"xml": {
"name": "ChatId"
}
},
"Chat": {
"type": "object",
"properties": {
"id": {
"xml": {
"name": "chatid"
},
"$ref": "#/components/schemas/ChatId"
},
"name": {
"type": "string",
"example": "John Doe"
},
"isGroup": {
"type": "boolean",
"example": false
},
"unreadCount": {
"type": "number",
"example": 0
},
"timestamp": {
"type": "number",
"example": 1770140061
},
"archived": {
"type": "boolean",
"example": false
},
"pinned": {
"type": "boolean",
"example": false
},
"isMuted": {
"type": "boolean",
"example": false
},
"muteExpiration": {
"type": "number",
"example": 0
}
},
"xml": {
"name": "Chat"
}
},
"GetChatsResponse": {
"type": "object",
"properties": {
"success": {
"type": "boolean",
"example": true
},
"chats": {
"type": "array",
"items": {
"xml": {
"name": "chat"
},
"$ref": "#/components/schemas/Chat"
}
},
"error": {
"type": "string",
"example": "error message if any"
}
},
"xml": {
"name": "GetChatsResponse"
}
}
},
"securitySchemes": {
Expand Down