Make ban user; handle server request

pull/652/head
Beaudan Brown 5 years ago
parent a3d171884d
commit 2bbc1ecf63

@ -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;

@ -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) {

Loading…
Cancel
Save