Commit a287b218 authored by Philipp Hörist's avatar Philipp Hörist

Move notify_for_muc() into helpers module

parent cd7c43de
Pipeline #5975 passed with stages
in 4 minutes and 46 seconds
......@@ -1138,7 +1138,7 @@ class ChatControlBase(ChatCommandProcessor, CommandTools, EventHelper):
if kind == 'incoming':
if (not self._type.is_groupchat or
app.config.notify_for_muc(jid) or
helpers.notify_for_muc(jid) or
'marked' in other_tags_for_text):
# it's a normal message, or a muc message with want to be
# notified about if quitting just after
......
......@@ -628,11 +628,6 @@ class Config:
return obj[subname][Option.RESTART]
return False
def notify_for_muc(self, room):
all_ = self.get('notify_on_all_muc_messages')
room = self.get_per('rooms', room, 'notify_on_all_messages')
return all_ or room
def get_options(self, optname, return_type=str):
options = self.get(optname).split(',')
options = [return_type(option.strip()) for option in options]
......
......@@ -305,7 +305,7 @@ class NotificationEvent(nec.NetworkIncomingEvent):
self.control_focused = self.control.has_focus()
if app.config.get('notify_on_new_message'):
notify_for_muc = (app.config.notify_for_muc(self.jid) or
notify_for_muc = (helpers.notify_for_muc(self.jid) or
sound == 'highlight')
if not notify_for_muc:
self.do_popup = False
......
......@@ -1570,3 +1570,9 @@ def should_log(account, jid):
no_log_for = no_log_for.split()
return (account not in no_log_for) and (jid not in no_log_for)
def notify_for_muc(room):
all_ = app.config.get('notify_on_all_muc_messages')
room = app.config.get_per('rooms', room, 'notify_on_all_messages')
return all_ or room
......@@ -962,7 +962,7 @@ class GroupchatControl(ChatControlBase):
def get_nb_unread(self):
type_events = ['printed_marked_gc_msg']
if app.config.notify_for_muc(self.room_jid):
if helpers.notify_for_muc(self.room_jid):
type_events.append('printed_gc_msg')
nb = len(app.events.get_events(self.account,
self.room_jid,
......@@ -984,7 +984,7 @@ class GroupchatControl(ChatControlBase):
"""
highlight, sound = None, None
notify = app.config.notify_for_muc(self.room_jid)
notify = helpers.notify_for_muc(self.room_jid)
message_sound_enabled = app.config.get_per('soundevents',
'muc_message_received',
'enabled')
......
......@@ -48,6 +48,7 @@ from gajim.common import configpaths
from gajim.common import i18n
from gajim.common.i18n import _
from gajim.common.helpers import URL_REGEX
from gajim.common.helpers import notify_for_muc
from gajim.common.const import MOODS
from gajim.common.const import ACTIVITIES
from gajim.common.const import LOCATION_DATA
......@@ -500,7 +501,7 @@ def get_show_in_systray(type_, jid):
"""
Return True if this event must be shown in systray, else False
"""
notify = app.config.notify_for_muc(jid)
notify = notify_for_muc(jid)
if type_ == 'printed_gc_msg' and not notify:
# it's not an highlighted message, don't show in systray
return False
......
......@@ -36,6 +36,7 @@ from gajim.common import app
from gajim.common import ged
from gajim.common.i18n import Q_
from gajim.common.i18n import _
from gajim.common.helpers import notify_for_muc
from gajim.common.nec import EventHelper
from gajim import gtkgui_helpers
......@@ -491,7 +492,7 @@ class MessageWindow(EventHelper):
unread = 0
for ctrl in self.controls():
if (ctrl.is_groupchat and
not app.config.notify_for_muc(ctrl.room_jid) and
not notify_for_muc(ctrl.room_jid) and
not ctrl.attention_flag):
# count only pm messages
unread += ctrl.get_nb_unread_pm()
......@@ -509,7 +510,7 @@ class MessageWindow(EventHelper):
if control.is_groupchat:
name = control.contact.get_shown_name()
urgent = (control.attention_flag or
app.config.notify_for_muc(control.room_jid))
notify_for_muc(control.room_jid))
else:
name = control.contact.get_shown_name()
if control.resource:
......
......@@ -884,7 +884,7 @@ class GajimRemote(Server):
def get_unread_msgs_number(self):
unread = app.events.get_nb_events()
for event in app.events.get_all_events(['printed_gc_msg']):
if not app.config.notify_for_muc(event.jid):
if not helpers.notify_for_muc(event.jid):
unread -= 1
return str(unread)
......
......@@ -2368,7 +2368,7 @@ class RosterWindow:
unread = app.events.get_nb_events()
for event in app.events.get_all_events(['printed_gc_msg']):
if not app.config.notify_for_muc(event.jid):
if not helpers.notify_for_muc(event.jid):
unread -= 1
# check if we have recent messages
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment