diff --git a/docs/openapi.yaml b/docs/openapi.yaml index b485f96..889838c 100644 --- a/docs/openapi.yaml +++ b/docs/openapi.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: WhatsApp API MultiDevice - version: 3.8.0 + version: 3.9.0 description: This API is used for sending whatsapp via API servers: - url: http://localhost:3000 @@ -691,6 +691,55 @@ paths: application/json: schema: $ref: '#/components/schemas/ErrorInternalServer' + /message/{message_id}/update: + post: + operationId: updateMessage + tags: + - message + summary: Edit message by message ID before 15 minutes + parameters: + - in: path + name: message_id + schema: + type: string + required: true + description: Message ID + requestBody: + content: + application/json: + schema: + type: object + properties: + phone: + type: string + example: '62819273192397132@s.whatsapp.net' + description: Phone number with country code + message: + type: string + example: 'Hello World' + description: New message to send + required: + - phone + - message + 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 diff --git a/src/views/components/MessageUpdate.js b/src/views/components/MessageUpdate.js new file mode 100644 index 0000000..6ca4644 --- /dev/null +++ b/src/views/components/MessageUpdate.js @@ -0,0 +1,119 @@ +export default { + name: 'Update Message', + data() { + return { + update_type: 'user', + update_phone: '', + update_message_id: '', + update_new_message: '', + update_loading: false, + } + }, + computed: { + update_phone_id() { + return this.update_type === 'user' ? `${this.update_phone}@${window.TYPEUSER}` : `${this.update_phone}@${window.TYPEGROUP}` + } + }, + methods: { + messageEditModal() { + $('#modalMessageEdit').modal({ + onApprove: function () { + return false; + } + }).modal('show'); + }, + async messageEditProcess() { + try { + let response = await this.messageEditApi() + showSuccessInfo(response) + $('#modalMessageEdit').modal('hide'); + } catch (err) { + showErrorInfo(err) + } + }, + messageEditApi() { + return new Promise(async (resolve, reject) => { + try { + this.update_loading = true; + + const payload = { + phone: this.update_phone_id, + message: this.update_new_message + } + + let response = await http.post(`/message/${this.update_message_id}/update`, payload) + this.messageEditReset(); + resolve(response.data.message) + } catch (error) { + if (error.response) { + reject(error.response.data.message) + } else { + reject(error.message) + } + } finally { + this.update_loading = false; + } + }) + }, + messageEditReset() { + this.update_type = 'user'; + this.update_phone = ''; + this.update_message_id = ''; + this.update_new_message = ''; + this.update_loading = false; + }, + }, + template: ` +
+
+ Message +
Edit Message
+
+ Update your sent message +
+
+
+ + + + ` +} \ No newline at end of file diff --git a/src/views/index.html b/src/views/index.html index 8bf94f0..8aef03f 100644 --- a/src/views/index.html +++ b/src/views/index.html @@ -169,6 +169,8 @@ + +
@@ -821,6 +823,7 @@