aboutsummaryrefslogtreecommitdiff
path: root/matrix
diff options
context:
space:
mode:
authorTulir Asokan <tulir@maunium.net>2018-03-20 23:34:43 +0200
committerTulir Asokan <tulir@maunium.net>2018-03-20 23:36:09 +0200
commitbb58954f755ac0ee5a7ad7e11159f00810d23aa3 (patch)
tree1cc67ed2b3e4d6fb5d6d92e9089259e26d5e3973 /matrix
parent85f289c98d0ebdecb7e504eb8d40b5413be5fc92 (diff)
Add initial notification support that just spams about everything, prepare for push rules (ref #7)
Diffstat (limited to 'matrix')
-rw-r--r--matrix/matrix.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/matrix/matrix.go b/matrix/matrix.go
index d7e9ed3..9689827 100644
--- a/matrix/matrix.go
+++ b/matrix/matrix.go
@@ -25,7 +25,9 @@ import (
"maunium.net/go/gomuks/config"
"maunium.net/go/gomuks/interface"
rooms "maunium.net/go/gomuks/matrix/room"
+ "maunium.net/go/gomuks/notification"
"maunium.net/go/gomuks/ui/debug"
+ "maunium.net/go/gomuks/ui/types"
"maunium.net/go/gomuks/ui/widget"
)
@@ -117,6 +119,14 @@ func (c *Container) Client() *gomatrix.Client {
return c.client
}
+func (c *Container) UpdatePushRules() {
+ resp, err := c.client.PushRules()
+ if err != nil {
+ debug.Print("Failed to fetch push rules:", err)
+ }
+ c.config.Session.PushRules = resp
+}
+
func (c *Container) UpdateRoomList() {
resp, err := c.client.JoinedRooms()
if err != nil {
@@ -147,6 +157,7 @@ func (c *Container) OnLogin() {
c.client.Syncer = syncer
c.UpdateRoomList()
+ c.UpdatePushRules()
}
func (c *Container) Start() {
@@ -177,9 +188,14 @@ func (c *Container) Start() {
}
}
+func (c *Container) NotifyMessage(room *rooms.Room, message *types.Message) {
+ notification.Send(room.GetTitle(), message.Text, false)
+}
+
func (c *Container) HandleMessage(evt *gomatrix.Event) {
room, message := c.ui.MainView().ProcessMessageEvent(evt)
if room != nil {
+ c.NotifyMessage(room.Room, message)
room.AddMessage(message, widget.AppendMessage)
c.ui.Render()
}