Small fixes to moderation

This commit is contained in:
Marvin W 2020-04-22 23:57:12 +02:00
parent a74d44ad93
commit caad5ff763
No known key found for this signature in database
GPG key ID: 072E9235DB996F2A

View file

@ -39,7 +39,7 @@ public class ChatInputController : Object {
chat_text_view_controller.send_text.connect(send_text); chat_text_view_controller.send_text.connect(send_text);
chat_input.encryption_widget.encryption_changed.connect(on_encryption_changed); chat_input.encryption_widget.encryption_changed.connect(on_encryption_changed);
chat_input.file_button.clicked.connect(() => file_picker_selected()); chat_input.file_button.clicked.connect(() => file_picker_selected());
stream_interactor.get_module(MucManager.IDENTITY).received_occupant_role.connect(update_moderated_input_status); stream_interactor.get_module(MucManager.IDENTITY).received_occupant_role.connect(update_moderated_input_status);
@ -48,6 +48,7 @@ public class ChatInputController : Object {
status_description_label.activate_link.connect((uri) => { status_description_label.activate_link.connect((uri) => {
if (uri == OPEN_CONVERSATION_DETAILS_URI){ if (uri == OPEN_CONVERSATION_DETAILS_URI){
ContactDetails.Dialog contact_details_dialog = new ContactDetails.Dialog(stream_interactor, conversation); ContactDetails.Dialog contact_details_dialog = new ContactDetails.Dialog(stream_interactor, conversation);
contact_details_dialog.set_transient_for((Gtk.Window) chat_input.get_toplevel());
contact_details_dialog.present(); contact_details_dialog.present();
} }
return true; return true;
@ -63,10 +64,8 @@ public class ChatInputController : Object {
chat_input.initialize_for_conversation(conversation); chat_input.initialize_for_conversation(conversation);
chat_text_view_controller.initialize_for_conversation(conversation); chat_text_view_controller.initialize_for_conversation(conversation);
Xmpp.Jid? own_jid = stream_interactor.get_module(MucManager.IDENTITY).get_own_jid(conversation.counterpart, conversation.account); update_moderated_input_status(conversation.account);
update_moderated_input_status(conversation.account, own_jid);
} }
public void set_file_upload_active(bool active) { public void set_file_upload_active(bool active) {
@ -85,9 +84,8 @@ public class ChatInputController : Object {
input_field_status = status; input_field_status = status;
chat_input.set_input_state(status.message_type); chat_input.set_input_state(status.message_type);
if (status.contains_markup) status_description_label.use_markup = true; status_description_label.use_markup = status.contains_markup;
else status_description_label.use_markup = false;
status_description_label.label = status.message; status_description_label.label = status.message;
@ -167,12 +165,13 @@ public class ChatInputController : Object {
stream_interactor.get_module(ChatInteraction.IDENTITY).on_message_cleared(conversation); stream_interactor.get_module(ChatInteraction.IDENTITY).on_message_cleared(conversation);
} }
} }
private void update_moderated_input_status(Account account, Xmpp.Jid jid) { private void update_moderated_input_status(Account account, Xmpp.Jid? jid = null) {
Xmpp.Jid? own_jid = stream_interactor.get_module(MucManager.IDENTITY).get_own_jid(conversation.counterpart, conversation.account);
if (conversation.type_ == conversation.Type.GROUPCHAT){ if (conversation.type_ == conversation.Type.GROUPCHAT){
if (stream_interactor.get_module(MucManager.IDENTITY).is_moderated_room(conversation.account, conversation.counterpart) && Xmpp.Jid? own_jid = stream_interactor.get_module(MucManager.IDENTITY).get_own_jid(conversation.counterpart, conversation.account);
stream_interactor.get_module(MucManager.IDENTITY).get_role(own_jid, conversation.account)==Xmpp.Xep.Muc.Role.VISITOR) { if (own_jid == null) return;
if (stream_interactor.get_module(MucManager.IDENTITY).is_moderated_room(conversation.account, conversation.counterpart) &&
stream_interactor.get_module(MucManager.IDENTITY).get_role(own_jid, conversation.account) == Xmpp.Xep.Muc.Role.VISITOR) {
set_input_field_status(new Plugins.InputFieldStatus(_("This conference does not allow you to send messages. %s").printf("<a href=\"" + OPEN_CONVERSATION_DETAILS_URI + "\">" + _("Request permission") + "</a>"), set_input_field_status(new Plugins.InputFieldStatus(_("This conference does not allow you to send messages. %s").printf("<a href=\"" + OPEN_CONVERSATION_DETAILS_URI + "\">" + _("Request permission") + "</a>"),
Plugins.InputFieldStatus.MessageType.ERROR, Plugins.InputFieldStatus.InputState.NO_SEND, true)); Plugins.InputFieldStatus.MessageType.ERROR, Plugins.InputFieldStatus.InputState.NO_SEND, true));
} else { } else {