From b0e245c5f4a71a955f07522e1177f1a218094306 Mon Sep 17 00:00:00 2001 From: Keyur Shah Date: Fri, 12 Apr 2024 06:56:24 +0530 Subject: [PATCH] This one is also Completed --- .gitignore | 4 +- apis/index.go | 33 +- swagger/index.html | 23 - swagger/swagger.json | 508 --------------------- swagger/swagger.yml | 972 ----------------------------------------- whatsapp/interfaces.go | 8 +- 6 files changed, 36 insertions(+), 1512 deletions(-) delete mode 100644 swagger/index.html delete mode 100644 swagger/swagger.json delete mode 100644 swagger/swagger.yml diff --git a/.gitignore b/.gitignore index e53a079..d5459d8 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,6 @@ __debug* server.config.json tmp -jwelly.whatsapp.config \ No newline at end of file +jwelly.whatsapp.config + +**/.DS_Store \ No newline at end of file diff --git a/apis/index.go b/apis/index.go index a25d3b1..35edbdf 100644 --- a/apis/index.go +++ b/apis/index.go @@ -57,6 +57,14 @@ func SendMediaFile(c *fiber.Ctx) error { return err } + if len(body.To) == 0 || len(body.To[0]) < 7 { + return &interfaces.RequestError{ + StatusCode: http.StatusBadRequest, + Code: interfaces.ERROR_INVALID_INPUT, + Message: "Number Not Found", + Name: "ERROR_INVALID_INPUT", + } + } connection, ok := whatsapp.ConnectionMap[number] if !ok || connection == nil { return &interfaces.RequestError{ @@ -97,11 +105,21 @@ func SendMediaFile(c *fiber.Ctx) error { func SendMediaFileWithBase64(c *fiber.Ctx) error { body := new(apiSendMediaMsgWithBase64) c.BodyParser(body) - number, err := interfaces.ExtractNumberFromCtx(c) - if err != nil { + + if err := utility.ValidateReqInput(body); err != nil { return err } - if err := utility.ValidateReqInput(body); err != nil { + + if len(body.To) == 0 || len(body.To[0]) < 7 { + return &interfaces.RequestError{ + StatusCode: http.StatusBadRequest, + Code: interfaces.ERROR_INVALID_INPUT, + Message: "Number Not Found", + Name: "ERROR_INVALID_INPUT", + } + } + number, err := interfaces.ExtractNumberFromCtx(c) + if err != nil { return err } @@ -137,7 +155,14 @@ func SendMessage(c *fiber.Ctx) error { if err := utility.ValidateReqInput(body); err != nil { return err } - + if len(body.To) == 0 || len(body.To[0]) < 7 { + return &interfaces.RequestError{ + StatusCode: http.StatusBadRequest, + Code: interfaces.ERROR_INVALID_INPUT, + Message: "Number Not Found", + Name: "ERROR_INVALID_INPUT", + } + } number, err := interfaces.ExtractNumberFromCtx(c) if err != nil { return err diff --git a/swagger/index.html b/swagger/index.html deleted file mode 100644 index 32d5c19..0000000 --- a/swagger/index.html +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - SwaggerUI - - - -
- - - - \ No newline at end of file diff --git a/swagger/swagger.json b/swagger/swagger.json deleted file mode 100644 index 9e07b8c..0000000 --- a/swagger/swagger.json +++ /dev/null @@ -1,508 +0,0 @@ -{ - "openapi": "3.0.0", - "info": { - "title": "WhatsApp API MultiDevice", - "version": "3.7.0", - "description": "This API is used for sending whatsapp via API" - }, - "servers": [ - { - "url": "http://localhost:3000/v1" - }, - { - "url": "http://localhost:4000/v1" - } - ], - "tags": [ - { - "name": "SendMessages", - "description": "Sending Text And Whatsapp Message Over Whatsapp" - } - ], - "paths":{ - "/send_message": { - "post": { - "operationId": "appLogin", - "tags": [ - "SendMessages" - ], - "summary": "Send Text Message", - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "phone": { - "type": "string", - "example": "6289685028129@s.whatsapp.net", - "description": "Phone number with country code" - }, - "caption": { - "type": "string", - "example": "ini contoh caption video", - "description": "Caption to send" - }, - "view_once": { - "type": "boolean", - "example": "false", - "description": "View once" - }, - "video": { - "type": "string", - "format": "binary", - "description": "Video to send" - }, - "compress": { - "type": "boolean", - "example": "false", - "description": "Compress video" - } - } - } - } - } - }, - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/SendResponse" - } - } - } - }, - "400": { - "description": "Bad Request", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorBadRequest" - } - } - } - }, - "500": { - "description": "Internal Server Error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorInternalServer" - } - } - } - } - } - } - }, - "/send_media": { - "post": { - "operationId": "sendMedia", - "tags": [ - "SendMessages" - ], - "summary": "Send Any Media File", - "requestBody": { - "content": { - "multipart/form-data": { - "schema": { - "type": "object", - "required": [ - "to" - ], - "properties": { - "to": { - "type": "array", - "description": "Phone number with country code", - "items": { - "type": "string", - "example": "919999998888" - } - }, - "msg": { - "type": "string", - "example": "selamat malam", - "description": "Caption to send" - }, - "file": { - "type": "string", - "format": "binary", - "description": "Media To Be Send" - } - } - } - } - } - }, - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/SendResponse" - } - } - } - }, - "400": { - "description": "Bad Request", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorBadRequest" - } - } - } - }, - "500": { - "description": "Internal Server Error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorInternalServer" - } - } - } - } - } - } - } - }, - "components": { - "schemas": { - "UserGroupResponse": { - "type": "object", - "properties": { - "code": { - "type": "string", - "example": "SUCCESS" - }, - "message": { - "type": "string", - "example": "Success get list groups" - }, - "results": { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "type": "object", - "properties": { - "JID": { - "type": "string" - }, - "OwnerJID": { - "type": "string" - }, - "Name": { - "type": "string" - }, - "NameSetAt": { - "type": "string" - }, - "NameSetBy": { - "type": "string" - }, - "GroupCreated": { - "type": "string" - }, - "ParticipantVersionID": { - "type": "string" - }, - "Participants": { - "type": "array", - "items": { - "properties": { - "JID": { - "type": "string" - }, - "IsAdmin": { - "type": "boolean" - }, - "IsSuperAdmin": { - "type": "boolean" - }, - "Error": { - "type": "number" - } - } - } - } - } - } - } - } - } - } - }, - "UserInfoResponse": { - "type": "object", - "properties": { - "code": { - "type": "string", - "example": "SUCCESS" - }, - "message": { - "type": "string", - "example": null - }, - "results": { - "type": "object", - "properties": { - "verified_name": { - "type": "string", - "example": "Aldino Kemal" - }, - "status": { - "type": "string", - "example": "Hello World" - }, - "picture_id": { - "type": "string", - "example": 1651459152 - }, - "devices": { - "type": "array", - "items": { - "type": "object", - "properties": { - "User": { - "type": "string", - "example": 6289685021291 - }, - "Agent": { - "type": "integer", - "example": 0 - }, - "Device": { - "type": "string", - "example": "UNKNOWN" - }, - "Server": { - "type": "string", - "example": "s.whatsapp.net" - }, - "AD": { - "type": "boolean", - "example": true - } - } - } - } - } - } - } - }, - "UserAvatarResponse": { - "type": "object", - "properties": { - "code": { - "type": "string", - "example": "SUCCESS" - }, - "message": { - "type": "string", - "example": "Success" - }, - "results": { - "type": "object", - "properties": { - "url": { - "type": "string", - "example": "https://pps.whatsapp.net/v/t61.24694-24/181358562_385581386633509_6230178822944778044_n.jpg?ccb=11-4&oh=df36c5b990497b8a5758a0f1ad8118a8&oe=620AA726" - }, - "id": { - "type": "string", - "example": "1635239861" - }, - "type": { - "type": "string", - "example": "image" - } - } - } - } - }, - "UserPrivacyResponse": { - "type": "object", - "properties": { - "code": { - "type": "string", - "example": "SUCCESS" - }, - "message": { - "type": "string", - "example": "Success get privacy" - }, - "results": { - "type": "object", - "properties": { - "group_add": { - "type": "string", - "example": "all" - }, - "last_seen": { - "type": "string", - "example": null - }, - "status": { - "type": "string", - "example": "all" - }, - "profile": { - "type": "string", - "example": "all" - }, - "read_receipts": { - "type": "string", - "example": "all" - } - } - } - } - }, - "SendResponse": { - "type": "object", - "properties": { - "code": { - "type": "string", - "example": "SUCCESS" - }, - "message": { - "type": "string", - "example": "Success" - }, - "results": { - "type": "object", - "properties": { - "message_id": { - "type": "string", - "example": "3EB0B430B6F8F1D0E053AC120E0A9E5C" - }, - "status": { - "type": "string", - "example": " success ...." - } - } - } - } - }, - "DeviceResponse": { - "type": "object", - "properties": { - "code": { - "type": "string", - "example": "SUCCESS" - }, - "message": { - "type": "string", - "example": "Fetch device success" - }, - "results": { - "type": "array", - "items": { - "type": "object", - "properties": { - "name": { - "type": "string", - "example": "Aldino Kemal" - }, - "device": { - "type": "string", - "example": "628960561XXX.0:64@s.whatsapp.net" - } - } - } - } - } - }, - "LoginResponse": { - "type": "object", - "properties": { - "code": { - "type": "string", - "example": "SUCCESS" - }, - "message": { - "type": "string", - "example": "Success" - }, - "results": { - "type": "object", - "properties": { - "qr_duration": { - "type": "integer", - "example": 30 - }, - "qr_link": { - "type": "string", - "example": "http://localhost:3000/statics/images/qrcode/scan-qr-b0b7bb43-9a22-455a-814f-5a225c743310.png" - } - } - } - } - }, - "GenericResponse": { - "type": "object", - "properties": { - "code": { - "type": "string", - "example": "SUCCESS" - }, - "message": { - "type": "string", - "example": "Success" - }, - "results": { - "type": "string", - "example": null - } - } - }, - "ErrorInternalServer": { - "type": "object", - "properties": { - "code": { - "type": "string", - "example": 101, - "description": "SYSTEM_CODE_ERROR" - }, - "message": { - "type": "string", - "example": "you are not loggin", - "description": "Detail error message" - }, - "results": { - "type": "object", - "example": null, - "description": "additional data" - } - } - }, - "ErrorBadRequest": { - "type": "object", - "properties": { - "code": { - "type": "string", - "example": 400, - "description": "HTTP Status Code" - }, - "message": { - "type": "string", - "example": "field cannot be blank", - "description": "Detail error message" - }, - "results": { - "type": "object", - "example": null, - "description": "additional data" - } - } - } - } - } -} \ No newline at end of file diff --git a/swagger/swagger.yml b/swagger/swagger.yml deleted file mode 100644 index 078e7b8..0000000 --- a/swagger/swagger.yml +++ /dev/null @@ -1,972 +0,0 @@ -openapi: 3.0.0 -info: - title: WhatsApp API MultiDevice - version: 3.7.0 - description: This API is used for sending whatsapp via API -servers: - - url: http://localhost:3000/v1 - - url: http://localhost:4000/v1 -tags: - - name: SendMessages - description: Sending Text And Whatsapp Message Over Whatsapp - -paths: - /send_message: - post: - operationId: appLogin - tags: - - SendMessages - summary: Send Text Message - requestBody: - content: - application/json: - schema: - type: object - properties: - phone: - type: string - example: '6289685028129@s.whatsapp.net' - description: Phone number with country code - caption: - type: string - example: ini contoh caption video - description: Caption to send - view_once: - type: boolean - example: 'false' - description: View once - video: - type: string - format: binary - description: Video to send - compress: - type: boolean - example: 'false' - description: Compress video - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/SendResponse' - '400': - description: Bad Request - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorBadRequest' - '500': - description: Internal Server Error - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorInternalServer' - /send_media: - post: - operationId: sendMedia - tags: - - SendMessages - summary: Send Any Media File - requestBody: - content: - multipart/form-data: - schema: - type: object - required: ["to"] - properties: - to: - type: array - description: Phone number with country code - items: - type: string - example: "919999998888" - msg: - type: string - example: selamat malam - description: Caption to send - file: - type: string - format: binary - description: Media To Be Send - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/SendResponse' - '400': - description: Bad Request - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorBadRequest' - '500': - description: Internal Server Error - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorInternalServer' - /app/logout: - get: - operationId: appLogout - tags: - - app - summary: Remove database and logout - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/GenericResponse' - '500': - description: Internal Server Error - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorInternalServer' - /app/reconnect: - get: - operationId: appReconnect - tags: - - app - summary: Reconnecting to whatsapp server - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/GenericResponse' - '500': - description: Internal Server Error - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorInternalServer' - /app/devices: - get: - operationId: appDevices - tags: - - app - summary: Get list connected devices - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/DeviceResponse' - '500': - description: Internal Server Error - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorInternalServer' - /user/info: - get: - operationId: userInfo - tags: - - user - summary: User Info - parameters: - - name: phone - in: query - schema: - type: integer - example: '6289685028129@s.whatsapp.net' - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/UserInfoResponse' - '400': - description: Bad Request - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorBadRequest' - '500': - description: Internal Server Error - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorInternalServer' - /user/avatar: - get: - operationId: userAvatar - tags: - - user - summary: User Avatar - parameters: - - name: phone - in: query - schema: - type: integer - example: '6289685028129@s.whatsapp.net' - - name: is_preview - in: query - schema: - type: boolean - example: true - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/UserAvatarResponse' - '400': - description: Bad Request - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorBadRequest' - '500': - description: Internal Server Error - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorInternalServer' - /user/my/privacy: - get: - operationId: userMyPrivacy - tags: - - user - summary: User My Privacy Setting - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/UserPrivacyResponse' - '500': - description: Internal Server Error - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorInternalServer' - /user/my/groups: - get: - operationId: userMyGroups - tags: - - user - summary: User My List Groups - responses: - '500': - description: Internal Server Error - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorInternalServer' - /send/message: - post: - operationId: sendMessage - tags: - - send - summary: Send Message - requestBody: - content: - multipart/form-data: - schema: - type: object - properties: - phone: - type: string - example: '6289685028129@s.whatsapp.net' - description: Phone number with country code - message: - type: string - example: selamat malam - description: Message to send - reply_message_id: - type: string - example: 3EB089B9D6ADD58153C561 - description: Message ID that you want reply - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/SendResponse' - '400': - description: Bad Request - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorBadRequest' - '500': - description: Internal Server Error - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorInternalServer' - /send/image: - post: - operationId: sendImage - tags: - - send - summary: Send Image - requestBody: - content: - multipart/form-data: - schema: - type: object - properties: - phone: - type: string - example: '6289685028129@s.whatsapp.net' - description: Phone number with country code - caption: - type: string - example: selamat malam - description: Caption to send - view_once: - type: boolean - example: false - description: View once - image: - type: string - format: binary - description: Image to send - compress: - type: boolean - example: false - description: Compress image - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/SendResponse' - '400': - description: Bad Request - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorBadRequest' - '500': - description: Internal Server Error - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorInternalServer' - /send/file: - post: - operationId: sendFile - tags: - - send - summary: Send File - requestBody: - content: - multipart/form-data: - schema: - type: object - properties: - phone: - type: string - example: '6289685028129@s.whatsapp.net' - description: Phone number with country code - caption: - type: string - example: selamat malam - description: Caption to send - file: - type: string - format: binary - description: File to send - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/SendResponse' - '400': - description: Bad Request - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorBadRequest' - '500': - description: Internal Server Error - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorInternalServer' - /send/video: - post: - operationId: sendVideo - tags: - - send - summary: Send Video - requestBody: - content: - multipart/form-data: - schema: - type: object - properties: - phone: - type: string - example: '6289685028129@s.whatsapp.net' - description: Phone number with country code - caption: - type: string - example: ini contoh caption video - description: Caption to send - view_once: - type: boolean - example: 'false' - description: View once - video: - type: string - format: binary - description: Video to send - compress: - type: boolean - example: 'false' - description: Compress video - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/SendResponse' - '400': - description: Bad Request - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorBadRequest' - '500': - description: Internal Server Error - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorInternalServer' - /send/contact: - post: - operationId: sendContact - tags: - - send - summary: Send Contact - requestBody: - content: - multipart/form-data: - schema: - type: object - properties: - phone: - type: string - example: '6289685024051@s.whatsapp.net' - description: Phone number with country code - contact_name: - type: string - example: Aldino Kemal - description: Contact name - contact_phone: - type: string - example: '6289685024992' - description: Contact phone number - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/SendResponse' - '400': - description: Bad Request - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorBadRequest' - '500': - description: Internal Server Error - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorInternalServer' - /send/link: - post: - operationId: sendLink - tags: - - send - summary: Send Link - requestBody: - content: - multipart/form-data: - schema: - type: object - properties: - phone: - type: string - example: '6289685024051@s.whatsapp.net' - description: Phone number with country code - link: - type: string - example: "https://google.com" - description: Link to send - caption: - type: string - example: 'Halo ini contoh caption' - description: Caption to send - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/SendResponse' - '400': - description: Bad Request - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorBadRequest' - '500': - description: Internal Server Error - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorInternalServer' - /send/location: - post: - operationId: sendLocation - tags: - - send - summary: Send Location - requestBody: - content: - multipart/form-data: - schema: - type: object - properties: - phone: - type: string - example: '6289685024051@s.whatsapp.net' - description: Phone number with country code - latitude: - type: string - example: "-7.797068" - description: Latitude coordinate - longitude: - type: string - example: '110.370529' - description: Longitude coordinate - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/SendResponse' - '400': - description: Bad Request - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorBadRequest' - '500': - description: Internal Server Error - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorInternalServer' - /message/{message_id}/revoke: - post: - operationId: revokeMessage - tags: - - message - summary: Revoke Message - parameters: - - in: path - name: message_id - schema: - type: string - required: true - description: Message ID - requestBody: - content: - multipart/form-data: - schema: - type: object - properties: - phone: - type: string - example: '6289685024051@s.whatsapp.net' - description: Phone number with country code - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/SendResponse' - '400': - description: Bad Request - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorBadRequest' - '500': - description: Internal Server Error - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorInternalServer' - /message/{message_id}/reaction: - post: - operationId: reactMessage - tags: - - message - summary: Send reaction to message - parameters: - - in: path - name: message_id - schema: - type: string - required: true - description: Message ID - requestBody: - content: - multipart/form-data: - schema: - type: object - properties: - phone: - type: string - example: '6289685024051@s.whatsapp.net' - description: Phone number with country code - emoji: - type: string - example: "🙏" - description: Emoji to react - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/SendResponse' - '400': - description: Bad Request - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorBadRequest' - '500': - description: Internal Server Error - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorInternalServer' - /group/join-with-link: - post: - operationId: joinGroupWithLink - tags: - - group - summary: Join group with link - requestBody: - content: - multipart/form-data: - schema: - type: object - properties: - link: - type: string - example: 'https://chat.whatsapp.com/whatsappKeyJoinGroup' - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/SendResponse' - '400': - description: Bad Request - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorBadRequest' - '500': - description: Internal Server Error - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorInternalServer' - /group/leave: - post: - operationId: leaveGroup - tags: - - group - summary: Leave group - requestBody: - content: - multipart/form-data: - schema: - type: object - properties: - group_id: - type: string - example: '120363024512399999@g.us' - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/GenericResponse' - '400': - description: Bad Request - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorBadRequest' - '500': - description: Internal Server Error - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorInternalServer' - -components: - schemas: - UserGroupResponse: - type: object - properties: - code: - type: string - example: SUCCESS - message: - type: string - example: Success get list groups - results: - type: object - properties: - data: - type: array - items: - type: object - properties: - JID: - type: string - OwnerJID: - type: string - Name: - type: string - NameSetAt: - type: string - NameSetBy: - type: string - GroupCreated: - type: string - ParticipantVersionID: - type: string - Participants: - type: array - items: - properties: - JID: - type: string - IsAdmin: - type: boolean - IsSuperAdmin: - type: boolean - Error: - type: number - UserInfoResponse: - type: object - properties: - code: - type: string - example: SUCCESS - message: - type: string - example: - results: - type: object - properties: - verified_name: - type: string - example: Aldino Kemal - status: - type: string - example: Hello World - picture_id: - type: string - example: 1651459152 - devices: - type: array - items: - type: object - properties: - User: - type: string - example: 6289685021291 - Agent: - type: integer - example: 0 - Device: - type: string - example: UNKNOWN - Server: - type: string - example: s.whatsapp.net - AD: - type: boolean - example: true - UserAvatarResponse: - type: object - properties: - code: - type: string - example: SUCCESS - message: - type: string - example: Success - results: - type: object - properties: - url: - type: string - example: 'https://pps.whatsapp.net/v/t61.24694-24/181358562_385581386633509_6230178822944778044_n.jpg?ccb=11-4&oh=df36c5b990497b8a5758a0f1ad8118a8&oe=620AA726' - id: - type: string - example: '1635239861' - type: - type: string - example: 'image' - UserPrivacyResponse: - type: object - properties: - code: - type: string - example: SUCCESS - message: - type: string - example: Success get privacy - results: - type: object - properties: - group_add: - type: string - example: all - last_seen: - type: string - example: null - status: - type: string - example: all - profile: - type: string - example: all - read_receipts: - type: string - example: all - SendResponse: - type: object - properties: - code: - type: string - example: SUCCESS - message: - type: string - example: Success - results: - type: object - properties: - message_id: - type: string - example: '3EB0B430B6F8F1D0E053AC120E0A9E5C' - status: - type: string - example: ' success ....' - DeviceResponse: - type: object - properties: - code: - type: string - example: SUCCESS - message: - type: string - example: Fetch device success - results: - type: array - items: - type: object - properties: - name: - type: string - example: 'Aldino Kemal' - device: - type: string - example: '628960561XXX.0:64@s.whatsapp.net' - LoginResponse: - type: object - properties: - code: - type: string - example: SUCCESS - message: - type: string - example: Success - results: - type: object - properties: - qr_duration: - type: integer - example: 30 - qr_link: - type: string - example: 'http://localhost:3000/statics/images/qrcode/scan-qr-b0b7bb43-9a22-455a-814f-5a225c743310.png' - GenericResponse: - type: object - properties: - code: - type: string - example: SUCCESS - message: - type: string - example: Success - results: - type: string - example: null - ErrorInternalServer: - type: object - properties: - code: - type: string - example: INTERNAL_SERVER_ERROR - description: 'SYSTEM_CODE_ERROR' - message: - type: string - example: you are not loggin - description: 'Detail error message' - results: - type: object - example: null - description: 'additional data' - ErrorBadRequest: - type: object - properties: - code: - type: string - example: 400 - description: 'HTTP Status Code' - message: - type: string - example: field cannot be blank - description: 'Detail error message' - results: - type: object - example: null - description: 'additional data' \ No newline at end of file diff --git a/whatsapp/interfaces.go b/whatsapp/interfaces.go index c314949..51e07c6 100644 --- a/whatsapp/interfaces.go +++ b/whatsapp/interfaces.go @@ -137,8 +137,8 @@ func (connection *WhatsappConnection) SendTextMessage(to []string, msg string) * } return &response } -func (connection *WhatsappConnection) SendMediaFile(to []string, filePath string, fileName string, msg string) *map[string]bool { - response := make(map[string]bool) +func (connection *WhatsappConnection) SendMediaFile(to []string, filePath string, fileName string, msg string) *map[string]interface{} { + response := make(map[string]interface{}) var docProto *waProto.Message for _, number := range to { IsOnWhatsappCheck, err := connection.Client.IsOnWhatsApp([]string{"+" + number}) @@ -243,9 +243,9 @@ func (connection *WhatsappConnection) SendMediaFile(to []string, filePath string } response[number] = false if len(msg) > 0 { - _, err := connection.Client.SendMessage(context.Background(), targetJID, docProto) + resp, err := connection.Client.SendMessage(context.Background(), targetJID, docProto) if err == nil { - response[number] = true + response[number] = resp } } }