Skip to content

Commit

Permalink
feat: take out all message and send audio
Browse files Browse the repository at this point in the history
  • Loading branch information
aldinokemal committed Mar 11, 2024
1 parent 5c35213 commit f7699ae
Show file tree
Hide file tree
Showing 6 changed files with 421 additions and 411 deletions.
116 changes: 116 additions & 0 deletions src/views/components/MessageReact.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
export default {
name: 'ReactMessage',
data() {
return {
type: 'user',
phone: '',
message_id: '',
emoji: '',
loading: false,
}
},
computed: {
phone_id() {
return this.type === 'user' ? `${this.phone}@${window.TYPEUSER}` : `${this.phone}@${window.TYPEGROUP}`
}
},
methods: {
messageModal() {
$('#modalMessageReaction').modal({
onApprove: function () {
return false;
}
}).modal('show');
},
async messageProcess() {
try {
let response = await this.messageApi()
showSuccessInfo(response)
$('#modalMessageReaction').modal('hide');
} catch (err) {
showErrorInfo(err)
}
},
messageApi() {
return new Promise(async (resolve, reject) => {
try {
this.loading = true;
let payload = new FormData();
payload.append("phone", this.phone_id)
payload.append("emoji", this.emoji)
let response = await http.post(`/message/${this.message_id}/reaction`, payload)
this.messageReset();
resolve(response.data.message)
} catch (error) {
if (error.response) {
reject(error.response.data.message)
} else {
reject(error.message)
}
} finally {
this.loading = false;
}
})
},
messageReset() {
this.phone = '';
this.message_id = '';
this.emoji = '';
this.type = 'user';
},
},
template: `
<div class="red card" @click="messageModal()" style="cursor: pointer">
<div class="content">
<a class="ui red right ribbon label">Message</a>
<div class="header">React Message</div>
<div class="description">
any message in private or group chat
</div>
</div>
</div>
<!-- Modal MessageReaction -->
<div class="ui small modal" id="modalMessageReaction">
<i class="close icon"></i>
<div class="header">
React Message
</div>
<div class="content">
<form class="ui form">
<div class="field">
<label>Type</label>
<select name="type" v-model="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="phone" type="text" placeholder="6289..."
aria-label="phone">
<input :value="phone_id" disabled aria-label="whatsapp_id">
</div>
<div class="field">
<label>Message ID</label>
<input v-model="message_id" type="text" placeholder="Please enter your message id"
aria-label="message id">
</div>
<div class="field">
<label>Emoji</label>
<input v-model="emoji" type="text" placeholder="Please enter emoji"
aria-label="message id">
</div>
</form>
</div>
<div class="actions">
<div class="ui approve positive right labeled icon button" :class="{'loading': this.loading}"
@click="messageProcess">
Send
<i class="send icon"></i>
</div>
</div>
</div>
`
}
107 changes: 107 additions & 0 deletions src/views/components/MessageRevoke.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
export default {
name: 'Message',
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: {
messageModal() {
$('#modalMessageRevoke').modal({
onApprove: function () {
return false;
}
}).modal('show');
},
async messageProcess() {
try {
let response = await this.messageApi()
showSuccessInfo(response)
$('#modalMessageRevoke').modal('hide');
} catch (err) {
showErrorInfo(err)
}
},
messageApi() {
return new Promise(async (resolve, reject) => {
try {
this.loading = true;
let payload = new FormData();
payload.append("phone", this.phone_id)
let response = await http.post(`/message/${this.message_id}/revoke`, payload)
this.messageReset();
resolve(response.data.message)
} catch (error) {
if (error.response) {
reject(error.response.data.message)
} else {
reject(error.message)
}
} finally {
this.loading = false;
}
})
},
messageReset() {
this.phone = '';
this.message_id = '';
this.type = 'user';
},
},
template:`
<div class="red card" @click="messageModal()" style="cursor: pointer">
<div class="content">
<a class="ui red right ribbon label">Message</a>
<div class="header">Revoke Message</div>
<div class="description">
any message in private or group chat
</div>
</div>
</div>
<!-- Modal MessageRevoke -->
<div class="ui small modal" id="modalMessageRevoke">
<i class="close icon"></i>
<div class="header">
Revoke Message
</div>
<div class="content">
<form class="ui form">
<div class="field">
<label>Type</label>
<select name="type" v-model="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="phone" type="text" placeholder="6289..."
aria-label="phone">
<input :value="phone_id" disabled aria-label="whatsapp_id">
</div>
<div class="field">
<label> Message ID</label>
<input v-model="message_id" type="text" placeholder="Please enter your message id"
aria-label="message id">
</div>
</form>
</div>
<div class="actions">
<div class="ui approve positive right labeled icon button" :class="{'loading': this.loading}"
@click="messageProcess">
Send
<i class="send icon"></i>
</div>
</div>
</div>
`
}
74 changes: 37 additions & 37 deletions src/views/components/MessageUpdate.js
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
export default {
name: 'Update Message',
name: 'UpdateMessage',
data() {
return {
update_type: 'user',
update_phone: '',
update_message_id: '',
update_new_message: '',
update_loading: false,
type: 'user',
phone: '',
message_id: '',
new_message: '',
loading: false,
}
},
computed: {
update_phone_id() {
return this.update_type === 'user' ? `${this.update_phone}@${window.TYPEUSER}` : `${this.update_phone}@${window.TYPEGROUP}`
phone_id() {
return this.type === 'user' ? `${this.phone}@${window.TYPEUSER}` : `${this.phone}@${window.TYPEGROUP}`
}
},
methods: {
messageEditModal() {
$('#modalMessageEdit').modal({
messageModal() {
$('#modalMessageUpdate').modal({
onApprove: function () {
return false;
}
}).modal('show');
},
async messageEditProcess() {
async messageProcess() {
try {
let response = await this.messageEditApi()
let response = await this.messageApi()
showSuccessInfo(response)
$('#modalMessageEdit').modal('hide');
$('#modalMessageUpdate').modal('hide');
} catch (err) {
showErrorInfo(err)
}
},
messageEditApi() {
messageApi() {
return new Promise(async (resolve, reject) => {
try {
this.update_loading = true;
this.loading = true;

const payload = {
phone: this.update_phone_id,
message: this.update_new_message
phone: this.phone_id,
message: this.new_message
}

let response = await http.post(`/message/${this.update_message_id}/update`, payload)
this.messageEditReset();
let response = await http.post(`/message/${this.message_id}/update`, payload)
this.messageReset();
resolve(response.data.message)
} catch (error) {
if (error.response) {
Expand All @@ -51,31 +51,31 @@ export default {
reject(error.message)
}
} finally {
this.update_loading = false;
this.loading = false;
}
})
},
messageEditReset() {
this.update_type = 'user';
this.update_phone = '';
this.update_message_id = '';
this.update_new_message = '';
this.update_loading = false;
messageReset() {
this.type = 'user';
this.phone = '';
this.message_id = '';
this.new_message = '';
this.loading = false;
},
},
template: `
<div class="red card" @click="messageEditModal()" style="cursor: pointer">
<div class="red card" @click="messageModal()" style="cursor: pointer">
<div class="content">
<a class="ui red right ribbon label">Message</a>
<div class="header">Edit Message</div>
<div class="header">Update Message</div>
<div class="description">
Update your sent message
</div>
</div>
</div>
<!-- Modal MessageEdit -->
<div class="ui small modal" id="modalMessageEdit">
<!-- Modal MessageUpdate -->
<div class="ui small modal" id="modalMessageUpdate">
<i class="close icon"></i>
<div class="header">
Update Message
Expand All @@ -84,32 +84,32 @@ export default {
<form class="ui form">
<div class="field">
<label>Type</label>
<select name="update_type" v-model="update_type" aria-label="type">
<select name="type" v-model="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..."
<input v-model="phone" type="text" placeholder="6289..."
aria-label="phone">
<input :value="update_phone_id" disabled aria-label="whatsapp_id">
<input :value="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"
<input v-model="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."
<textarea v-model="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">
<div class="ui approve positive right labeled icon button" :class="{'loading': this.loading}"
@click="messageProcess">
Update
<i class="send icon"></i>
</div>
Expand Down
Loading

0 comments on commit f7699ae

Please sign in to comment.