mirror of
https://github.com/matrix-org/sliding-sync.git
synced 2025-03-10 13:37:11 +00:00
Parse m.room.avatar
This commit is contained in:
parent
3861bac4c6
commit
5913fbb0f3
@ -30,6 +30,7 @@ type RoomMetadata struct {
|
||||
RoomID string
|
||||
Heroes []Hero
|
||||
NameEvent string // the content of m.room.name, NOT the calculated name
|
||||
AvatarEvent string // the content of m.room.avatar, NOT the resolved avatar
|
||||
CanonicalAlias string
|
||||
JoinCount int
|
||||
InviteCount int
|
||||
|
@ -232,7 +232,7 @@ func (s *Storage) MetadataForAllRooms(txn *sqlx.Tx, tempTableName string, result
|
||||
|
||||
// Select the name / canonical alias for all rooms
|
||||
roomIDToStateEvents, err := s.currentNotMembershipStateEventsInAllRooms(txn, []string{
|
||||
"m.room.name", "m.room.canonical_alias",
|
||||
"m.room.name", "m.room.canonical_alias", "m.room.avatar",
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to load state events for all rooms: %s", err)
|
||||
@ -244,6 +244,8 @@ func (s *Storage) MetadataForAllRooms(txn *sqlx.Tx, tempTableName string, result
|
||||
metadata.NameEvent = gjson.ParseBytes(ev.JSON).Get("content.name").Str
|
||||
} else if ev.Type == "m.room.canonical_alias" && ev.StateKey == "" {
|
||||
metadata.CanonicalAlias = gjson.ParseBytes(ev.JSON).Get("content.alias").Str
|
||||
} else if ev.Type == "m.room.avatar" && ev.StateKey == "" {
|
||||
metadata.AvatarEvent = gjson.ParseBytes(ev.JSON).Get("content.url").Str
|
||||
}
|
||||
}
|
||||
result[roomID] = metadata
|
||||
|
@ -279,6 +279,10 @@ func (c *GlobalCache) OnNewEvent(
|
||||
if ed.StateKey != nil && *ed.StateKey == "" {
|
||||
metadata.NameEvent = ed.Content.Get("name").Str
|
||||
}
|
||||
case "m.room.avatar":
|
||||
if ed.StateKey != nil && *ed.StateKey == "" {
|
||||
metadata.AvatarEvent = ed.Content.Get("url").Str
|
||||
}
|
||||
case "m.room.encryption":
|
||||
if ed.StateKey != nil && *ed.StateKey == "" {
|
||||
metadata.Encrypted = true
|
||||
|
@ -73,6 +73,7 @@ type InviteData struct {
|
||||
Heroes []internal.Hero
|
||||
InviteEvent *EventData
|
||||
NameEvent string // the content of m.room.name, NOT the calculated name
|
||||
AvatarEvent string // the content of m.room.avatar, NOT the calculated avatar
|
||||
CanonicalAlias string
|
||||
LastMessageTimestamp uint64
|
||||
Encrypted bool
|
||||
@ -114,6 +115,8 @@ func NewInviteData(ctx context.Context, userID, roomID string, inviteState []jso
|
||||
}
|
||||
case "m.room.name":
|
||||
id.NameEvent = j.Get("content.name").Str
|
||||
case "m.room.avatar":
|
||||
id.AvatarEvent = j.Get("content.avatar_url").Str
|
||||
case "m.room.canonical_alias":
|
||||
id.CanonicalAlias = j.Get("content.alias").Str
|
||||
case "m.room.encryption":
|
||||
@ -147,6 +150,7 @@ func (i *InviteData) RoomMetadata() *internal.RoomMetadata {
|
||||
metadata := internal.NewRoomMetadata(i.roomID)
|
||||
metadata.Heroes = i.Heroes
|
||||
metadata.NameEvent = i.NameEvent
|
||||
metadata.AvatarEvent = i.AvatarEvent
|
||||
metadata.CanonicalAlias = i.CanonicalAlias
|
||||
metadata.InviteCount = 1
|
||||
metadata.JoinCount = 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user