aboutsummaryrefslogtreecommitdiff
path: root/matrix
diff options
context:
space:
mode:
Diffstat (limited to 'matrix')
-rw-r--r--matrix/event/event.go8
-rw-r--r--matrix/matrix.go21
2 files changed, 27 insertions, 2 deletions
diff --git a/matrix/event/event.go b/matrix/event/event.go
index 143d35d..8506c9c 100644
--- a/matrix/event/event.go
+++ b/matrix/event/event.go
@@ -25,6 +25,14 @@ type Event struct {
Gomuks GomuksContent `json:"-"`
}
+func (evt *Event) SomewhatDangerousCopy() *Event {
+ base := *evt.Event
+ return &Event{
+ Event: &base,
+ Gomuks: evt.Gomuks,
+ }
+}
+
func Wrap(event *mautrix.Event) *Event {
return &Event{Event: event}
}
diff --git a/matrix/matrix.go b/matrix/matrix.go
index f77a257..c33a749 100644
--- a/matrix/matrix.go
+++ b/matrix/matrix.go
@@ -218,7 +218,7 @@ func (c *Container) SingleSignOn() error {
if err != nil {
return err
}
- err = <- errChan
+ err = <-errChan
return err
}
@@ -690,7 +690,7 @@ func (c *Container) MarkRead(roomID, eventID string) {
var mentionRegex = regexp.MustCompile("\\[(.+?)]\\(https://matrix.to/#/@.+?:.+?\\)")
var roomRegex = regexp.MustCompile("\\[.+?]\\(https://matrix.to/#/(#.+?:[^/]+?)\\)")
-func (c *Container) PrepareMarkdownMessage(roomID string, msgtype mautrix.MessageType, text string) *event.Event {
+func (c *Container) PrepareMarkdownMessage(roomID string, msgtype mautrix.MessageType, text string, edit *event.Event) *event.Event {
content := format.RenderMarkdown(text)
content.MsgType = msgtype
@@ -698,6 +698,19 @@ func (c *Container) PrepareMarkdownMessage(roomID string, msgtype mautrix.Messag
content.Body = mentionRegex.ReplaceAllString(content.Body, "$1")
content.Body = roomRegex.ReplaceAllString(content.Body, "$1")
+ if edit != nil {
+ contentCopy := content
+ content.NewContent = &contentCopy
+ content.Body = "* " + content.Body
+ if len(content.FormattedBody) > 0 {
+ content.FormattedBody = "* " + content.FormattedBody
+ }
+ content.RelatesTo = &mautrix.RelatesTo{
+ Type: mautrix.RelReplace,
+ EventID: edit.ID,
+ }
+ }
+
txnID := c.client.TxnID()
localEcho := event.Wrap(&mautrix.Event{
ID: txnID,
@@ -711,6 +724,10 @@ func (c *Container) PrepareMarkdownMessage(roomID string, msgtype mautrix.Messag
},
})
localEcho.Gomuks.OutgoingState = event.StateLocalEcho
+ if edit != nil {
+ localEcho.ID = edit.ID
+ localEcho.Gomuks.Edits = []*event.Event{localEcho}
+ }
return localEcho
}