Skip to content

Commit

Permalink
Merge pull request ookamiiixd#3 from RocketsLab/group-functions
Browse files Browse the repository at this point in the history
Updates group resources
  • Loading branch information
tiagoandrepro authored Nov 3, 2021
2 parents 1a15ea0 + 8c8b9b1 commit eef4371
Show file tree
Hide file tree
Showing 7 changed files with 214 additions and 86 deletions.
118 changes: 92 additions & 26 deletions baileys-api.json → postman-api.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"info": {
"_postman_id": "4e47ac1f-23ee-4d64-8bc8-ea84762913f2",
"name": "New Collection",
"name": "WhatsApp Api Baileys",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
Expand All @@ -15,7 +15,7 @@
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"session\": \"instance-one\"\n}",
"raw": "{\n \"session\": \"{{instance}}\"\n}",
"options": {
"raw": {
"language": "json"
Expand Down Expand Up @@ -52,7 +52,7 @@
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"session\": \"instance-one\"\n}",
"raw": "{\n \"session\": \"{{instance}}\"\n}",
"options": {
"raw": {
"language": "json"
Expand Down Expand Up @@ -85,7 +85,7 @@
"header": [],
"body": {
"mode": "raw",
"raw": "{ \n \"sender\": \"instance-one\",\n \"name\" : \"group-test\",\n \"members\" : \"5511900000000\"\n}",
"raw": "{ \n \"session\": \"{{instance}}\",\n \"name\" : \"group-test\",\n \"members\" : \"5511900000000\"\n}",
"options": {
"raw": {
"language": "json"
Expand All @@ -109,11 +109,11 @@
{
"name": "Update Description",
"request": {
"method": "PATCH",
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{ \n \"sender\": \"instance-one\",\n \"groupId\" : \"[email protected]\",\n \"description\" : \"Nova Descrição do Grupo\"\n}",
"raw": "{ \n \"session\": \"{{instance}}\",\n \"groupId\" : \"[email protected]\",\n \"description\" : \"Nova Descrição do Grupo\"\n}",
"options": {
"raw": {
"language": "json"
Expand All @@ -137,11 +137,11 @@
{
"name": "Update Name",
"request": {
"method": "PATCH",
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{ \n \"sender\": \"instance-one\",\n \"groupId\" : \"[email protected]\",\n \"name\" : \"Test 001\"\n}",
"raw": "{ \n \"session\": \"{{instance}}\",\n \"groupId\" : \"[email protected]\",\n \"name\" : \"Test 001\"\n}",
"options": {
"raw": {
"language": "json"
Expand Down Expand Up @@ -169,7 +169,7 @@
"header": [],
"body": {
"mode": "raw",
"raw": "{ \n \"sender\": \"instance-one\",\n \"groupId\" : \"[email protected]\",\n \"members\" : \"55119000000\"\n}",
"raw": "{ \n \"session\": \"{{instance}}\",\n \"groupId\" : \"[email protected]\",\n \"members\" : \"55119000000\"\n}",
"options": {
"raw": {
"language": "json"
Expand Down Expand Up @@ -197,7 +197,7 @@
"header": [],
"body": {
"mode": "raw",
"raw": "{ \n \"sender\": \"instance-one\",\n \"groupId\" : \"[email protected]\",\n \"members\" : \"55119000000\"\n}",
"raw": "{ \n \"session\": \"{{instance}}\",\n \"groupId\" : \"[email protected]\",\n \"members\" : \"55119000000\"\n}",
"options": {
"raw": {
"language": "json"
Expand Down Expand Up @@ -225,7 +225,7 @@
"header": [],
"body": {
"mode": "raw",
"raw": "{ \n \"sender\": \"instance-one\",\n \"groupId\" : \"[email protected]\",\n \"members\" : \"551190000000\"\n}",
"raw": "{ \n \"session\": \"{{instance}}\",\n \"groupId\" : \"[email protected]\",\n \"members\" : \"551190000000\"\n}",
"options": {
"raw": {
"language": "json"
Expand All @@ -248,24 +248,30 @@
},
{
"name": "All Groups",
"protocolProfileBehavior": {
"disableBodyPruning": true
},
"request": {
"method": "GET",
"header": [],
"body": {
"mode": "raw",
"raw": "{ \n \"session\": \"{{instance}}\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{host}}:{{port}}/groups/get?session=instance-one",
"raw": "{{host}}:{{port}}/groups/all-groups",
"host": [
"{{host}}"
],
"port": "{{port}}",
"path": [
"groups",
"get"
],
"query": [
{
"key": "session",
"value": "instance-one"
}
"all-groups"
]
}
},
Expand All @@ -281,7 +287,7 @@
"header": [],
"body": {
"mode": "raw",
"raw": "{ \n \"sender\": \"instance-one\",\n \"groupId\" : \"[email protected]\"\n}",
"raw": "{ \n \"session\": \"{{instance}}\",\n \"groupId\" : \"[email protected]\"\n}",
"options": {
"raw": {
"language": "json"
Expand Down Expand Up @@ -312,7 +318,7 @@
"header": [],
"body": {
"mode": "raw",
"raw": "{ \n \"sender\": \"instance-one\",\n \"groupId\" : \"[email protected]\"\n}",
"raw": "{ \n \"session\": \"{{instance}}\",\n \"groupId\" : \"[email protected]\"\n}",
"options": {
"raw": {
"language": "json"
Expand Down Expand Up @@ -340,7 +346,7 @@
"header": [],
"body": {
"mode": "raw",
"raw": "{ \n \"sender\": \"instance-one\",\n \"groupId\" : \"[email protected]\"\n}",
"raw": "{ \n \"session\": \"{{instance}}\",\n \"groupId\" : \"[email protected]\"\n}",
"options": {
"raw": {
"language": "json"
Expand All @@ -364,11 +370,11 @@
{
"name": "Setting Message",
"request": {
"method": "PATCH",
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{ \n \"sender\": \"instance-one\",\n \"groupId\" : \"[email protected]\",\n \"value\" : true\n}",
"raw": "{ \n \"session\": \"{{instance}}\",\n \"groupId\" : \"[email protected]\",\n \"value\" : true\n}",
"options": {
"raw": {
"language": "json"
Expand All @@ -392,11 +398,11 @@
{
"name": "Setting Change",
"request": {
"method": "PATCH",
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{ \n \"sender\": \"instance-one\",\n \"groupId\" : \"[email protected]\",\n \"value\" : true\n}",
"raw": "{ \n \"session\": \"{{instance}}\",\n \"groupId\" : \"[email protected]\",\n \"value\" : true\n}",
"options": {
"raw": {
"language": "json"
Expand All @@ -416,6 +422,62 @@
}
},
"response": []
},
{
"name": "Accept Invite",
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{ \n \"session\": \"{{instance}}\",\n \"code\" : \"It8GoNNgWW9LfwtR8nuyru\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{host}}:{{port}}/groups/group-accept-invite",
"host": [
"{{host}}"
],
"port": "{{port}}",
"path": [
"groups",
"group-accept-invite"
]
}
},
"response": []
},
{
"name": "Revoke Invite",
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{ \n \"session\": \"{{instance}}\",\n \"groupId\" : \"[email protected]\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{host}}:{{port}}/groups/group-revoke-invite",
"host": [
"{{host}}"
],
"port": "{{port}}",
"path": [
"groups",
"group-revoke-invite"
]
}
},
"response": []
}
]
}
Expand Down Expand Up @@ -448,6 +510,10 @@
{
"key": "port",
"value": "8000"
},
{
"key": "instance",
"value": "default"
}
]
}
4 changes: 2 additions & 2 deletions src/controllers/chatsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const getChats = (req, res) => {
const errors = validationResult(req)
if(!errors.isEmpty()) return response(res, 400, {success: false, message: 'Please fill out all required inputs.'})

const session = whatsapp.getSession(req.query.session)
const session = whatsapp.getSession(req.body.session)
if(!session) return response(res, 404, {success: false, message: 'The requested session cannot be found.'})

response(res, 200, {success: true, data: whatsapp.getChats(session, 'single')})
Expand All @@ -19,7 +19,7 @@ const sendMessage = (req, res) => {

const receiver = whatsapp.formatPhone(req.body.receiver)
const message = req.body.message
const session = whatsapp.getSession(req.body.sender)
const session = whatsapp.getSession(req.body.session)

if(!session) return response(res, 404, {success: false, message: 'The requested session cannot be found.'})

Expand Down
Loading

0 comments on commit eef4371

Please sign in to comment.