From 2bbc1ecf63f7f5953956b1d3a60b23b0d46ad951 Mon Sep 17 00:00:00 2001 From: Beaudan Brown Date: Mon, 25 Nov 2019 15:59:13 +1100 Subject: [PATCH] Make ban user; handle server request --- js/models/messages.js | 15 +++++++++++++++ js/modules/loki_app_dot_net_api.js | 12 ++++++++++++ 2 files changed, 27 insertions(+) diff --git a/js/models/messages.js b/js/models/messages.js index 6b5314e33..89bb29d26 100644 --- a/js/models/messages.js +++ b/js/models/messages.js @@ -12,6 +12,7 @@ Whisper, clipboard, libloki, + lokiPublicChatAPI, */ /* eslint-disable more/no-then */ @@ -662,6 +663,7 @@ onSelectMessage: () => this.selectMessage(), onSelectMessageUnchecked: () => this.selectMessageUnchecked(), onCopyPubKey: () => this.copyPubKey(), + onBanUser: () => this.banUser(), onReply: () => this.trigger('reply', this), onRetrySend: () => this.retrySend(), onShowDetail: () => this.trigger('show-message-detail', this), @@ -970,6 +972,19 @@ }); }, + banUser() { + window.Whisper.events.trigger('showConfirmationDialog', { + message: i18n('banUserConfirm'), + onOk: async () => { + const source = this.get('source'); + const conversation = this.getConversation(); + + const channelAPI = await conversation.getPublicSendData(); + await channelAPI.banUser(source); + } + }); + }, + // Select message even if the context menu is shown selectMessageUnchecked() { this.selected = !this.selected; diff --git a/js/modules/loki_app_dot_net_api.js b/js/modules/loki_app_dot_net_api.js index 23c9711af..ac66db441 100644 --- a/js/modules/loki_app_dot_net_api.js +++ b/js/modules/loki_app_dot_net_api.js @@ -545,6 +545,18 @@ class LokiPublicChannelAPI { // TODO: poll for group members here? } + async banUser(pubkey){ + const res = await this.serverRequest( + `loki/v1/moderation/blacklist/@${pubkey}` + ); + + if (res.err || !res.response || !res.response.data) { + if (res.err) { + log.error(`Error ${res.err}`); + } + } + } + stop() { this.running = false; if (this.timers.channel) {