diff options
author | Tulir Asokan <tulir@maunium.net> | 2020-02-22 01:17:52 +0200 |
---|---|---|
committer | Tulir Asokan <tulir@maunium.net> | 2020-02-22 01:17:52 +0200 |
commit | 455d9fc4c5726e4af9c40b36ee4f4ea18f65a8e9 (patch) | |
tree | ed61048b008b627371943370a16244c10e33602b /matrix/matrix.go | |
parent | ecdb1166e1cead31518c058a0e7fd749e61b193e (diff) |
Improve tags and add initial invite handling
Diffstat (limited to 'matrix/matrix.go')
-rw-r--r-- | matrix/matrix.go | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/matrix/matrix.go b/matrix/matrix.go index d3edde5..8819a5b 100644 --- a/matrix/matrix.go +++ b/matrix/matrix.go @@ -663,7 +663,7 @@ func (c *Container) parseDirectChatInfo(evt *mautrix.Event) map[*rooms.Room]bool return directChats } -func (c *Container) HandleDirectChatInfo(source EventSource, evt *mautrix.Event) { +func (c *Container) HandleDirectChatInfo(_ EventSource, evt *mautrix.Event) { directChats := c.parseDirectChatInfo(evt) for _, room := range c.config.Rooms.Map { shouldBeDirect := directChats[room] @@ -677,7 +677,7 @@ func (c *Container) HandleDirectChatInfo(source EventSource, evt *mautrix.Event) } // HandlePushRules is the event handler for the m.push_rules account data event. -func (c *Container) HandlePushRules(source EventSource, evt *mautrix.Event) { +func (c *Container) HandlePushRules(_ EventSource, evt *mautrix.Event) { debug.Print("Received updated push rules") var err error c.config.PushRules, err = pushrules.EventToPushRules(evt) @@ -689,15 +689,16 @@ func (c *Container) HandlePushRules(source EventSource, evt *mautrix.Event) { } // HandleTag is the event handler for the m.tag account data event. -func (c *Container) HandleTag(source EventSource, evt *mautrix.Event) { +func (c *Container) HandleTag(_ EventSource, evt *mautrix.Event) { + debug.Printf("Received tags for %s: %s -- %s", evt.RoomID, evt.Content.RoomTags, string(evt.Content.VeryRaw)) room := c.GetOrCreateRoom(evt.RoomID) newTags := make([]rooms.RoomTag, len(evt.Content.RoomTags)) index := 0 for tag, info := range evt.Content.RoomTags { - order := "0.5" + order := json.Number("0.5") if len(info.Order) > 0 { - order = info.Order.String() + order = info.Order } newTags[index] = rooms.RoomTag{ Tag: tag, @@ -714,7 +715,7 @@ func (c *Container) HandleTag(source EventSource, evt *mautrix.Event) { } // HandleTyping is the event handler for the m.typing event. -func (c *Container) HandleTyping(source EventSource, evt *mautrix.Event) { +func (c *Container) HandleTyping(_ EventSource, evt *mautrix.Event) { if !c.config.AuthCache.InitialSyncDone { return } @@ -723,7 +724,7 @@ func (c *Container) HandleTyping(source EventSource, evt *mautrix.Event) { func (c *Container) MarkRead(roomID, eventID string) { urlPath := c.client.BuildURL("rooms", roomID, "receipt", "m.read", eventID) - c.client.MakeRequest("POST", urlPath, struct{}{}, nil) + _, _ = c.client.MakeRequest("POST", urlPath, struct{}{}, nil) } var mentionRegex = regexp.MustCompile("\\[(.+?)]\\(https://matrix.to/#/@.+?:.+?\\)") @@ -791,10 +792,10 @@ func (c *Container) SendTyping(roomID string, typing bool) { } if typing { - c.client.UserTyping(roomID, true, 20000) + _, _ = c.client.UserTyping(roomID, true, 20000) c.typing = ts + 15 } else { - c.client.UserTyping(roomID, false, 0) + _, _ = c.client.UserTyping(roomID, false, 0) c.typing = 0 } } |