aboutsummaryrefslogtreecommitdiff
path: root/matrix/rooms
diff options
context:
space:
mode:
authorTulir Asokan <tulir@maunium.net>2018-04-24 02:13:17 +0300
committerTulir Asokan <tulir@maunium.net>2018-04-24 02:13:43 +0300
commit2a0145db884038342ba00cdb29fc29085e1faace (patch)
treee4362a636292981450c1884be16ba947ec2dc9a2 /matrix/rooms
parent135fcbf284e941a312567d22af80fe69d49cbd89 (diff)
Handle tag events
Diffstat (limited to 'matrix/rooms')
-rw-r--r--matrix/rooms/room.go19
1 files changed, 18 insertions, 1 deletions
diff --git a/matrix/rooms/room.go b/matrix/rooms/room.go
index 7b4a8b5..44a386b 100644
--- a/matrix/rooms/room.go
+++ b/matrix/rooms/room.go
@@ -34,6 +34,14 @@ const (
MemberRoomName
)
+// RoomTag is a tag given to a specific room.
+type RoomTag struct {
+ // The name of the tag.
+ Tag string
+ // The order of the tag. Smaller values are ordered higher.
+ Order float64
+}
+
// Room represents a single Matrix room.
type Room struct {
*gomatrix.Room
@@ -53,7 +61,9 @@ type Room struct {
// a notificationless message like bot notices.
HasNewMessages bool
- Tags []string
+ // List of tags given to this room
+ RawTags []RoomTag
+ // Timestamp of previously received actual message.
LastReceivedMessage time.Time
// MXID -> Member cache calculated from membership events.
@@ -102,6 +112,13 @@ func (room *Room) MarkRead() {
room.HasNewMessages = false
}
+func (room *Room) Tags() []RoomTag {
+ if len(room.RawTags) == 0 {
+ return []RoomTag{{"", 0.5}}
+ }
+ return room.RawTags
+}
+
// UpdateState updates the room's current state with the given Event. This will clobber events based
// on the type/state_key combination.
func (room *Room) UpdateState(event *gomatrix.Event) {