plugin XEP-0045: added room statuses to metadata:
room statuses are now sent with other metadata on bridge signals, and saved in Room instance. They give useful data on the room, for instance they can be used to know if a full jid is used in this room.
This commit is contained in:
parent
b7a74d5034
commit
efe52d755d
1 changed files with 29 additions and 8 deletions
|
|
@ -92,7 +92,7 @@ class XEP_0045(object):
|
|||
# return same arguments as mucRoomJoined + a boolean set to True is the room was
|
||||
# already joined (first argument)
|
||||
host.bridge.addMethod(
|
||||
"mucJoin", ".plugin", in_sign='ssa{ss}s', out_sign='(bsa{sa{ss}}sss)',
|
||||
"mucJoin", ".plugin", in_sign='ssa{ss}s', out_sign='(bsa{sa{ss}}ssass)',
|
||||
method=self._join, async_=True)
|
||||
host.bridge.addMethod(
|
||||
"mucNick", ".plugin", in_sign='sss', out_sign='', method=self._nick)
|
||||
|
|
@ -107,7 +107,7 @@ class XEP_0045(object):
|
|||
host.bridge.addMethod(
|
||||
"mucSubject", ".plugin", in_sign='sss', out_sign='', method=self._subject)
|
||||
host.bridge.addMethod(
|
||||
"mucGetRoomsJoined", ".plugin", in_sign='s', out_sign='a(sa{sa{ss}}ss)',
|
||||
"mucGetRoomsJoined", ".plugin", in_sign='s', out_sign='a(sa{sa{ss}}ssas)',
|
||||
method=self._getRoomsJoined)
|
||||
host.bridge.addMethod(
|
||||
"mucGetUniqueRoomName", ".plugin", in_sign='ss', out_sign='s',
|
||||
|
|
@ -128,7 +128,7 @@ class XEP_0045(object):
|
|||
"mucRoomPrepareJoin", ".plugin", signature='ss')
|
||||
# args: room_jid, occupants, user_nick, subject, profile
|
||||
host.bridge.addSignal(
|
||||
"mucRoomJoined", ".plugin", signature='sa{sa{ss}}sss')
|
||||
"mucRoomJoined", ".plugin", signature='sa{sa{ss}}ssass')
|
||||
# args: room_jid, profile
|
||||
host.bridge.addSignal(
|
||||
"mucRoomLeft", ".plugin", signature='ss')
|
||||
|
|
@ -241,6 +241,7 @@ class XEP_0045(object):
|
|||
XEP_0045._getOccupants(room),
|
||||
room.nick,
|
||||
room.subject,
|
||||
[s.name for s in room.statuses],
|
||||
profile
|
||||
]
|
||||
|
||||
|
|
@ -331,7 +332,14 @@ class XEP_0045(object):
|
|||
result = []
|
||||
for room in list(client._muc_client.joined_rooms.values()):
|
||||
if room.state == ROOM_STATE_LIVE:
|
||||
result.append((room.roomJID.userhost(), self._getOccupants(room), room.nick, room.subject))
|
||||
result.append(
|
||||
(room.roomJID.userhost(),
|
||||
self._getOccupants(room),
|
||||
room.nick,
|
||||
room.subject,
|
||||
[s.name for s in room.statuses],
|
||||
)
|
||||
)
|
||||
return result
|
||||
|
||||
def _getRoomNick(self, room_jid_s, profile_key=C.PROF_KEY_NONE):
|
||||
|
|
@ -1087,6 +1095,15 @@ class SatMUCClient(muc.MUCClient):
|
|||
return
|
||||
user = muc.User(nick, presence.entity)
|
||||
|
||||
# we want to keep statuses with room
|
||||
# XXX: presence if broadcasted, and we won't have status code
|
||||
# like 110 (REALJID_PUBLIC) after first <presence/> received
|
||||
# so we keep only the initial <presence> (with SELF_PRESENCE),
|
||||
# thus we check if attribute already exists
|
||||
if (not hasattr(room, 'statuses')
|
||||
and muc.STATUS_CODE.SELF_PRESENCE in presence.mucStatuses):
|
||||
room.statuses = presence.mucStatuses
|
||||
|
||||
# Update user data
|
||||
user.role = presence.role
|
||||
user.affiliation = presence.affiliation
|
||||
|
|
|
|||
Loading…
Reference in a new issue