aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2020-03-01 15:38:54 +0100
committerAlex Auvolat <alex@adnab.me>2020-03-01 15:38:54 +0100
commitf251d67c32e001a01c19faac800762ba146c2339 (patch)
tree1557475dd14599e5dd84f4d01d89f1ec24da15a9
parent0823b72accdde4f1812a45beb061ce61e18c15b3 (diff)
downloadeasybridge-f251d67c32e001a01c19faac800762ba146c2339.tar.gz
easybridge-f251d67c32e001a01c19faac800762ba146c2339.zip
UNTESTED: GROUP CHATS ;; add handlers for member join/leave and name changes
-rwxr-xr-xexternal/messenger.py31
1 files changed, 24 insertions, 7 deletions
diff --git a/external/messenger.py b/external/messenger.py
index cd5d972..f857b46 100755
--- a/external/messenger.py
+++ b/external/messenger.py
@@ -389,7 +389,7 @@ class MessengerBridge:
"room": room,
}
})
- self.joined_map[key] = true
+ self.joined_map[key] = True
def onMessage(self, thread_id, thread_type, message_object, **kwargs):
if message_object.author == self.client.uid:
@@ -443,12 +443,29 @@ class MessengerBridge:
self.cache_put("last_seen_%s"%thread_id, message_object.uid)
- def onPeopleAdded(self, *args, **kwargs):
- pass
- def onPersonRemoved(self, *args, **kwargs):
- pass
- def onTitleChange(self, *args, **kwargs):
- pass
+ def onPeopleAdded(self, added_ids, thread_id, *args, **kwargs):
+ for user_id in added_ids:
+ self.ensureJoined(self.getUserIdFromUid(user_id), thread_id)
+
+ def onPersonRemoved(self, removed_id, thread_id, *args, **kwargs):
+ userId = self.getUserIdFromUid(removed_id),
+ self.write({
+ "_type": EVENT,
+ "data": {
+ "type": EVENT_JOIN,
+ "author": userId,
+ "room": thread_id,
+ }
+ })
+ del self.joined_map["{}--{}".format(userId, thread_id)]
+
+ def onTitleChange(self, author_id, new_title, thread_id, thread_type, *args, **kwargs):
+ if thread_type == ThreadType.GROUP:
+ self.bridge.write({
+ "_type": ROOM_INFO_UPDATED,
+ "room": thread_id,
+ "data": {"name": new_title},
+ })
if __name__ == "__main__":
bridge = MessengerBridge()