Update online friends buffer even if chat notifications are disabled

This commit is contained in:
Manuel Cortez 2019-09-15 09:58:22 -05:00
parent 69f8b79fc4
commit 5b3a013766
2 changed files with 13 additions and 14 deletions

View File

@ -9,6 +9,7 @@
### bugfixes ### bugfixes
* Fixed an error that was causing socializer to not update the "Online friends" buffer if chat notifications were disabled.
* Fixed an error that was making Socializer unable to attach audio files from the computer, if the file does not include correct ID3 TAGS. * Fixed an error that was making Socializer unable to attach audio files from the computer, if the file does not include correct ID3 TAGS.
* Fixed a traceback that was being logged when attempting to load an image but cancel the dialog for attaching it. * Fixed a traceback that was being logged when attempting to load an image but cancel the dialog for attaching it.
* Fixed an error that was making Socializer to fail when loading the newsfeed buffer, thus not loading any other buffers. This error was caused due to VK sending a new object type (undocumented for now) representing push subscriptions. The item is ignored by Socializer so it will not break the newsfeed buffer anymore. * Fixed an error that was making Socializer to fail when loading the newsfeed buffer, thus not loading any other buffers. This error was caused due to VK sending a new object type (undocumented for now) representing push subscriptions. The item is ignored by Socializer so it will not break the newsfeed buffer anymore.

View File

@ -443,15 +443,14 @@ class Controller(object):
p = presenters.userProfilePresenter(session=self.session, user_id=person, view=views.userProfileDialog(), interactor=interactors.userProfileInteractor()) p = presenters.userProfilePresenter(session=self.session, user_id=person, view=views.userProfileDialog(), interactor=interactors.userProfileInteractor())
def user_online(self, event): def user_online(self, event):
""" Sends a notification of an user connecting to VK. """ Add user to the online buffer and Send a notification of an user connecting to VK.
@ event vk_api.longpoll.event object: The event sent by the vk_api's longPoll module. @ event vk_api.longpoll.event object: The event sent by the vk_api's longPoll module.
""" """
if self.session.settings["chat"]["notify_online"] == False: if self.session.settings["chat"]["notify_online"] == True:
return user_name = self.session.get_user(event.user_id)
user_name = self.session.get_user(event.user_id) msg = _("{user1_nom} is online.").format(**user_name)
msg = _("{user1_nom} is online.").format(**user_name) sound = "friend_online.ogg"
sound = "friend_online.ogg" self.notify(msg, sound, self.session.settings["chat"]["notifications"])
self.notify(msg, sound, self.session.settings["chat"]["notifications"])
online_buffer = self.search("online_friends") online_buffer = self.search("online_friends")
user = None user = None
for i in self.session.db["friends_"]["items"]: for i in self.session.db["friends_"]["items"]:
@ -465,15 +464,14 @@ class Controller(object):
wx.CallAfter(online_buffer.add_person, user) wx.CallAfter(online_buffer.add_person, user)
def user_offline(self, event): def user_offline(self, event):
""" Sends a notification of an user logging off in VK. """ Remove user from the online buffer and Send a notification of an user logging off in VK.
@ event vk_api.longpoll.event object: The event sent by the vk_api's longPoll module. @ event vk_api.longpoll.event object: The event sent by the vk_api's longPoll module.
""" """
if self.session.settings["chat"]["notify_offline"] == False: if self.session.settings["chat"]["notify_offline"] == True:
return user_name = self.session.get_user(event.user_id)
user_name = self.session.get_user(event.user_id) msg = _("{user1_nom} is offline.").format(**user_name)
msg = _("{user1_nom} is offline.").format(**user_name) sound = "friend_offline.ogg"
sound = "friend_offline.ogg" self.notify(msg, sound, self.session.settings["chat"]["notifications"])
self.notify(msg, sound, self.session.settings["chat"]["notifications"])
online_friends = self.search("online_friends") online_friends = self.search("online_friends")
wx.CallAfter(online_friends.remove_person, event.user_id) wx.CallAfter(online_friends.remove_person, event.user_id)