Add support for sending replies
This commit is contained in:
parent
a350e4fc00
commit
b4103e9ba8
2 changed files with 18 additions and 3 deletions
|
@ -3,7 +3,7 @@
|
||||||
* [ ] Message content
|
* [ ] Message content
|
||||||
* [x] Plain text
|
* [x] Plain text
|
||||||
* [ ] Media/files
|
* [ ] Media/files
|
||||||
* [ ] Replies (RCS)
|
* [x] Replies (RCS)
|
||||||
* [ ] Reactions (RCS)
|
* [ ] Reactions (RCS)
|
||||||
* [ ] Typing notifications (RCS)
|
* [ ] Typing notifications (RCS)
|
||||||
* [ ] Read receipts (RCS)
|
* [ ] Read receipts (RCS)
|
||||||
|
|
19
portal.go
19
portal.go
|
@ -29,7 +29,7 @@ import (
|
||||||
|
|
||||||
"github.com/gabriel-vasile/mimetype"
|
"github.com/gabriel-vasile/mimetype"
|
||||||
"github.com/rs/zerolog"
|
"github.com/rs/zerolog"
|
||||||
log "maunium.net/go/maulogger/v2"
|
"maunium.net/go/maulogger/v2"
|
||||||
|
|
||||||
"maunium.net/go/mautrix"
|
"maunium.net/go/mautrix"
|
||||||
"maunium.net/go/mautrix/appservice"
|
"maunium.net/go/mautrix/appservice"
|
||||||
|
@ -220,7 +220,7 @@ type Portal struct {
|
||||||
|
|
||||||
bridge *GMBridge
|
bridge *GMBridge
|
||||||
// Deprecated: use zerolog
|
// Deprecated: use zerolog
|
||||||
log log.Logger
|
log maulogger.Logger
|
||||||
zlog zerolog.Logger
|
zlog zerolog.Logger
|
||||||
|
|
||||||
roomCreateLock sync.Mutex
|
roomCreateLock sync.Mutex
|
||||||
|
@ -999,6 +999,7 @@ func (portal *Portal) HandleMatrixMessage(sender *User, evt *event.Event, timing
|
||||||
ms := metricSender{portal: portal, timings: &timings}
|
ms := metricSender{portal: portal, timings: &timings}
|
||||||
|
|
||||||
log := portal.zlog.With().Str("event_id", evt.ID.String()).Logger()
|
log := portal.zlog.With().Str("event_id", evt.ID.String()).Logger()
|
||||||
|
ctx := log.WithContext(context.TODO())
|
||||||
log.Debug().Dur("age", timings.totalReceive).Msg("Handling Matrix message")
|
log.Debug().Dur("age", timings.totalReceive).Msg("Handling Matrix message")
|
||||||
|
|
||||||
content, ok := evt.Content.Parsed.(*event.MessageEventContent)
|
content, ok := evt.Content.Parsed.(*event.MessageEventContent)
|
||||||
|
@ -1006,6 +1007,19 @@ func (portal *Portal) HandleMatrixMessage(sender *User, evt *event.Event, timing
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var replyToID string
|
||||||
|
replyToMXID := content.RelatesTo.GetReplyTo()
|
||||||
|
if replyToMXID != "" {
|
||||||
|
replyToMsg, err := portal.bridge.DB.Message.GetByMXID(ctx, replyToMXID)
|
||||||
|
if err != nil {
|
||||||
|
log.Err(err).Str("reply_to_mxid", replyToMXID.String()).Msg("Failed to get reply target message")
|
||||||
|
} else if replyToMsg == nil {
|
||||||
|
log.Warn().Str("reply_to_mxid", replyToMXID.String()).Msg("Reply target message not found")
|
||||||
|
} else {
|
||||||
|
replyToID = replyToMsg.ID
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
txnID := util.GenerateTmpId()
|
txnID := util.GenerateTmpId()
|
||||||
portal.outgoingMessagesLock.Lock()
|
portal.outgoingMessagesLock.Lock()
|
||||||
portal.outgoingMessages[txnID] = evt.ID
|
portal.outgoingMessages[txnID] = evt.ID
|
||||||
|
@ -1020,6 +1034,7 @@ func (portal *Portal) HandleMatrixMessage(sender *User, evt *event.Event, timing
|
||||||
sender.Client.NewMessageBuilder().
|
sender.Client.NewMessageBuilder().
|
||||||
SetConversationID(portal.ID).
|
SetConversationID(portal.ID).
|
||||||
SetSelfParticipantID(portal.SelfUserID).
|
SetSelfParticipantID(portal.SelfUserID).
|
||||||
|
SetReplyMessage(replyToID).
|
||||||
SetContent(text).
|
SetContent(text).
|
||||||
SetTmpID(txnID),
|
SetTmpID(txnID),
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue