Mercurial > libervia-backend
changeset 1891:b91c8637c656
plugin XEP-0045: overriden availableReceived method of MUCClient to work around a bug in Wokkel (affiliation and role are not set). TODO: propose a patch upstream
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 07 Mar 2016 15:48:11 +0100 |
parents | 0a45bc8e7cf4 |
children | 8a5b178ff28b |
files | src/plugins/plugin_xep_0045.py |
diffstat | 1 files changed, 28 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/plugins/plugin_xep_0045.py Mon Mar 07 13:50:57 2016 +0100 +++ b/src/plugins/plugin_xep_0045.py Mon Mar 07 15:48:11 2016 +0100 @@ -692,6 +692,34 @@ def subject(self, room, subject): return muc.MUCClientProtocol.subject(self, room, subject) + def availableReceived(self, presence): + """ + Available presence was received. + """ + # XXX: we override MUCClient.availableReceived to fix bugs + # (affiliation and role are not set) + # FIXME: propose a patch upstream + + room, user = self._getRoomUser(presence) + + if room is None: + return + + if user is None: + nick = presence.sender.resource + user = muc.User(nick, presence.entity) + + # Update user data + user.role = presence.role + user.affiliation = presence.affiliation + user.status = presence.status + user.show = presence.show + + if room.inRoster(user): + self.userUpdatedStatus(room, user, presence.show, presence.status) + else: + room.addUser(user) + self.userJoinedRoom(room, user) def unavailableReceived(self, presence): # XXX: we override this method to manage nickname change # TODO: feed this back to Wokkel