Add members to room updates
This commit is contained in:
parent
0ac4874ddf
commit
735707bade
|
@ -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
|
||||||
|
|
||||||
|
@ -12,14 +12,15 @@ from .event import AutoStrEnum, Event
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class RoomUpdated(Event):
|
class RoomUpdated(Event):
|
||||||
user_id: str = field()
|
user_id: str = field()
|
||||||
category: str = field()
|
category: str = field()
|
||||||
room_id: str = field()
|
room_id: str = field()
|
||||||
display_name: str = ""
|
display_name: str = ""
|
||||||
avatar_url: str = ""
|
avatar_url: str = ""
|
||||||
topic: str = ""
|
topic: str = ""
|
||||||
typing_members: Sequence[str] = ()
|
members: Sequence[Dict[str, Any]] = ()
|
||||||
inviter_id: str = ""
|
typing_members: Sequence[str] = ()
|
||||||
|
inviter_id: str = ""
|
||||||
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -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,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user