Browse Source

feat: Add IsForwarded field to request types for tracking forwarded m… (#271)

feat: Add IsForwarded field to request types for tracking forwarded messages
pull/280/head
Aldino Kemal 12 months ago
committed by GitHub
parent
commit
534e8977be
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 1
      src/domains/send/audio.go
  2. 1
      src/domains/send/contact.go
  3. 1
      src/domains/send/file.go
  4. 1
      src/domains/send/image.go
  5. 1
      src/domains/send/link.go
  6. 1
      src/domains/send/location.go
  7. 1
      src/domains/send/presence.go
  8. 1
      src/domains/send/text.go
  9. 1
      src/domains/send/video.go
  10. 68
      src/services/send.go
  11. 14
      src/views/components/SendAudio.js
  12. 20
      src/views/components/SendContact.js
  13. 15
      src/views/components/SendFile.js
  14. 20
      src/views/components/SendImage.js
  15. 10
      src/views/components/SendLink.js
  16. 15
      src/views/components/SendLocation.js
  17. 10
      src/views/components/SendMessage.js
  18. 18
      src/views/components/SendVideo.js

1
src/domains/send/audio.go

@ -5,4 +5,5 @@ import "mime/multipart"
type AudioRequest struct { type AudioRequest struct {
Phone string `json:"phone" form:"phone"` Phone string `json:"phone" form:"phone"`
Audio *multipart.FileHeader `json:"audio" form:"audio"` Audio *multipart.FileHeader `json:"audio" form:"audio"`
IsForwarded bool `json:"is_forwarded" form:"is_forwarded"`
} }

1
src/domains/send/contact.go

@ -4,4 +4,5 @@ type ContactRequest struct {
Phone string `json:"phone" form:"phone"` Phone string `json:"phone" form:"phone"`
ContactName string `json:"contact_name" form:"contact_name"` ContactName string `json:"contact_name" form:"contact_name"`
ContactPhone string `json:"contact_phone" form:"contact_phone"` ContactPhone string `json:"contact_phone" form:"contact_phone"`
IsForwarded bool `json:"is_forwarded" form:"is_forwarded"`
} }

1
src/domains/send/file.go

@ -6,4 +6,5 @@ type FileRequest struct {
Phone string `json:"phone" form:"phone"` Phone string `json:"phone" form:"phone"`
File *multipart.FileHeader `json:"file" form:"file"` File *multipart.FileHeader `json:"file" form:"file"`
Caption string `json:"caption" form:"caption"` Caption string `json:"caption" form:"caption"`
IsForwarded bool `json:"is_forwarded" form:"is_forwarded"`
} }

1
src/domains/send/image.go

@ -9,4 +9,5 @@ type ImageRequest struct {
ImageURL *string `json:"image_url" form:"image_url"` ImageURL *string `json:"image_url" form:"image_url"`
ViewOnce bool `json:"view_once" form:"view_once"` ViewOnce bool `json:"view_once" form:"view_once"`
Compress bool `json:"compress"` Compress bool `json:"compress"`
IsForwarded bool `json:"is_forwarded" form:"is_forwarded"`
} }

1
src/domains/send/link.go

@ -4,4 +4,5 @@ type LinkRequest struct {
Phone string `json:"phone" form:"phone"` Phone string `json:"phone" form:"phone"`
Caption string `json:"caption"` Caption string `json:"caption"`
Link string `json:"link"` Link string `json:"link"`
IsForwarded bool `json:"is_forwarded" form:"is_forwarded"`
} }

1
src/domains/send/location.go

@ -4,4 +4,5 @@ type LocationRequest struct {
Phone string `json:"phone" form:"phone"` Phone string `json:"phone" form:"phone"`
Latitude string `json:"latitude" form:"latitude"` Latitude string `json:"latitude" form:"latitude"`
Longitude string `json:"longitude" form:"longitude"` Longitude string `json:"longitude" form:"longitude"`
IsForwarded bool `json:"is_forwarded" form:"is_forwarded"`
} }

1
src/domains/send/presence.go

@ -2,4 +2,5 @@ package send
type PresenceRequest struct { type PresenceRequest struct {
Type string `json:"type" form:"type"` Type string `json:"type" form:"type"`
IsForwarded bool `json:"is_forwarded" form:"is_forwarded"`
} }

