diff options
| author | frosty <gabriel@bwaaa.monster> | 2026-08-18 12:08:05 -0400 |
|---|---|---|
| committer | frosty <gabriel@bwaaa.monster> | 2026-08-18 12:08:05 -0400 |
| commit | 35108fe1936a280318ad8935b89277f049a6428e (patch) | |
| tree | f4f82f13eba7c823457ce5b4a5b62b21a178c628 /libdino/src/service | |
| parent | 7cf1a12faa2c7781f6277c75702f62f1404752a2 (diff) | |
Split notification settings
Diffstat (limited to 'libdino/src/service')
| -rw-r--r-- | libdino/src/service/notification_events.vala | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/libdino/src/service/notification_events.vala b/libdino/src/service/notification_events.vala index 1830bab4..d22d54a4 100644 --- a/libdino/src/service/notification_events.vala +++ b/libdino/src/service/notification_events.vala @@ -53,9 +53,6 @@ public class NotificationEvents : StreamInteractionModule, Object { if (item.id == conversation.read_up_to_item) return; if (stream_interactor.get_module(ChatInteraction.IDENTITY).is_active_focus()) return; - Conversation.NotifySetting notify = conversation.get_notification_setting(stream_interactor); - if (notify == Conversation.NotifySetting.OFF) return; - string conversation_display_name = get_conversation_display_name(stream_interactor, conversation, null); string? participant_display_name = null; if (conversation.type_ == Conversation.Type.GROUPCHAT) { @@ -64,13 +61,16 @@ public class NotificationEvents : StreamInteractionModule, Object { switch (item.type_) { case MessageItem.TYPE: + Conversation.NotifySetting message_notify = conversation.get_notification_setting(stream_interactor); + if (message_notify == Conversation.NotifySetting.OFF) return; + Message message = ((MessageItem) item).message; if (message.direction == Message.DIRECTION_SENT) return; DateTime? message_time = message.time; if (message_time != null && message_time.compare(new DateTime.now_utc().add_seconds(-MESSAGE_NOTIFICATION_MAX_AGE_SECONDS)) < 0) return; - if (notify == Conversation.NotifySetting.HIGHLIGHT) { + if (message_notify == Conversation.NotifySetting.HIGHLIGHT) { Jid? nick = stream_interactor.get_module(MucManager.IDENTITY).get_own_jid(conversation.counterpart, conversation.account); if (nick == null) return; @@ -79,21 +79,25 @@ public class NotificationEvents : StreamInteractionModule, Object { } notify_content_item(item, conversation); - if (notify != Conversation.NotifySetting.OFF) { + if (message_notify != Conversation.NotifySetting.OFF) { NotificationProvider notifier = yield notifier.wait_async(); yield notifier.notify_message(message, conversation, conversation_display_name, participant_display_name); } break; case FileItem.TYPE: + Conversation.NotifySetting file_notify = conversation.get_notification_setting_for( + stream_interactor, Application.get_default().settings.notifications_files); + if (file_notify == Conversation.NotifySetting.OFF) return; + FileTransfer file_transfer = ((FileItem) item).file_transfer; bool is_image = file_transfer.content_type != null && file_transfer.content_type.is_image(); // Don't notify on file transfers in a groupchat set to "mention only" - if (notify == Conversation.NotifySetting.HIGHLIGHT) return; + if (file_notify == Conversation.NotifySetting.HIGHLIGHT) return; if (file_transfer.direction == FileTransfer.DIRECTION_SENT) return; notify_content_item(item, conversation); - if (notify != Conversation.NotifySetting.OFF) { + if (file_notify != Conversation.NotifySetting.OFF) { NotificationProvider notifier = yield notifier.wait_async(); yield notifier.notify_file(file_transfer, conversation, is_image, conversation_display_name, participant_display_name); } @@ -105,6 +109,8 @@ public class NotificationEvents : StreamInteractionModule, Object { } private async void on_voice_request_received(Account account, Jid room_jid, Jid from_jid, string nick) { + if (!Application.get_default().settings.notifications_permission_requests) return; + Conversation? conversation = stream_interactor.get_module(ConversationManager.IDENTITY).get_conversation(room_jid, account, Conversation.Type.GROUPCHAT); if (conversation == null) return; @@ -113,6 +119,8 @@ public class NotificationEvents : StreamInteractionModule, Object { } private async void on_received_subscription_request(Jid jid, Account account) { + if (!Application.get_default().settings.notifications_subscription_requests) return; + Conversation conversation = stream_interactor.get_module(ConversationManager.IDENTITY).create_conversation(jid, account, Conversation.Type.CHAT); if (stream_interactor.get_module(ChatInteraction.IDENTITY).is_active_focus(conversation)) return; @@ -121,6 +129,7 @@ public class NotificationEvents : StreamInteractionModule, Object { } private async void on_call_incoming(Call call, CallState call_state, Conversation conversation, bool video, bool multiparty) { + if (!Application.get_default().settings.notifications_calls) return; if (!stream_interactor.get_module(Calls.IDENTITY).can_we_do_calls(call.account)) return; string conversation_display_name = get_conversation_display_name(stream_interactor, conversation, null); @@ -134,6 +143,8 @@ public class NotificationEvents : StreamInteractionModule, Object { } private async void on_invite_received(Account account, Jid room_jid, Jid from_jid, string? password, string? reason) { + if (!Application.get_default().settings.notifications_group_chat_invitations) return; + string inviter_display_name; if (room_jid.equals_bare(from_jid)) { Conversation conversation = new Conversation(room_jid, account, Conversation.Type.GROUPCHAT); @@ -147,6 +158,8 @@ public class NotificationEvents : StreamInteractionModule, Object { } private async void on_connection_error(Account account, ConnectionManager.ConnectionError error) { + if (!Application.get_default().settings.notifications_connection_errors) return; + NotificationProvider notifier = yield notifier.wait_async(); yield notifier.notify_connection_error(account, error); } |
