From c9feb06461cbfba7406622dfa9bcc20bf1d65b78 Mon Sep 17 00:00:00 2001 From: Keyur Shah Date: Thu, 9 May 2024 22:05:45 +0530 Subject: [PATCH 1/2] Docker Image Chnaged --- compose.yaml | 55 +-- go.mod | 1 + go.sum | 3 + main.go | 3 +- swagger/index.html | 23 + swagger/swagger.json | 508 ++++++++++++++++++++++ swagger/swagger.yml | 972 +++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 1513 insertions(+), 52 deletions(-) create mode 100644 swagger/index.html create mode 100644 swagger/swagger.json create mode 100644 swagger/swagger.yml diff --git a/compose.yaml b/compose.yaml index 424e5dc..b3f0277 100644 --- a/compose.yaml +++ b/compose.yaml @@ -21,57 +21,10 @@ services: environment: - APP_ENV=${APP_ENV} - PORT=${PORT} - - DB_URL=${DB_URL} - - DB_NAME=${DB_NAME} - - REDIS_DB_HOST=redis - - REDIS_DB_PORT=${REDIS_DB_PORT} - - REDIS_DB_PASSWORD=${REDIS_DB_PASSWORD} - - REDIS_DB_DATABASE=${REDIS_DB_DATABASE} - - ACCESS_TOKEN_KEY=${ACCESS_TOKEN_KEY} - - REFRESH_TOKEN_KEY=${REFRESH_TOKEN_KEY} - - FIREBASE_JSON_STRING=${FIREBASE_JSON_STRING} - - FIREBASE_DATABASE_URL=${FIREBASE_DATABASE_URL} + - ALLOW_LOCAL_NO_AUTH=${ALLOW_LOCAL_NO_AUTH} + - AUTO_CONNECT_TO_WHATSAPP=${AUTO_CONNECT_TO_WHATSAPP} + - OPEN_BROWSER_FOR_SCAN=${OPEN_BROWSER_FOR_SCAN} ports: - 5000:${PORT} - redis: - image: redis:alpine - command: - - '--port ${REDIS_DB_PORT}' - - '--requirepass ${REDIS_DB_PASSWORD}' - ports: - - '${REDIS_DB_PORT}:${REDIS_DB_PORT}' - -# The commented out section below is an example of how to define a PostgreSQL -# database that your application can use. `depends_on` tells Docker Compose to -# start the database before your application. The `db-data` volume persists the -# database data between container restarts. The `db-password` secret is used -# to set the database password. You must create `db/password.txt` and add -# a password of your choosing to it before running `docker compose up`. -# depends_on: -# db: -# condition: service_healthy -# db: -# image: postgres -# restart: always -# user: postgres -# secrets: -# - db-password -# volumes: -# - db-data:/var/lib/postgresql/data -# environment: -# - POSTGRES_DB=example -# - POSTGRES_PASSWORD_FILE=/run/secrets/db-password -# expose: -# - 5432 -# healthcheck: -# test: [ "CMD", "pg_isready" ] -# interval: 10s -# timeout: 5s -# retries: 5 -# volumes: -# db-data: -# secrets: -# db-password: -# file: db/password.txt - + diff --git a/go.mod b/go.mod index 81d8b52..69bf0c2 100644 --- a/go.mod +++ b/go.mod @@ -37,6 +37,7 @@ require ( github.com/gofiber/contrib/swagger v1.1.1 // indirect github.com/gorilla/websocket v1.5.1 // indirect github.com/josharian/intern v1.0.0 // indirect + github.com/judwhite/go-svc v1.2.1 // indirect github.com/klauspost/compress v1.17.7 // indirect github.com/leodido/go-urn v1.4.0 // indirect github.com/mailru/easyjson v0.7.7 // indirect diff --git a/go.sum b/go.sum index 069793c..0546d58 100644 --- a/go.sum +++ b/go.sum @@ -114,6 +114,8 @@ github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= +github.com/judwhite/go-svc v1.2.1 h1:a7fsJzYUa33sfDJRF2N/WXhA+LonCEEY8BJb1tuS5tA= +github.com/judwhite/go-svc v1.2.1/go.mod h1:mo/P2JNX8C07ywpP9YtO2gnBgnUiFTHqtsZekJrUuTk= github.com/karrick/godirwalk v1.8.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaRPx4tDPEn4= github.com/karrick/godirwalk v1.10.3/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA= github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= @@ -247,6 +249,7 @@ golang.org/x/sys v0.0.0-20190419153524-e8e3143a4f4a/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190531175056-4c3a928424d2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210420072515-93ed5bcd2bfe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= diff --git a/main.go b/main.go index 3a19336..d711970 100644 --- a/main.go +++ b/main.go @@ -21,6 +21,7 @@ import ( ) var version string +var app *fiber.App func main() { println(version) @@ -53,7 +54,7 @@ func main() { } func InitFiberServer() { - app := fiber.New(fiber.Config{ + app = fiber.New(fiber.Config{ ErrorHandler: func(c *fiber.Ctx, err error) error { mappedError, ok := err.(*interfaces.RequestError) if !ok { diff --git a/swagger/index.html b/swagger/index.html new file mode 100644 index 0000000..32d5c19 --- /dev/null +++ b/swagger/index.html @@ -0,0 +1,23 @@ + + + + + + + SwaggerUI + + + +
+ + + + \ No newline at end of file diff --git a/swagger/swagger.json b/swagger/swagger.json new file mode 100644 index 0000000..66a246f --- /dev/null +++ b/swagger/swagger.json @@ -0,0 +1,508 @@ +{ + "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 new file mode 100644 index 0000000..078e7b8 --- /dev/null +++ b/swagger/swagger.yml @@ -0,0 +1,972 @@ +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 From e5a719ac729f51185ff0ca21d47d15c7e0656131 Mon Sep 17 00:00:00 2001 From: Keyur Shah Date: Sat, 8 Jun 2024 13:51:10 +0530 Subject: [PATCH 2/2] Minor File Changes --- main.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index bcfe5a9..2ccb1f4 100644 --- a/main.go +++ b/main.go @@ -38,6 +38,11 @@ func main() { os.Mkdir("./tmp", 0777) }() env.ServerConfig = ReadConfigFileAndReturnIt(env.CurrentDirectory) + outputLogFolderDir := filepath.Join(env.CurrentDirectory, "whatsapp_server_logs") + + if _, err := os.Stat(outputLogFolderDir); errors.Is(err, os.ErrNotExist) { + os.MkdirAll(outputLogFolderDir, 0777) + } whatsapp.OutPutFilePath = ReturnOutPutFilePath(env.CurrentDirectory) whatsapp.InitSqlContainer() go func() { @@ -116,7 +121,7 @@ func ReadConfigFileAndReturnIt(currentDir string) *env.IServerConfig { func ReturnOutPutFilePath(currentDir string) string { t := time.Now() today := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, t.Nanosecond(), t.Location()).Unix() - return filepath.Join(currentDir, "whatsapp_server_logs", fmt.Sprintf("%d.log.csv", today)) + return filepath.Join(currentDir, fmt.Sprintf("%d.log.csv", today)) } func check(e error) { if e != nil {