1
src/domains/send/text.go

@ -3,5 +3,6 @@ package send
type MessageRequest struct { type MessageRequest struct {
Phone string `json:"phone" form:"phone"` Phone string `json:"phone" form:"phone"`
Message string `json:"message" form:"message"` Message string `json:"message" form:"message"`
IsForwarded bool `json:"is_forwarded" form:"is_forwarded"`
ReplyMessageID *string `json:"reply_message_id" form:"reply_message_id"` ReplyMessageID *string `json:"reply_message_id" form:"reply_message_id"`
} }

1
src/domains/send/video.go

@ -8,4 +8,5 @@ type VideoRequest struct {
Video *multipart.FileHeader `json:"video" form:"video"` Video *multipart.FileHeader `json:"video" form:"video"`
ViewOnce bool `json:"view_once" form:"view_once"` ViewOnce bool `json:"view_once" form:"view_once"`
Compress bool `json:"compress"` Compress bool `json:"compress"`
IsForwarded bool `json:"is_forwarded" form:"is_forwarded"`
} }

68
src/services/send.go

@ -59,18 +59,23 @@ func (service serviceSend) SendText(ctx context.Context, request domainSend.Mess
return response, err return response, err
} }
// Send message
// Create base message
msg := &waE2E.Message{ msg := &waE2E.Message{
ExtendedTextMessage: &waE2E.ExtendedTextMessage{ ExtendedTextMessage: &waE2E.ExtendedTextMessage{
Text: proto.String(request.Message), Text: proto.String(request.Message),
ContextInfo: &waE2E.ContextInfo{},
}, },
} }
// Add forwarding context if IsForwarded is true
if request.IsForwarded {
msg.ExtendedTextMessage.ContextInfo.IsForwarded = proto.Bool(true)
msg.ExtendedTextMessage.ContextInfo.ForwardingScore = proto.Uint32(100)
}
parsedMentions := service.getMentionFromText(ctx, request.Message) parsedMentions := service.getMentionFromText(ctx, request.Message)
if len(parsedMentions) > 0 { if len(parsedMentions) > 0 {
msg.ExtendedTextMessage.ContextInfo = &waE2E.ContextInfo{
MentionedJID: parsedMentions,
}
msg.ExtendedTextMessage.ContextInfo.MentionedJID = parsedMentions
} }
// Reply message // Reply message
@ -207,6 +212,13 @@ func (service serviceSend) SendImage(ctx context.Context, request domainSend.Ima
ViewOnce: proto.Bool(request.ViewOnce), ViewOnce: proto.Bool(request.ViewOnce),
}} }}
if request.IsForwarded {
msg.ImageMessage.ContextInfo = &waE2E.ContextInfo{
IsForwarded: proto.Bool(true),
ForwardingScore: proto.Uint32(100),
}
}
caption := "🖼️ Image" caption := "🖼️ Image"
if request.Caption != "" { if request.Caption != "" {
caption = "🖼️ " + request.Caption caption = "🖼️ " + request.Caption
@ -259,6 +271,14 @@ func (service serviceSend) SendFile(ctx context.Context, request domainSend.File
DirectPath: proto.String(uploadedFile.DirectPath), DirectPath: proto.String(uploadedFile.DirectPath),
Caption: proto.String(request.Caption), Caption: proto.String(request.Caption),
}} }}
if request.IsForwarded {
msg.DocumentMessage.ContextInfo = &waE2E.ContextInfo{
IsForwarded: proto.Bool(true),
ForwardingScore: proto.Uint32(100),
}
}
caption := "📄 Document" caption := "📄 Document"
if request.Caption != "" { if request.Caption != "" {
caption = "📄 " + request.Caption caption = "📄 " + request.Caption
@ -371,6 +391,14 @@ func (service serviceSend) SendVideo(ctx context.Context, request domainSend.Vid
ThumbnailSHA256: dataWaThumbnail, ThumbnailSHA256: dataWaThumbnail,
ThumbnailDirectPath: proto.String(uploaded.DirectPath), ThumbnailDirectPath: proto.String(uploaded.DirectPath),
}} }}
if request.IsForwarded {
msg.VideoMessage.ContextInfo = &waE2E.ContextInfo{
IsForwarded: proto.Bool(true),
ForwardingScore: proto.Uint32(100),
}
}
caption := "🎥 Video" caption := "🎥 Video"
if request.Caption != "" { if request.Caption != "" {
caption = "🎥 " + request.Caption caption = "🎥 " + request.Caption
@ -408,6 +436,13 @@ func (service serviceSend) SendContact(ctx context.Context, request domainSend.C
Vcard: proto.String(msgVCard), Vcard: proto.String(msgVCard),
}} }}
if request.IsForwarded {
msg.ContactMessage.ContextInfo = &waE2E.ContextInfo{
IsForwarded: proto.Bool(true),
ForwardingScore: proto.Uint32(100),
}
}
content := "👤 " + request.ContactName content := "👤 " + request.ContactName
ts, err := service.wrapSendMessage(ctx, dataWaRecipient, msg, content) ts, err := service.wrapSendMessage(ctx, dataWaRecipient, msg, content)
@ -451,6 +486,13 @@ func (service serviceSend) SendLink(ctx context.Context, request domainSend.Link
JPEGThumbnail: metadata.ImageThumb, JPEGThumbnail: metadata.ImageThumb,
}} }}
if request.IsForwarded {
msg.ExtendedTextMessage.ContextInfo = &waE2E.ContextInfo{
IsForwarded: proto.Bool(true),
ForwardingScore: proto.Uint32(100),
}
}
// If we have a thumbnail image, upload it to WhatsApp's servers // If we have a thumbnail image, upload it to WhatsApp's servers
if len(metadata.ImageThumb) > 0 && metadata.Height != nil && metadata.Width != nil { if len(metadata.ImageThumb) > 0 && metadata.Height != nil && metadata.Width != nil {
uploadedThumb, err := service.uploadMedia(ctx, whatsmeow.MediaLinkThumbnail, metadata.ImageThumb, dataWaRecipient) uploadedThumb, err := service.uploadMedia(ctx, whatsmeow.MediaLinkThumbnail, metadata.ImageThumb, dataWaRecipient)
@ -499,6 +541,13 @@ func (service serviceSend) SendLocation(ctx context.Context, request domainSend.
}, },
} }
if request.IsForwarded {
msg.LocationMessage.ContextInfo = &waE2E.ContextInfo{
IsForwarded: proto.Bool(true),
ForwardingScore: proto.Uint32(100),
}
}
content := "📍 " + request.Latitude + ", " + request.Longitude content := "📍 " + request.Latitude + ", " + request.Longitude
// Send WhatsApp Message Proto // Send WhatsApp Message Proto
@ -543,6 +592,13 @@ func (service serviceSend) SendAudio(ctx context.Context, request domainSend.Aud
}, },
} }
if request.IsForwarded {
msg.AudioMessage.ContextInfo = &waE2E.ContextInfo{
IsForwarded: proto.Bool(true),
ForwardingScore: proto.Uint32(100),
}
}
content := "🎵 Audio" content := "🎵 Audio"
ts, err := service.wrapSendMessage(ctx, dataWaRecipient, msg, content) ts, err := service.wrapSendMessage(ctx, dataWaRecipient, msg, content)
@ -567,7 +623,9 @@ func (service serviceSend) SendPoll(ctx context.Context, request domainSend.Poll
content := "📊 " + request.Question content := "📊 " + request.Question
ts, err := service.wrapSendMessage(ctx, dataWaRecipient, service.WaCli.BuildPollCreation(request.Question, request.Options, request.MaxAnswer), content)
msg := service.WaCli.BuildPollCreation(request.Question, request.Options, request.MaxAnswer)
ts, err := service.wrapSendMessage(ctx, dataWaRecipient, msg, content)
if err != nil { if err != nil {
return response, err return response, err
} }

14
src/views/components/SendAudio.js

@ -10,7 +10,8 @@ export default {
phone: '', phone: '',
type: window.TYPEUSER, type: window.TYPEUSER,
loading: false, loading: false,
selectedFileName: null
selectedFileName: null,
is_forwarded: false
} }
}, },
computed: { computed: {
@ -27,7 +28,7 @@ export default {
}).modal('show'); }).modal('show');
}, },
isValidForm() { isValidForm() {
if (this.type !== window.TYPESTATUS && !this.phone.trim()) {
if (this.type !== window.TYPEUSER && !this.phone.trim()) {
return false; return false;
} }
@ -55,6 +56,7 @@ export default {
try { try {
let payload = new FormData(); let payload = new FormData();
payload.append("phone", this.phone_id) payload.append("phone", this.phone_id)
payload.append("is_forwarded", this.is_forwarded)
payload.append("audio", $("#file_audio")[0].files[0]) payload.append("audio", $("#file_audio")[0].files[0])
const response = await window.http.post(`/send/audio`, payload) const response = await window.http.post(`/send/audio`, payload)
this.handleReset(); this.handleReset();
@ -71,6 +73,7 @@ export default {
handleReset() { handleReset() {
this.phone = ''; this.phone = '';
this.type = window.TYPEUSER; this.type = window.TYPEUSER;
this.is_forwarded = false;
$("#file_audio").val(''); $("#file_audio").val('');
this.selectedFileName = null; this.selectedFileName = null;
}, },
@ -101,6 +104,13 @@ export default {
<div class="content"> <div class="content">
<form class="ui form"> <form class="ui form">
<FormRecipient v-model:type="type" v-model:phone="phone"/> <FormRecipient v-model:type="type" v-model:phone="phone"/>
<div class="field">
<label>Is Forwarded</label>
<div class="ui toggle checkbox">
<input type="checkbox" aria-label="is forwarded" v-model="is_forwarded">
<label>Mark audio as forwarded</label>
</div>
</div>
<div class="field" style="padding-bottom: 30px"> <div class="field" style="padding-bottom: 30px">
<label>Audio</label> <label>Audio</label>
<input type="file" style="display: none" accept="audio/*" id="file_audio" @change="handleFileChange"/> <input type="file" style="display: none" accept="audio/*" id="file_audio" @change="handleFileChange"/>

20
src/views/components/SendContact.js

@ -12,6 +12,7 @@ export default {
card_name: '', card_name: '',
card_phone: '', card_phone: '',
loading: false, loading: false,
is_forwarded: false
} }
}, },
computed: { computed: {
@ -27,6 +28,9 @@ export default {
} }
}).modal('show'); }).modal('show');
}, },
isShowAttributes() {
return this.type !== window.TYPESTATUS;
},
isValidForm() { isValidForm() {
if (this.type !== window.TYPESTATUS && !this.phone.trim()) { if (this.type !== window.TYPESTATUS && !this.phone.trim()) {
return false; return false;
@ -44,18 +48,15 @@ export default {
}, },
async handleSubmit() { async handleSubmit() {
try { try {
this.loading = true;
let response = await this.submitApi() let response = await this.submitApi()
showSuccessInfo(response) showSuccessInfo(response)
$('#modalSendContact').modal('hide'); $('#modalSendContact').modal('hide');
} catch (err) { } catch (err) {
showErrorInfo(err) showErrorInfo(err)
} finally {
this.loading = false;
} }
}, },
async submitApi() { async submitApi() {
if (!this.isValidForm() || this.loading) {
if (!this.isValidForm()) {
return; return;
} }
@ -64,7 +65,8 @@ export default {
const payload = { const payload = {
phone: this.phone_id, phone: this.phone_id,
contact_name: this.card_name, contact_name: this.card_name,
contact_phone: this.card_phone
contact_phone: this.card_phone,
is_forwarded: this.is_forwarded
} }
let response = await window.http.post(`/send/contact`, payload) let response = await window.http.post(`/send/contact`, payload)
this.handleReset(); this.handleReset();
@ -83,6 +85,7 @@ export default {
this.card_name = ''; this.card_name = '';
this.card_phone = ''; this.card_phone = '';
this.type = window.TYPEUSER; this.type = window.TYPEUSER;
this.is_forwarded = false;
}, },
}, },
template: ` template: `
@ -116,6 +119,13 @@ export default {
<input v-model="card_phone" type="text" placeholder="Please enter contact phone" <input v-model="card_phone" type="text" placeholder="Please enter contact phone"
aria-label="contact phone"> aria-label="contact phone">
</div> </div>
<div class="field" v-if="isShowAttributes()">
<label>Is Forwarded</label>
<div class="ui toggle checkbox">
<input type="checkbox" aria-label="is forwarded" v-model="is_forwarded">
<label>Mark contact as forwarded</label>
</div>
</div>
</form> </form>
</div> </div>
<div class="actions"> <div class="actions">

15
src/views/components/SendFile.js

@ -17,7 +17,8 @@ export default {
type: window.TYPEUSER, type: window.TYPEUSER,
phone: '', phone: '',
loading: false, loading: false,
selectedFileName: null
selectedFileName: null,
is_forwarded: false
} }
}, },
computed: { computed: {
@ -33,6 +34,9 @@ export default {
} }
}).modal('show'); }).modal('show');
}, },
isShowAttributes() {
return this.type !== window.TYPESTATUS;
},
isValidForm() { isValidForm() {
if (this.type !== window.TYPESTATUS && !this.phone.trim()) { if (this.type !== window.TYPESTATUS && !this.phone.trim()) {
return false; return false;
@ -63,6 +67,7 @@ export default {
let payload = new FormData(); let payload = new FormData();
payload.append("caption", this.caption) payload.append("caption", this.caption)
payload.append("phone", this.phone_id) payload.append("phone", this.phone_id)
payload.append("is_forwarded", this.is_forwarded)
payload.append("file", $("#file_file")[0].files[0]) payload.append("file", $("#file_file")[0].files[0])
let response = await window.http.post(`/send/file`, payload) let response = await window.http.post(`/send/file`, payload)
this.handleReset(); this.handleReset();
@ -81,6 +86,7 @@ export default {
this.phone = ''; this.phone = '';
this.type = window.TYPEUSER; this.type = window.TYPEUSER;
this.selectedFileName = null; this.selectedFileName = null;
this.is_forwarded = false;
$("#file_file").val(''); $("#file_file").val('');
}, },
handleFileChange(event) { handleFileChange(event) {
@ -117,6 +123,13 @@ export default {
<textarea v-model="caption" placeholder="Type some caption (optional)..." <textarea v-model="caption" placeholder="Type some caption (optional)..."
aria-label="caption"></textarea> aria-label="caption"></textarea>
</div> </div>
<div class="field" v-if="isShowAttributes()">
<label>Is Forwarded</label>
<div class="ui toggle checkbox">
<input type="checkbox" aria-label="is forwarded" v-model="is_forwarded">
<label>Mark file as forwarded</label>
</div>
</div>
<div class="field" style="padding-bottom: 30px"> <div class="field" style="padding-bottom: 30px">
<label>File</label> <label>File</label>
<input type="file" style="display: none" id="file_file" @change="handleFileChange"> <input type="file" style="display: none" id="file_file" @change="handleFileChange">

20
src/views/components/SendImage.js

@ -15,7 +15,8 @@ export default {
loading: false, loading: false,
selected_file: null, selected_file: null,
image_url: null, image_url: null,
preview_url: null
preview_url: null,
is_forwarded: false
} }
}, },
computed: { computed: {
@ -23,6 +24,14 @@ export default {
return this.phone + this.type; return this.phone + this.type;
}, },
}, },
watch: {
view_once(newValue) {
// If view_once is set to true, set is_forwarded to false
if (newValue === true) {
this.is_forwarded = false;
}
}
},
methods: { methods: {
openModal() { openModal() {
$('#modalSendImage').modal({ $('#modalSendImage').modal({
@ -66,6 +75,7 @@ export default {
payload.append("view_once", this.view_once) payload.append("view_once", this.view_once)
payload.append("compress", this.compress) payload.append("compress", this.compress)
payload.append("caption", this.caption) payload.append("caption", this.caption)
payload.append("is_forwarded", this.is_forwarded)
const fileInput = $("#file_image"); const fileInput = $("#file_image");
if (fileInput.length > 0 && fileInput[0].files.length > 0) { if (fileInput.length > 0 && fileInput[0].files.length > 0) {
@ -96,6 +106,7 @@ export default {
this.preview_url = null; this.preview_url = null;
this.selected_file = null; this.selected_file = null;
this.image_url = null; this.image_url = null;
this.is_forwarded = false;
$("#file_image").val(''); $("#file_image").val('');
}, },
handleImageChange(event) { handleImageChange(event) {
@ -155,6 +166,13 @@ export default {
<label>Check for compressing image to smaller size</label> <label>Check for compressing image to smaller size</label>
</div> </div>
</div> </div>
<div class="field" v-if="isShowAttributes() && !view_once">
<label>Is Forwarded</label>
<div class="ui toggle checkbox">
<input type="checkbox" aria-label="is forwarded" v-model="is_forwarded">
<label>Mark image as forwarded</label>
</div>
</div>
<div class="field"> <div class="field">
<label>Image URL</label> <label>Image URL</label>
<input type="text" v-model="image_url" placeholder="https://example.com/image.jpg" <input type="text" v-model="image_url" placeholder="https://example.com/image.jpg"

10
src/views/components/SendLink.js

@ -13,6 +13,7 @@ export default {
caption: '', caption: '',
reply_message_id: '', reply_message_id: '',
loading: false, loading: false,
is_forwarded: false
} }
}, },
computed: { computed: {
@ -63,6 +64,7 @@ export default {
phone: this.phone_id, phone: this.phone_id,
link: this.link.trim(), link: this.link.trim(),
caption: this.caption.trim(), caption: this.caption.trim(),
is_forwarded: this.is_forwarded
}; };
if (this.reply_message_id !== '') { if (this.reply_message_id !== '') {
payload.reply_message_id = this.reply_message_id; payload.reply_message_id = this.reply_message_id;
@ -85,6 +87,7 @@ export default {
this.link = ''; this.link = '';
this.caption = ''; this.caption = '';
this.reply_message_id = ''; this.reply_message_id = '';
this.is_forwarded = false;
}, },
}, },
template: ` template: `
@ -123,6 +126,13 @@ export default {
<textarea v-model="caption" placeholder="Hello this is caption" <textarea v-model="caption" placeholder="Hello this is caption"
aria-label="caption"></textarea> aria-label="caption"></textarea>
</div> </div>
<div class="field" v-if="isShowReplyId()">
<label>Is Forwarded</label>
<div class="ui toggle checkbox">
<input type="checkbox" aria-label="is forwarded" v-model="is_forwarded">
<label>Mark link as forwarded</label>
</div>
</div>
</form> </form>
</div> </div>
<div class="actions"> <div class="actions">

15
src/views/components/SendLocation.js

@ -12,6 +12,7 @@ export default {
latitude: '', latitude: '',
longitude: '', longitude: '',
loading: false, loading: false,
is_forwarded: false
} }
}, },
computed: { computed: {
@ -43,6 +44,9 @@ export default {
} }
}).modal('show'); }).modal('show');
}, },
isShowAttributes() {
return this.type !== window.TYPESTATUS;
},
async handleSubmit() { async handleSubmit() {
try { try {
let response = await this.submitApi() let response = await this.submitApi()
@ -58,7 +62,8 @@ export default {
const payload = { const payload = {
phone: this.phone_id, phone: this.phone_id,
latitude: this.latitude, latitude: this.latitude,
longitude: this.longitude
longitude: this.longitude,
is_forwarded: this.is_forwarded
}; };
const response = await window.http.post(`/send/location`, payload); const response = await window.http.post(`/send/location`, payload);
@ -78,6 +83,7 @@ export default {
this.latitude = ''; this.latitude = '';
this.longitude = ''; this.longitude = '';
this.type = window.TYPEUSER; this.type = window.TYPEUSER;
this.is_forwarded = false;
}, },
}, },
template: ` template: `
@ -111,6 +117,13 @@ export default {
<input v-model="longitude" type="text" placeholder="Please enter longitude (-180 to 180)" <input v-model="longitude" type="text" placeholder="Please enter longitude (-180 to 180)"
aria-label="longitude"> aria-label="longitude">
</div> </div>
<div class="field" v-if="isShowAttributes()">
<label>Is Forwarded</label>
<div class="ui toggle checkbox">
<input type="checkbox" aria-label="is forwarded" v-model="is_forwarded">
<label>Mark location as forwarded</label>
</div>
</div>
</form> </form>
</div> </div>
<div class="actions"> <div class="actions">

10
src/views/components/SendMessage.js

@ -11,6 +11,7 @@ export default {
phone: '', phone: '',
text: '', text: '',
reply_message_id: '', reply_message_id: '',
is_forwarded: false,
loading: false, loading: false,
} }
}, },
@ -58,6 +59,7 @@ export default {
const payload = { const payload = {
phone: this.phone_id, phone: this.phone_id,
message: this.text.trim(), message: this.text.trim(),
is_forwarded: this.is_forwarded
}; };
if (this.reply_message_id !== '') { if (this.reply_message_id !== '') {
payload.reply_message_id = this.reply_message_id; payload.reply_message_id = this.reply_message_id;
@ -79,6 +81,7 @@ export default {
this.phone = ''; this.phone = '';
this.text = ''; this.text = '';
this.reply_message_id = ''; this.reply_message_id = '';
this.is_forwarded = false;
}, },
}, },
template: ` template: `
@ -112,6 +115,13 @@ export default {
<textarea v-model="text" placeholder="Hello this is message text" <textarea v-model="text" placeholder="Hello this is message text"
aria-label="message"></textarea> aria-label="message"></textarea>
</div> </div>
<div class="field" v-if="isShowReplyId()">
<label>Is Forwarded</label>
<div class="ui toggle checkbox">
<input type="checkbox" aria-label="is forwarded" v-model="is_forwarded">
<label>Mark message as forwarded</label>
</div>
</div>
</form> </form>
</div> </div>
<div class="actions"> <div class="actions">

18
src/views/components/SendVideo.js

@ -20,6 +20,7 @@ export default {
phone: '', phone: '',
loading: false, loading: false,
selectedFileName: null, selectedFileName: null,
is_forwarded: false
} }
}, },
computed: { computed: {
@ -27,6 +28,14 @@ export default {
return this.phone + this.type; return this.phone + this.type;
}, },
}, },
watch: {
view_once(newValue) {
// If view_once is set to true, set is_forwarded to false
if (newValue === true) {
this.is_forwarded = false;
}
}
},
methods: { methods: {
openModal() { openModal() {
$('#modalSendVideo').modal({ $('#modalSendVideo').modal({
@ -81,6 +90,7 @@ export default {
payload.append("caption", this.caption.trim()) payload.append("caption", this.caption.trim())
payload.append("view_once", this.view_once) payload.append("view_once", this.view_once)
payload.append("compress", this.compress) payload.append("compress", this.compress)
payload.append("is_forwarded", this.is_forwarded)
payload.append('video', $("#file_video")[0].files[0]) payload.append('video', $("#file_video")[0].files[0])
let response = await window.http.post(`/send/video`, payload) let response = await window.http.post(`/send/video`, payload)
this.handleReset(); this.handleReset();
@ -100,6 +110,7 @@ export default {
this.compress = false; this.compress = false;
this.phone = ''; this.phone = '';
this.selectedFileName = null; this.selectedFileName = null;
this.is_forwarded = false;
$("#file_video").val(''); $("#file_video").val('');
}, },
handleFileChange(event) { handleFileChange(event) {
@ -152,6 +163,13 @@ export default {
<label>Check for compressing video to smaller size</label> <label>Check for compressing video to smaller size</label>
</div> </div>
</div> </div>
<div class="field" v-if="isShowAttributes() && !view_once">
<label>Is Forwarded</label>
<div class="ui toggle checkbox">
<input type="checkbox" aria-label="is forwarded" v-model="is_forwarded">
<label>Mark video as forwarded</label>
</div>
</div>
<div class="field" style="padding-bottom: 30px"> <div class="field" style="padding-bottom: 30px">
<label>Video</label> <label>Video</label>
<input type="file" style="display: none" accept="video/*" id="file_video" @change="handleFileChange"> <input type="file" style="display: none" accept="video/*" id="file_video" @change="handleFileChange">

Loading…
Cancel
Save