Skip to content

Commit

Permalink
fix(messageEdit): only allow user to edit their own message (#281)
Browse files Browse the repository at this point in the history
Co-authored-by: Matt Wisniewski <[email protected]>
  • Loading branch information
KemoPaw and Matt Wisniewski authored Nov 18, 2021
1 parent 73493f6 commit 2bb3473
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
8 changes: 6 additions & 2 deletions components/tailored/messaging/message/Message.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@
<UiUsername :username="from" :badge="$mock.users.filter(u => u.name === from)[0].badge" />
<TypographyText :text="$dayjs(message.at).from()" />
</div>
<TailoredMessagingMessageActions v-if="messageHover && !hideActions"
:setReplyChatbarContent="setReplyChatbarContent" :emojiReaction="emojiReaction" :editMessage="editMessage" />
<TailoredMessagingMessageActions
v-if="messageHover && !hideActions"
:setReplyChatbarContent="setReplyChatbarContent"
:emojiReaction="emojiReaction"
:editMessage="editMessage"
:messageOwner="this.$props.message.from" />
<VueMarkdown v-if="!messageEdit && message.type === 'text'" :source="message.payload" class="markdown" />
<UiImage v-else-if="message.type === 'image'" :source="message.payload.url" alt="" />
<!-- Only for video types we can't embed directly without doing something sketchy, like sending it to a server somewhere to extract the HTML5 video-->
Expand Down
5 changes: 3 additions & 2 deletions components/tailored/messaging/message/actions/Actions.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@
<div
class="reply-command has-tooltip has-tooltip-primary"
:data-tooltip="$t('global.edit')"
v-if="messageOwner === accounts.details.textilePubkey"
@click="editMessage"
>
<edit-icon size="1x" :class="'control-icon'"
@click="editMessage" />
<edit-icon size="1x" :class="'control-icon'" />
</div>
<div
class="reply-command has-tooltip has-tooltip-primary"
Expand Down
6 changes: 5 additions & 1 deletion components/tailored/messaging/message/actions/Actions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,13 @@ export default Vue.extend({
type: Function,
default: () => () => {},
},
messageOwner: {
type: String,
required: true,
},
},
computed: {
...mapState(['ui']),
...mapState(['ui', 'accounts'])
},
})
</script>
Expand Down

0 comments on commit 2bb3473

Please sign in to comment.