comparison src/plugins/plugin_xep_0045.py @ 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 2daf7b4c6756
comparison
equal deleted inserted replaced
1890:0a45bc8e7cf4 1891:b91c8637c656
690 return self._rooms 690 return self._rooms
691 691
692 def subject(self, room, subject): 692 def subject(self, room, subject):
693 return muc.MUCClientProtocol.subject(self, room, subject) 693 return muc.MUCClientProtocol.subject(self, room, subject)
694 694
695 def availableReceived(self, presence):
696 """
697 Available presence was received.
698 """
699 # XXX: we override MUCClient.availableReceived to fix bugs
700 # (affiliation and role are not set)
701 # FIXME: propose a patch upstream
702
703 room, user = self._getRoomUser(presence)
704
705 if room is None:
706 return
707
708 if user is None:
709 nick = presence.sender.resource
710 user = muc.User(nick, presence.entity)
711
712 # Update user data
713 user.role = presence.role
714 user.affiliation = presence.affiliation
715 user.status = presence.status
716 user.show = presence.show
717
718 if room.inRoster(user):
719 self.userUpdatedStatus(room, user, presence.show, presence.status)
720 else:
721 room.addUser(user)
722 self.userJoinedRoom(room, user)
695 def unavailableReceived(self, presence): 723 def unavailableReceived(self, presence):
696 # XXX: we override this method to manage nickname change 724 # XXX: we override this method to manage nickname change
697 # TODO: feed this back to Wokkel 725 # TODO: feed this back to Wokkel
698 """ 726 """
699 Unavailable presence was received. 727 Unavailable presence was received.