3333 placeholder =" Enter your message here"
3434 label =" Content"
3535 ></v-textarea >
36+ <v-textarea
37+ v-model =" formAttachments"
38+ :error =" errors.has('attachments')"
39+ :error-messages =" errors.get('attachments')"
40+ :disabled =" sending"
41+ outlined
42+ rows =" 2"
43+ placeholder =" https://example.com/image.jpg, https://example.com/video.mp4"
44+ label =" Attachment URLs (comma separated, optional)"
45+ ></v-textarea >
3646 <v-btn
3747 type =" submit"
3848 class =" primary"
@@ -72,6 +82,7 @@ export default {
7282 sending: false ,
7383 formPhoneNumber: ' ' ,
7484 formContent: ' ' ,
85+ formAttachments: ' ' ,
7586 errors: new Map (),
7687 }
7788 },
@@ -85,11 +96,31 @@ export default {
8596 sendMessage () {
8697 this .errors = new Map ()
8798 this .sending = true
99+
100+ const attachments = []
101+ if (this .formAttachments .trim () !== ' ' ) {
102+ const urls = this .formAttachments .split (' ,' )
103+ for (const u of urls) {
104+ const cleanUrl = u .trim ()
105+ if (! cleanUrl) continue
106+
107+ let contentType = ' application/octet-stream'
108+ const lowerUrl = cleanUrl .toLowerCase ()
109+ if (lowerUrl .endsWith (' .jpg' ) || lowerUrl .endsWith (' .jpeg' )) contentType = ' image/jpeg'
110+ else if (lowerUrl .endsWith (' .png' )) contentType = ' image/png'
111+ else if (lowerUrl .endsWith (' .gif' )) contentType = ' image/gif'
112+ else if (lowerUrl .endsWith (' .mp4' )) contentType = ' video/mp4'
113+
114+ attachments .push ({ content_type: contentType, url: cleanUrl })
115+ }
116+ }
117+
88118 axios
89119 .post (' /v1/messages/send' , {
90120 to: this .formPhoneNumber ,
91121 from: this .$store .getters .getOwner ,
92122 content: this .formContent ,
123+ attachments: attachments,
93124 sim: this .simSelected .code ,
94125 })
95126 .then (() => {
@@ -113,6 +144,9 @@ export default {
113144 ),
114145 )
115146 }
147+ if (response .data .data .attachments ) {
148+ errors .set (' attachments' , response .data .data .attachments )
149+ }
116150 if (response .data .data .from ) {
117151 this .$store .dispatch (' addNotification' , {
118152 message: response .data .data .from [0 ],
0 commit comments