From fb5dc877217adefe3fc60768729006cfcb73a5cb Mon Sep 17 00:00:00 2001 From: Aldino Kemal Date: Sun, 2 Jun 2024 08:23:48 +0700 Subject: [PATCH] feat: add FE and docs --- docs/openapi.yaml | 60 ++++++++++++--- readme.md | 101 ++++++++++++------------ src/config/settings.go | 2 +- src/views/components/MessageDelete.js | 106 ++++++++++++++++++++++++++ src/views/index.html | 4 +- 5 files changed, 214 insertions(+), 59 deletions(-) create mode 100644 src/views/components/MessageDelete.js diff --git a/docs/openapi.yaml b/docs/openapi.yaml index 60533b8..e958ac1 100644 --- a/docs/openapi.yaml +++ b/docs/openapi.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: WhatsApp API MultiDevice - version: 3.11.0 + version: 4.0.0 description: This API is used for sending whatsapp via API servers: - url: http://localhost:3000 @@ -200,7 +200,7 @@ paths: summary: Send Message requestBody: content: - multipart/form-data: + application/json: schema: type: object properties: @@ -427,7 +427,7 @@ paths: summary: Send Contact requestBody: content: - multipart/form-data: + application/json: schema: type: object properties: @@ -470,7 +470,7 @@ paths: summary: Send Link requestBody: content: - multipart/form-data: + application/json: schema: type: object properties: @@ -513,7 +513,7 @@ paths: summary: Send Location requestBody: content: - multipart/form-data: + application/json: schema: type: object properties: @@ -618,7 +618,49 @@ paths: description: Message ID requestBody: content: - multipart/form-data: + application/json: + 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}/delete: + post: + operationId: deleteMessage + tags: + - message + summary: Delete Message + parameters: + - in: path + name: message_id + schema: + type: string + required: true + description: Message ID + requestBody: + content: + application/json: schema: type: object properties: @@ -660,7 +702,7 @@ paths: description: Message ID requestBody: content: - multipart/form-data: + application/json: schema: type: object properties: @@ -840,7 +882,7 @@ paths: summary: Join group with link requestBody: content: - multipart/form-data: + application/json: schema: type: object properties: @@ -874,7 +916,7 @@ paths: summary: Leave group requestBody: content: - multipart/form-data: + application/json: schema: type: object properties: diff --git a/readme.md b/readme.md index 3ce80e8..227c7de 100644 --- a/readme.md +++ b/readme.md @@ -92,38 +92,42 @@ docker run --detach --publish=3000:3000 --name=whatsapp --restart=always --volum You can fork or edit this source code ! ### Current API + - [Api Specification Document](https://bump.sh/aldinokemal/doc/go-whatsapp-web-multidevice) -- You can check [docs/openapi.yml](./docs/openapi.yaml) for detail API or paste to [SwaggerEditor](https://editor.swagger.io). +- You can check [docs/openapi.yml](./docs/openapi.yaml) for detail API or paste + to [SwaggerEditor](https://editor.swagger.io). - Furthermore you can generate HTTP Client from this API using [openapi-generator](https://openapi-generator.tech/#try) -| Feature | Menu | Method | URL | -|---------|------------------------------|--------|-----------------------------| -| ✅ | Login | GET | /app/login | -| ✅ | Logout | GET | /app/logout | -| ✅ | Reconnect | GET | /app/reconnect | -| ✅ | User Info | GET | /user/info | -| ✅ | User Avatar | GET | /user/avatar | -| ✅ | User My Group List | GET | /user/my/groups | -| ✅ | User My Privacy Setting | GET | /user/my/privacy | -| ✅ | Send Message | POST | /send/message | -| ✅ | Send Image | POST | /send/image | -| ✅ | Send Audio | POST | /send/audio | -| ✅ | Send File | POST | /send/file | -| ✅ | Send Video | POST | /send/video | -| ✅ | Send Contact | POST | /send/contact | -| ✅ | Send Link | POST | /send/link | -| ✅ | Send Location | POST | /send/location | -| ✅ | Send Poll / Vote | POST | /send/poll | -| ✅ | Revoke Message | POST | /message/:message_id/revoke | -| ✅ | React Message | POST | /message/:message_id/react | -| ✅ | Edit Message | POST | /message/:message_id/update | -| ✅ | Join Group With Link | POST | /group/join-with-link | -| ✅ | Leave Group | POST | /group/leave | -| ✅ | Create Group | POST | /group | -| ✅ | Add Participants in Group | POST | /group/participants | -| ❌ | Remove Participant in Group | DELETE | /group/participants | -| ❌ | Promote Participant in Group | POST | /group/participants/promote | -| ❌ | Demote Participant in Group | POST | /group/participants/demote | +| Feature | Menu | Method | URL | +|---------|------------------------------|--------|-------------------------------| +| ✅ | Login | GET | /app/login | +| ✅ | Logout | GET | /app/logout | +| ✅ | Reconnect | GET | /app/reconnect | +| ✅ | Devices | GET | /app/devices | +| ✅ | User Info | GET | /user/info | +| ✅ | User Avatar | GET | /user/avatar | +| ✅ | User My Group List | GET | /user/my/groups | +| ✅ | User My Privacy Setting | GET | /user/my/privacy | +| ✅ | Send Message | POST | /send/message | +| ✅ | Send Image | POST | /send/image | +| ✅ | Send Audio | POST | /send/audio | +| ✅ | Send File | POST | /send/file | +| ✅ | Send Video | POST | /send/video | +| ✅ | Send Contact | POST | /send/contact | +| ✅ | Send Link | POST | /send/link | +| ✅ | Send Location | POST | /send/location | +| ✅ | Send Poll / Vote | POST | /send/poll | +| ✅ | Revoke Message | POST | /message/:message_id/revoke | +| ✅ | React Message | POST | /message/:message_id/reaction | +| ✅ | Delete Message | POST | /message/:message_id/delete | +| ✅ | Edit Message | POST | /message/:message_id/update | +| ✅ | Join Group With Link | POST | /group/join-with-link | +| ✅ | Leave Group | POST | /group/leave | +| ✅ | Create Group | POST | /group | +| ✅ | Add Participants in Group | POST | /group/participants | +| ❌ | Remove Participant in Group | DELETE | /group/participants | +| ❌ | Promote Participant in Group | POST | /group/participants/promote | +| ❌ | Demote Participant in Group | POST | /group/participants/demote | ``` ✅ = Available @@ -132,25 +136,26 @@ You can fork or edit this source code ! ### App User Interface -1. Homepage ![Homepage](https://i.ibb.co/Wn3H1L9/homepage.png) -2. Login ![Login](https://i.ibb.co/jkcB15R/login.png?v=1) -3. Send Message ![Send Message](https://i.ibb.co/rc3NXMX/send-message.png?v1) -4. Send Image ![Send Image](https://i.ibb.co/BcFL3SD/send-image.png?v1) -5. Send File ![Send File](https://i.ibb.co/f4yxjpp/send-file.png) -6. Send Video ![Send Video](https://i.ibb.co/PrD3P51/send-video.png) -7. Send Contact ![Send Contact](https://i.ibb.co/4810H7N/send-contact.png) -8. Send Location ![Send Location](https://i.ibb.co/TWsy09G/send-location.png) -9. Send Audio ![Send Location](https://i.ibb.co/p1wL4wh/Send-Audio.png) -10. Send Poll ![Send Poll](https://i.ibb.co/mq2fGHz/send-poll.png) -11. Revoke Message ![Revoke Message](https://i.ibb.co/yswhvQY/revoke.png?v1) -12. Reaction Message ![Revoke Message](https://i.ibb.co/BfHgSHG/react-message.png) -13. Edit Message ![Edit Message](https://i.ibb.co/kXfpqJw/update-message.png) -14. User Info ![User Info](https://i.ibb.co/3zjX6Cz/user-info.png?v=1) -15. User Avatar ![User Avatar](https://i.ibb.co/ZmJZ4ZW/search-avatar.png?v=1) -16. My Privacy ![My Privacy](https://i.ibb.co/Cw1sMQz/my-privacy.png) -17. My Group ![My Group](https://i.ibb.co/WB268Xy/list-group.png) -18. Auto Reply ![Auto Reply](https://i.ibb.co/D4rTytX/IMG-20220517-162500.jpg) -19. Basic Auth Prompt ![Basic Auth](https://i.ibb.co/PDjQ92W/Screenshot-2022-11-06-at-14-06-29.png) +1. Homepage ![Homepage](https://i.ibb.co.com/Wn3H1L9/homepage.png) +2. Login ![Login](https://i.ibb.co.com/jkcB15R/login.png?v=1) +3. Send Message ![Send Message](https://i.ibb.co.com/rc3NXMX/send-message.png?v1) +4. Send Image ![Send Image](https://i.ibb.co.com/BcFL3SD/send-image.png?v1) +5. Send File ![Send File](https://i.ibb.co.com/f4yxjpp/send-file.png) +6. Send Video ![Send Video](https://i.ibb.co.com/PrD3P51/send-video.png) +7. Send Contact ![Send Contact](https://i.ibb.co.com/4810H7N/send-contact.png) +8. Send Location ![Send Location](https://i.ibb.co.com/TWsy09G/send-location.png) +9. Send Audio ![Send Location](https://i.ibb.co.com/p1wL4wh/Send-Audio.png) +10. Send Poll ![Send Poll](https://i.ibb.co.com/mq2fGHz/send-poll.png) +11. Revoke Message ![Revoke Message](https://i.ibb.co.com/yswhvQY/revoke.png?v1) +12. Delete Message ![Delete Message](https://i.ibb.co.com/F70SZ84/image.png) +13. Reaction Message ![Revoke Message](https://i.ibb.co.com/BfHgSHG/react-message.png) +14. Edit Message ![Edit Message](https://i.ibb.co.com/kXfpqJw/update-message.png) +15. User Info ![User Info](https://i.ibb.co.com/3zjX6Cz/user-info.png?v=1) +16. User Avatar ![User Avatar](https://i.ibb.co.com/ZmJZ4ZW/search-avatar.png?v=1) +17. My Privacy ![My Privacy](https://i.ibb.co.com/Cw1sMQz/my-privacy.png) +18. My Group ![My Group](https://i.ibb.co.com/WB268Xy/list-group.png) +19. Auto Reply ![Auto Reply](https://i.ibb.co.com/D4rTytX/IMG-20220517-162500.jpg) +20. Basic Auth Prompt ![Basic Auth](https://i.ibb.co.com/PDjQ92W/Screenshot-2022-11-06-at-14-06-29.png) ### Mac OS NOTE diff --git a/src/config/settings.go b/src/config/settings.go index 6e40818..9d9458e 100644 --- a/src/config/settings.go +++ b/src/config/settings.go @@ -5,7 +5,7 @@ import ( ) var ( - AppVersion = "v4.13.0" + AppVersion = "v4.14.0" AppPort = "3000" AppDebug = false AppOs = "AldinoKemal" diff --git a/src/views/components/MessageDelete.js b/src/views/components/MessageDelete.js new file mode 100644 index 0000000..cb6f46d --- /dev/null +++ b/src/views/components/MessageDelete.js @@ -0,0 +1,106 @@ +export default { + name: 'DeleteMessage', + data() { + return { + type: 'user', + phone: '', + message_id: '', + loading: false, + } + }, + computed: { + phone_id() { + return this.type === 'user' ? `${this.phone}@${window.TYPEUSER}` : `${this.phone}@${window.TYPEGROUP}` + } + }, + methods: { + openModal() { + $('#modalMessageDelete').modal({ + onApprove: function () { + return false; + } + }).modal('show'); + }, + async handleSubmit() { + try { + let response = await this.submitApi() + showSuccessInfo(response) + $('#modalMessageDelete').modal('hide'); + } catch (err) { + showErrorInfo(err) + } + }, + async submitApi() { + this.loading = true; + try { + const payload = {phone: this.phone_id, message: this.new_message} + + let response = await window.http.post(`/message/${this.message_id}/delete`, payload) + this.handleReset(); + return response.data.message; + } catch (error) { + if (error.response) { + throw new Error(error.response.data.message); + } + throw new Error(error.message); + } finally { + this.loading = false; + } + }, + handleReset() { + this.type = 'user'; + this.phone = ''; + this.message_id = ''; + this.new_message = ''; + this.loading = false; + }, + }, + template: ` +
+
+ Message +
Delete Message
+
+ Delete your sent message +
+
+
+ + + + ` +} \ No newline at end of file diff --git a/src/views/index.html b/src/views/index.html index 75723e0..85140d7 100644 --- a/src/views/index.html +++ b/src/views/index.html @@ -68,6 +68,7 @@
+ @@ -136,6 +137,7 @@ import SendLocation from "./components/SendLocation.js"; import SendAudio from "./components/SendAudio.js"; import SendPoll from "./components/SendPoll.js"; + import MessageDelete from "./components/MessageDelete.js"; import MessageUpdate from "./components/MessageUpdate.js"; import MessageReact from "./components/MessageReact.js"; import MessageRevoke from "./components/MessageRevoke.js"; @@ -170,7 +172,7 @@ components: { AppLogin, AppLogout, AppReconnect, SendMessage, SendImage, SendFile, SendVideo, SendContact, SendLocation, SendAudio, SendPoll, - MessageUpdate, MessageReact, MessageRevoke, + MessageDelete, MessageUpdate, MessageReact, MessageRevoke, GroupList, GroupCreate, GroupJoinWithLink, GroupAddParticipants, AccountAvatar, AccountUserInfo, AccountPrivacy },