summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorCyrille Bollu <cyrpub@bollu.be>2019-09-11 15:00:32 +0200
committerCyrille Bollu <cyrpub@bollu.be>2019-09-25 14:47:21 +0200
commitfe3f3e39a38c0321e37256aac3f351e51ffde7ce (patch)
treec1c89c94097781be429ec0704fb96e586a1d9de9 /src
parent94e366c259266380bc3838ceb50348087d030c02 (diff)
Makes sure there are valid recipients when posting to a direct message
Signed-off-by: Cyrille Bollu <cyrpub@bollu.be>
Diffstat (limited to 'src')
-rw-r--r--src/components/Composer.vue15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/components/Composer.vue b/src/components/Composer.vue
index 96d88ce1..2135a45b 100644
--- a/src/components/Composer.vue
+++ b/src/components/Composer.vue
@@ -743,7 +743,7 @@ export default {
let contentHtml = element.innerHTML
let to = []
let hashtags = []
- const mentionRegex = /@(([\w-_.]+)(@[\w-.]+)?)/g
+ const mentionRegex = /<span class="mention"[^>]+><a[^>]+><img[^>]+>@([\w-_.]+@[\w-.]+)/g
let match = null
do {
match = mentionRegex.exec(contentHtml)
@@ -783,8 +783,18 @@ export default {
this.$refs.composerInput.oninput(event)
},
createPost(event) {
+
+ let postData = this.getPostData()
+
+ // Abort if the post is a direct message and no valid mentions were found
+ if (this.type === 'direct' && postData.to.length === 0) {
+ OC.Notification.showTemporary(t('social', 'Error while trying to post your message: Could not find any valid recipients.'), { type: 'error' })
+ return
+ }
+
+ // Post toot
this.loading = true
- this.$store.dispatch('post', this.getPostData()).then((response) => {
+ this.$store.dispatch('post', postData).then((response) => {
this.loading = false
this.replyTo = null
this.post = ''
@@ -793,6 +803,7 @@ export default {
this.miniatures = []
this.$store.dispatch('refreshTimeline')
})
+
},
remoteSearchAccounts(text) {
return axios.get(OC.generateUrl('apps/social/api/v1/global/accounts/search?search=' + text))