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

@ -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;
@ -64,9 +65,7 @@ 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) {
@ -86,8 +85,7 @@ public class ChatInputController : Object {
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;
@ -168,9 +166,10 @@ public class ChatInputController : Object {
} }
} }
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){
Xmpp.Jid? own_jid = stream_interactor.get_module(MucManager.IDENTITY).get_own_jid(conversation.counterpart, conversation.account);
if (own_jid == null) return;
if (stream_interactor.get_module(MucManager.IDENTITY).is_moderated_room(conversation.account, conversation.counterpart) && 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) { 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>"),