provide proper reply-to fallback by default

This commit is contained in:
Aine
2023-09-28 15:17:55 +03:00
parent 8bdd46fb32
commit bebfa6df92
11 changed files with 91 additions and 85 deletions

View File

@@ -7,6 +7,35 @@ import (
"maunium.net/go/mautrix/id"
)
// RelatesTo returns relation object of a matrix event (either threads with reply-to fallback or plain reply-to)
func RelatesTo(parentID id.EventID, noThreads ...bool) *event.RelatesTo {
if parentID == "" {
return nil
}
var nothreads bool
if len(noThreads) > 0 {
nothreads = noThreads[0]
}
if nothreads {
return &event.RelatesTo{
InReplyTo: &event.InReplyTo{
EventID: parentID,
},
}
}
return &event.RelatesTo{
Type: event.RelThread,
EventID: parentID,
InReplyTo: &event.InReplyTo{
EventID: parentID,
},
IsFallingBack: true,
}
}
// EventParent returns parent event ID (either from thread or from reply-to relation)
func EventParent(currentID id.EventID, content *event.MessageEventContent) id.EventID {
if content == nil {

2
vendor/modules.txt vendored
View File

@@ -144,7 +144,7 @@ gitlab.com/etke.cc/go/trysmtp
# gitlab.com/etke.cc/go/validator v1.0.6
## explicit; go 1.18
gitlab.com/etke.cc/go/validator
# gitlab.com/etke.cc/linkpearl v0.0.0-20230928051620-7f1b7d54e9a8
# gitlab.com/etke.cc/linkpearl v0.0.0-20230928120707-1e99315dc616
## explicit; go 1.18
gitlab.com/etke.cc/linkpearl
# go.mau.fi/util v0.1.0