From 01a547ef18a52064cc85d1050c60f37bb50bd028 Mon Sep 17 00:00:00 2001 From: Miquel Lionel Date: Sun, 8 Oct 2023 17:45:16 +0200 Subject: Allow blocking entire domain from conversation details - the block domain option is in a drop down of the block button - when blocking the domain, the "Blocked domain" button appears and block button disappears and vice versa. --- libdino/src/service/blocking_manager.vala | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'libdino') diff --git a/libdino/src/service/blocking_manager.vala b/libdino/src/service/blocking_manager.vala index aa07f990..1c125aac 100644 --- a/libdino/src/service/blocking_manager.vala +++ b/libdino/src/service/blocking_manager.vala @@ -20,19 +20,22 @@ public class BlockingManager : StreamInteractionModule, Object { this.stream_interactor = stream_interactor; } - public bool is_blocked(Account account, Jid jid) { + public bool is_blocked(Account account, Jid jid, bool domainblock = false) { XmppStream stream = stream_interactor.get_stream(account); - return stream != null && stream.get_module(Xmpp.Xep.BlockingCommand.Module.IDENTITY).is_blocked(stream, jid.to_string()); + string jid_str = domainblock ? jid.domainpart.to_string () : jid.to_string(); + return stream != null && stream.get_module(Xmpp.Xep.BlockingCommand.Module.IDENTITY).is_blocked(stream, jid_str); } - public void block(Account account, Jid jid) { + public void block(Account account, Jid jid, bool domainblock = false) { XmppStream stream = stream_interactor.get_stream(account); - stream.get_module(Xmpp.Xep.BlockingCommand.Module.IDENTITY).block(stream, { jid.to_string() }); + string jid_str = domainblock ? jid.domainpart.to_string () : jid.to_string(); + stream.get_module(Xmpp.Xep.BlockingCommand.Module.IDENTITY).block(stream, { jid_str }); } - public void unblock(Account account, Jid jid) { + public void unblock(Account account, Jid jid, bool domainblock = false) { XmppStream stream = stream_interactor.get_stream(account); - stream.get_module(Xmpp.Xep.BlockingCommand.Module.IDENTITY).unblock(stream, { jid.to_string() }); + string jid_str = domainblock ? jid.domainpart.to_string () : jid.to_string(); + stream.get_module(Xmpp.Xep.BlockingCommand.Module.IDENTITY).unblock(stream, { jid_str }); } public bool is_supported(Account account) { -- cgit v1.2.3-54-g00ecf