notifications fix

This commit is contained in:
ingvar1995 2017-07-19 19:39:56 +03:00
parent d5d1e616ba
commit 6efb1790bb
2 changed files with 8 additions and 4 deletions

View file

@ -384,13 +384,14 @@ def group_invite(tox, friend_number, gc_type, data, length, user_data):
bytes(data[:length])) bytes(data[:length]))
def show_gc_notification(window, tray, message, group_number): def show_gc_notification(window, tray, message, group_number, peer_number):
profile = Profile.get_instance() profile = Profile.get_instance()
settings = Settings.get_instance() settings = Settings.get_instance()
chat = profile.get_group_by_number(group_number) chat = profile.get_group_by_number(group_number)
peer_name = chat.get_peer_name(peer_number)
if not window.isActiveWindow() and (profile.name in message or settings['group_notifications']): if not window.isActiveWindow() and (profile.name in message or settings['group_notifications']):
if settings['notifications'] and profile.status != TOX_USER_STATUS['BUSY'] and not settings.locked: if settings['notifications'] and profile.status != TOX_USER_STATUS['BUSY'] and not settings.locked:
invoke_in_main_thread(tray_notification, chat.name, message, tray, window) invoke_in_main_thread(tray_notification, chat.name + ' ' + peer_name, message, tray, window)
if settings['sound_notifications'] and profile.status != TOX_USER_STATUS['BUSY']: if settings['sound_notifications'] and profile.status != TOX_USER_STATUS['BUSY']:
sound_notification(SOUND_NOTIFICATION['MESSAGE']) sound_notification(SOUND_NOTIFICATION['MESSAGE'])
invoke_in_main_thread(tray.setIcon, QtGui.QIcon(curr_directory() + '/images/icon_new_messages.png')) invoke_in_main_thread(tray.setIcon, QtGui.QIcon(curr_directory() + '/images/icon_new_messages.png'))
@ -401,7 +402,7 @@ def group_message(window, tray):
message = str(message[:length], 'utf-8') message = str(message[:length], 'utf-8')
invoke_in_main_thread(Profile.get_instance().new_gc_message, group_number, invoke_in_main_thread(Profile.get_instance().new_gc_message, group_number,
peer_number, TOX_MESSAGE_TYPE['NORMAL'], message) peer_number, TOX_MESSAGE_TYPE['NORMAL'], message)
show_gc_notification(window, tray, message, group_number) show_gc_notification(window, tray, message, group_number, peer_number)
return wrapped return wrapped
@ -410,7 +411,7 @@ def group_action(window, tray):
message = str(message[:length], 'utf-8') message = str(message[:length], 'utf-8')
invoke_in_main_thread(Profile.get_instance().new_gc_message, group_number, invoke_in_main_thread(Profile.get_instance().new_gc_message, group_number,
peer_number, TOX_MESSAGE_TYPE['ACTION'], message) peer_number, TOX_MESSAGE_TYPE['ACTION'], message)
show_gc_notification(window, tray, message, group_number) show_gc_notification(window, tray, message, group_number, peer_number)
return wrapped return wrapped

View file

@ -44,3 +44,6 @@ class GroupChat(contact.Contact):
def get_full_status(self): def get_full_status(self):
names = self.get_names() names = self.get_names()
return '\n'.join(names) return '\n'.join(names)
def get_peer_name(self, peer_number):
return self._tox.group_peername(self._number, peer_number)