From e9c0b6e3a956c4890ee534fa043c387e3e87e529 Mon Sep 17 00:00:00 2001 From: cubicroot Date: Fri, 8 Apr 2022 20:14:22 +0200 Subject: [PATCH 1/4] fix empty notifications --- internal/dispatcher/notification.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/dispatcher/notification.go b/internal/dispatcher/notification.go index b23bca6..29d3bf9 100644 --- a/internal/dispatcher/notification.go +++ b/internal/dispatcher/notification.go @@ -33,7 +33,7 @@ type MessageEvent struct { MsgType MsgType `json:"msgtype"` RelatesTo RelatesTo `json:"m.relates_to,omitempty"` Format MessageFormat `json:"format"` - NewContent NewContent `json:"m.new_content,omitempty"` + NewContent *NewContent `json:"m.new_content,omitempty"` } // RelatesTo holds information about relations to other message events @@ -212,7 +212,7 @@ func (d *Dispatcher) replaceMessage(a *model.Application, newBody, newFormattedB Body: oldBody, FormattedBody: oldFormattedBody, MsgType: MsgTypeText, - NewContent: newMessage, + NewContent: &newMessage, RelatesTo: replaceRelation, Format: MessageFormatHTML, } From 75244a6593e481e6fa569c70c7b34ddf5758181c Mon Sep 17 00:00:00 2001 From: cubicroot Date: Fri, 8 Apr 2022 20:21:02 +0200 Subject: [PATCH 2/4] try without poetry --- Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile b/Makefile index 520967c..d4a68a0 100644 --- a/Makefile +++ b/Makefile @@ -38,7 +38,6 @@ setup: go install github.com/securego/gosec/v2/cmd/gosec@latest go install github.com/swaggo/swag/cmd/swag@latest go install honnef.co/go/tools/cmd/staticcheck@latest - poetry install .PHONY: swag swag: From 802794212bdd8531f00407dfb14849cd592a0f3c Mon Sep 17 00:00:00 2001 From: cubicroot Date: Fri, 8 Apr 2022 20:24:16 +0200 Subject: [PATCH 3/4] pin staticcheck version --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d4a68a0..5b3a535 100644 --- a/Makefile +++ b/Makefile @@ -37,7 +37,8 @@ setup: go install github.com/fzipp/gocyclo/cmd/gocyclo@latest go install github.com/securego/gosec/v2/cmd/gosec@latest go install github.com/swaggo/swag/cmd/swag@latest - go install honnef.co/go/tools/cmd/staticcheck@latest + go install honnef.co/go/tools/cmd/staticcheck@v0.2.2 + poetry install .PHONY: swag swag: From 85c4ae071a10908a7e9e86a3e5b2c798b8302d40 Mon Sep 17 00:00:00 2001 From: cubicroot Date: Sat, 9 Apr 2022 12:47:32 +0200 Subject: [PATCH 4/4] omit empty relates to --- internal/dispatcher/notification.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/dispatcher/notification.go b/internal/dispatcher/notification.go index 29d3bf9..574c995 100644 --- a/internal/dispatcher/notification.go +++ b/internal/dispatcher/notification.go @@ -31,7 +31,7 @@ type MessageEvent struct { Body string `json:"body"` FormattedBody string `json:"formatted_body"` MsgType MsgType `json:"msgtype"` - RelatesTo RelatesTo `json:"m.relates_to,omitempty"` + RelatesTo *RelatesTo `json:"m.relates_to,omitempty"` Format MessageFormat `json:"format"` NewContent *NewContent `json:"m.new_content,omitempty"` } @@ -213,7 +213,7 @@ func (d *Dispatcher) replaceMessage(a *model.Application, newBody, newFormattedB FormattedBody: oldFormattedBody, MsgType: MsgTypeText, NewContent: &newMessage, - RelatesTo: replaceRelation, + RelatesTo: &replaceRelation, Format: MessageFormatHTML, } @@ -252,7 +252,7 @@ func (d *Dispatcher) respondToMessage(a *model.Application, body, formattedBody notificationRelation := RelatesTo{ InReplyTo: notificationReply, } - notificationEvent.RelatesTo = notificationRelation + notificationEvent.RelatesTo = ¬ificationRelation return d.mautrixClient.SendMessageEvent(mId.RoomID(a.MatrixID), event.EventMessage, ¬ificationEvent) }