omit empty relates to

This commit is contained in:
cubicroot 2022-04-09 12:47:32 +02:00
parent 802794212b
commit 85c4ae071a

View file

@ -31,7 +31,7 @@ type MessageEvent struct {
Body string `json:"body"` Body string `json:"body"`
FormattedBody string `json:"formatted_body"` FormattedBody string `json:"formatted_body"`
MsgType MsgType `json:"msgtype"` MsgType MsgType `json:"msgtype"`
RelatesTo RelatesTo `json:"m.relates_to,omitempty"` RelatesTo *RelatesTo `json:"m.relates_to,omitempty"`
Format MessageFormat `json:"format"` Format MessageFormat `json:"format"`
NewContent *NewContent `json:"m.new_content,omitempty"` NewContent *NewContent `json:"m.new_content,omitempty"`
} }
@ -213,7 +213,7 @@ func (d *Dispatcher) replaceMessage(a *model.Application, newBody, newFormattedB
FormattedBody: oldFormattedBody, FormattedBody: oldFormattedBody,
MsgType: MsgTypeText, MsgType: MsgTypeText,
NewContent: &newMessage, NewContent: &newMessage,
RelatesTo: replaceRelation, RelatesTo: &replaceRelation,
Format: MessageFormatHTML, Format: MessageFormatHTML,
} }
@ -252,7 +252,7 @@ func (d *Dispatcher) respondToMessage(a *model.Application, body, formattedBody
notificationRelation := RelatesTo{ notificationRelation := RelatesTo{
InReplyTo: notificationReply, InReplyTo: notificationReply,
} }
notificationEvent.RelatesTo = notificationRelation notificationEvent.RelatesTo = &notificationRelation
return d.mautrixClient.SendMessageEvent(mId.RoomID(a.MatrixID), event.EventMessage, &notificationEvent) return d.mautrixClient.SendMessageEvent(mId.RoomID(a.MatrixID), event.EventMessage, &notificationEvent)
} }