Skip to content

Commit

Permalink
feat: Added SendImageStorie and sendTextStorie
Browse files Browse the repository at this point in the history
  • Loading branch information
icleitoncosta committed Jul 19, 2022
1 parent 8df9499 commit 2f388f0
Show file tree
Hide file tree
Showing 3 changed files with 6,953 additions and 7,105 deletions.
16 changes: 4 additions & 12 deletions src/controller/messageController.js
Expand Up @@ -265,7 +265,7 @@ export async function sendMentioned(req, res) {
}

export async function sendTextStorie(req, res) {
const { text } = req.body;
const { text, options } = req.body;

if (!text)
return res.status(401).send({
Expand All @@ -274,7 +274,7 @@ export async function sendTextStorie(req, res) {

try {
let results = [];
results.push(await req.client.sendText('status@broadcast', text));
results.push(await req.client.sendTextStatus(text, options));

if (results.length === 0) return res.status(400).json('Error sending the text of stories');
returnSucess(res, results);
Expand All @@ -284,21 +284,13 @@ export async function sendTextStorie(req, res) {
}

export async function sendImageStorie(req, res) {
const { path, filename = 'image-storie', caption } = req.body;

if (!path && !req.file)
return res.status(401).send({
message: 'Sending the image is mandatory',
});

const pathFile = path || req.file.path;
const { path, options } = req.body;

try {
let results = [];
results.push(await req.client.sendImage('status@broadcast', pathFile, filename, caption));
results.push(await req.client.sendImageStatus(path, options));

if (results.length === 0) return res.status(400).json('Error sending the image of stories');
if (req.file) await unlinkAsync(pathFile);
returnSucess(res, results);
} catch (error) {
returnError(req, res, error);
Expand Down
253 changes: 253 additions & 0 deletions src/swagger.json
Expand Up @@ -6458,6 +6458,229 @@
"deprecated": false
}
},
"/send-image-storie": {
"post": {
"tags": ["Profile"],
"summary": "Send Image Storie ",
"description": "Send Image Storie",
"operationId": "SendImageStorie",
"parameters": [],
"requestBody": {
"description": "",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/SendImageStorieRequest"
},
"example": {
"path": "https://pbs.twimg.com/profile_images/549882655932948480/LCZWmFyW_400x400.jpeg"
}
}
},
"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": "20"
}
}
},
"ETag": {
"content": {
"text/plain": {
"schema": {
"type": "string"
},
"example": "W/\"14-Aecwmfr5xTp+PReMihhLNM3Z9mY\""
}
}
},
"Date": {
"content": {
"text/plain": {
"schema": {
"type": "string"
},
"example": "Thu, 13 May 2021 18:12:58 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/ChangeProfileStatus"
},
"example": {
"status": "Success"
}
}
}
}
},
"deprecated": false
}
},
"/send-text-storie": {
"post": {
"tags": ["Profile"],
"summary": "Send Text Storie ",
"description": "Send Text Storie",
"operationId": "SendTextStorie",
"parameters": [],
"requestBody": {
"description": "",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/SendTextStorieRequest"
},
"example": {
"text": "https://pbs.twimg.com/profile_images/549882655932948480/LCZWmFyW_400x400.jpeg",
"options": { "backgroundColor": "#0275d8", "font": 2 }
}
}
},
"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": "20"
}
}
},
"ETag": {
"content": {
"text/plain": {
"schema": {
"type": "string"
},
"example": "W/\"14-Aecwmfr5xTp+PReMihhLNM3Z9mY\""
}
}
},
"Date": {
"content": {
"text/plain": {
"schema": {
"type": "string"
},
"example": "Thu, 13 May 2021 18:12:58 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/ChangeProfileStatus"
},
"example": {
"status": "Success"
}
}
}
}
},
"deprecated": false
}
},
"/subscribe-presence": {
"post": {
"tags": ["Contact"],
Expand Down Expand Up @@ -16836,6 +17059,36 @@
"status": "My new status"
}
},
"SendImageStorieRequest": {
"title": "SendImageStorieRequest",
"required": ["path"],
"type": "object",
"properties": {
"path": {
"type": "string"
}
},
"example": {
"path": "https://pbs.twimg.com/profile_images/549882655932948480/LCZWmFyW_400x400.jpeg"
}
},
"SendTextStorieRequest": {
"title": "SendTextStorieRequest",
"required": ["text", "options"],
"type": "object",
"properties": {
"text": {
"type": "string"
},
"options": {
"type": "string"
}
},
"example": {
"text": "https://pbs.twimg.com/profile_images/549882655932948480/LCZWmFyW_400x400.jpeg",
"options": { "backgroundColor": "#0275d8", "font": 2 }
}
},
"SubscribePresenceRequest": {
"title": "SubscribePresenceRequest",
"required": ["phone"],
Expand Down

0 comments on commit 2f388f0

Please sign in to comment.