Skip to content

Commit

Permalink
feat: Added router to set recording
Browse files Browse the repository at this point in the history
  • Loading branch information
icleitoncosta committed Jul 21, 2022
1 parent b9d13ca commit e49671e
Show file tree
Hide file tree
Showing 3 changed files with 154 additions and 2 deletions.
16 changes: 16 additions & 0 deletions src/controller/deviceController.js
Expand Up @@ -578,6 +578,22 @@ export async function setTyping(req, res) {
}
}

export async function setRecording(req, res) {
const { phone, value = true, duration, isGroup = false } = req.body;
try {
let response;
for (const contato of contactToArray(phone, isGroup)) {
if (value) response = await req.client.startRecording(contato, duration);
else response = await req.client.stopRecoring(contato);
}

return res.status(200).json({ status: 'success', response: response });
} catch (error) {
req.logger.error(error);
return res.status(500).json({ status: 'error', message: 'Error on set recording' });
}
}

export async function checkNumberStatus(req, res) {
const { phone } = req.params;
try {
Expand Down
1 change: 1 addition & 0 deletions src/routes/index.js
Expand Up @@ -194,6 +194,7 @@ routes.post('/api/:session/send-seen', verifyToken, statusConnection, DeviceCont
routes.post('/api/:session/chat-state', verifyToken, statusConnection, DeviceController.setChatState);
routes.post('/api/:session/temporary-messages', verifyToken, statusConnection, DeviceController.setTemporaryMessages);
routes.post('/api/:session/typing', verifyToken, statusConnection, DeviceController.setTyping);
routes.post('/api/:session/recording', verifyToken, statusConnection, DeviceController.setRecording);
routes.post('/api/:session/star-message', verifyToken, statusConnection, DeviceController.starMessage);
routes.post('/api/:session/reject-call', verifyToken, statusConnection, DeviceController.rejectCall);

Expand Down
139 changes: 137 additions & 2 deletions src/swagger.json
Expand Up @@ -5059,6 +5059,120 @@
"deprecated": false
}
},
"/recording": {
"post": {
"tags": ["Chat"],
"summary": "Set Recording",
"description": "Start and Stop Recording, passe valeu true os false",
"operationId": "SetRecording",
"parameters": [],
"requestBody": {
"description": "",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/SetRecordingRequest"
},
"example": {
"phone": "556593077171",
"value": true,
"isGroup": false
}
}
},
"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/TemporaryMessages"
},
"example": {
"status": "success",
"response": true
}
}
}
}
},
"deprecated": false
}
},

"/reject-call": {
"post": {
Expand Down Expand Up @@ -16749,7 +16863,28 @@
},
"SetTypingRequest": {
"title": "SetTypingRequest",
"required": ["phone", "value", "isGrup"],
"required": ["phone", "value", "isGroup"],
"type": "object",
"properties": {
"phone": {
"type": "string"
},
"value": {
"type": "boolean"
},
"isGrup": {
"type": "boolean"
}
},
"example": {
"phone": "556593077171",
"value": true,
"isGroup": false
}
},
"SetRecordingRequest": {
"title": "SetRecordingRequest",
"required": ["phone", "value", "isGroup"],
"type": "object",
"properties": {
"phone": {
Expand All @@ -16765,7 +16900,7 @@
"example": {
"phone": "556593077171",
"value": true,
"isGrup": false
"isGroup": false
}
},
"rejectCallRequest": {
Expand Down

0 comments on commit e49671e

Please sign in to comment.