Browse Source

Feat/edit message (#119)

* feat: add edit message UI and open api

* chore: update edit message

* chore: update home page image
pull/123/head
Aldino Kemal 2 years ago
committed by GitHub
parent
commit
5c3521376c
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 51
      docs/openapi.yaml
  2. 16
      readme.md
  3. 119
      src/views/components/MessageUpdate.js
  4. 6
      src/views/index.html

51
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

16
readme.md

@ -122,6 +122,7 @@ API using [openapi-generator](https://openapi-generator.tech/#try)
| ✅ | 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 |
@ -132,7 +133,7 @@ API using [openapi-generator](https://openapi-generator.tech/#try)
### App User Interface
1. Homepage ![Homepage](https://i.ibb.co/RDBjmz1/homepage.png)
1. Homepage ![Homepage](https://i.ibb.co/18f8vCz/homepage.png)
2. Login ![Login](https://i.ibb.co/jkcB15R/login.png)
3. Send Message ![Send Message](https://i.ibb.co/rc3NXMX/send-message.png)
4. Send Image ![Send Image](https://i.ibb.co/BcFL3SD/send-image.png)
@ -144,12 +145,13 @@ API using [openapi-generator](https://openapi-generator.tech/#try)
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?)
12. Reaction Message ![Revoke Message](https://i.ibb.co/BfHgSHG/react-message.png)
13. User Info ![User Info](https://i.ibb.co/3zjX6Cz/user-info.png)
14. User Avatar ![User Avatar](https://i.ibb.co/ZmJZ4ZW/search-avatar.png)
15. My Privacy ![My Privacy](https://i.ibb.co/Cw1sMQz/my-privacy.png)
16. My Group ![My Group](https://i.ibb.co/WB268Xy/list-group.png)
17. Auto Reply ![Auto Reply](https://i.ibb.co/D4rTytX/IMG-20220517-162500.jpg)
18. Basic Auth Prompt ![Basic Auth](https://i.ibb.co/PDjQ92W/Screenshot-2022-11-06-at-14-06-29.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)
15. User Avatar ![User Avatar](https://i.ibb.co/ZmJZ4ZW/search-avatar.png)
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)
### Mac OS NOTE

119
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: `
<div class="red card" @click="messageEditModal()" style="cursor: pointer">
<div class="content">
<a class="ui red right ribbon label">Message</a>
<div class="header">Edit Message</div>
<div class="description">
Update your sent message
</div>
</div>
</div>
<!-- Modal MessageEdit -->
<div class="ui small modal" id="modalMessageEdit">
<i class="close icon"></i>
<div class="header">
Update Message
</div>
<div class="content">
<form class="ui form">
<div class="field">
<label>Type</label>
<select name="update_type" v-model="update_type" aria-label="type">
<option value="group">Group Message</option>
<option value="user">Private Message</option>
</select>
</div>
<div class="field">
<label>Phone / Group ID</label>
<input v-model="update_phone" type="text" placeholder="6289..."
aria-label="phone">
<input :value="update_phone_id" disabled aria-label="whatsapp_id">
</div>
<div class="field">
<label>Message ID</label>
<input v-model="update_message_id" type="text" placeholder="Please enter your message id"
aria-label="message id">
</div>
<div class="field">
<label>New Message</label>
<textarea v-model="update_new_message" type="text" placeholder="Hello this is your new message text, you can edit before 15 minutes after sent."
aria-label="message"></textarea>
</div>
</form>
</div>
<div class="actions">
<div class="ui approve positive right labeled icon button" :class="{'loading': this.update_loading}"
@click="messageEditProcess">
Update
<i class="send icon"></i>
</div>
</div>
</div>
`
}

6
src/views/index.html

@ -169,6 +169,8 @@
</div>
</div>
</div>
<message-update></message-update>
</div>
<div class="ui horizontal divider">
@ -821,6 +823,7 @@
</script>
<script type="module">
import SendPoll from "./components/SendPoll.js";
import MessageUpdate from "./components/MessageUpdate.js";
const showErrorInfo = (message) => {
$('body').toast({
@ -1740,7 +1743,8 @@
Vue.createApp({
components: {
SendPoll
SendPoll,
MessageUpdate,
},
delimiters: ['[[', ']]'],
data() {

Loading…
Cancel
Save