Add members to room updates

This commit is contained in:
miruka 2019-07-07 05:08:58 -04:00
parent 0ac4874ddf
commit 735707bade
2 changed files with 16 additions and 10 deletions

View File

@ -1,6 +1,6 @@
from datetime import datetime from datetime import datetime
from enum import auto from enum import auto
from typing import List, Sequence, Type, Union from typing import Any, Dict, List, Sequence, Type, Union
from dataclasses import dataclass, field from dataclasses import dataclass, field
@ -18,6 +18,7 @@ class RoomUpdated(Event):
display_name: str = "" display_name: str = ""
avatar_url: str = "" avatar_url: str = ""
topic: str = "" topic: str = ""
members: Sequence[Dict[str, Any]] = ()
typing_members: Sequence[str] = () typing_members: Sequence[str] = ()
inviter_id: str = "" inviter_id: str = ""
@ -42,6 +43,9 @@ class RoomUpdated(Event):
name = room.group_name() name = room.group_name()
name = "" if name == "Empty room?" else name name = "" if name == "Empty room?" else name
members = [{"userId": m.user_id, "powerLevel": m.power_level}
for m in room.users.values()]
return cls( return cls(
user_id = user_id, user_id = user_id,
category = category, category = category,
@ -50,6 +54,7 @@ class RoomUpdated(Event):
avatar_url = room.gen_avatar_url or "", avatar_url = room.gen_avatar_url or "",
topic = room.topic or "", topic = room.topic or "",
inviter_id = getattr(room, "inviter", "") or "", inviter_id = getattr(room, "inviter", "") or "",
members = members,
typing_members = typing, typing_members = typing,
) )

View File

@ -35,7 +35,7 @@ function typingTextFor(members, our_user_id) {
function onRoomUpdated( function onRoomUpdated(
user_id, category, room_id, display_name, avatar_url, topic, user_id, category, room_id, display_name, avatar_url, topic,
typing_members, inviter_id members, typing_members, inviter_id
) { ) {
roomCategories.upsert({"userId": user_id, "name": category}, { roomCategories.upsert({"userId": user_id, "name": category}, {
"userId": user_id, "userId": user_id,
@ -61,6 +61,7 @@ function onRoomUpdated(
"displayName": display_name, "displayName": display_name,
"avatarUrl": avatar_url, "avatarUrl": avatar_url,
"topic": topic, "topic": topic,
"members": members,
"typingText": typingTextFor(typing_members, user_id), "typingText": typingTextFor(typing_members, user_id),
"inviterId": inviter_id "inviterId": inviter_id
} }