File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -101,6 +101,10 @@ func (rel *RelatesTo) SetReplace(mxid id.EventID) *RelatesTo {
101101}
102102
103103func (rel * RelatesTo ) SetReplyTo (mxid id.EventID ) * RelatesTo {
104+ if rel .Type != RelThread {
105+ rel .Type = ""
106+ rel .EventID = ""
107+ }
104108 rel .InReplyTo = & InReplyTo {EventID : mxid }
105109 rel .IsFallingBack = false
106110 return rel
Original file line number Diff line number Diff line change @@ -47,5 +47,27 @@ func (content *MessageEventContent) GetReplyTo() id.EventID {
4747}
4848
4949func (content * MessageEventContent ) SetReply (inReplyTo * Event ) {
50- content .RelatesTo = (& RelatesTo {}).SetReplyTo (inReplyTo .ID )
50+ if content .RelatesTo == nil {
51+ content .RelatesTo = & RelatesTo {}
52+ }
53+ content .RelatesTo .SetReplyTo (inReplyTo .ID )
54+ if content .Mentions == nil {
55+ content .Mentions = & Mentions {}
56+ }
57+ content .Mentions .Add (inReplyTo .Sender )
58+ }
59+
60+ func (content * MessageEventContent ) SetThread (inReplyTo * Event ) {
61+ root := inReplyTo .ID
62+ relatable , ok := inReplyTo .Content .Parsed .(Relatable )
63+ if ok {
64+ targetRoot := relatable .OptionalGetRelatesTo ().GetThreadParent ()
65+ if targetRoot != "" {
66+ root = targetRoot
67+ }
68+ }
69+ if content .RelatesTo == nil {
70+ content .RelatesTo = & RelatesTo {}
71+ }
72+ content .RelatesTo .SetThread (root , inReplyTo .ID )
5173}
You can’t perform that action at this time.
0 commit comments