use proper thread IDs on metadata save and error reporting

This commit is contained in:
Aine
2023-09-27 15:07:55 +03:00
parent 816db6f409
commit 7fbb279830
3 changed files with 39 additions and 5 deletions

View File

@@ -93,6 +93,11 @@ func New(
// Error message to the log and matrix room
func (b *Bot) Error(ctx context.Context, message string, args ...interface{}) {
evt := eventFromContext(ctx)
threadID := threadIDFromContext(ctx)
if threadID == "" {
threadID = linkpearl.EventParent(evt.ID, evt.Content.AsMessage())
}
err := fmt.Errorf(message, args...)
b.log.Error().Err(err).Msg(err.Error())
if evt == nil {
@@ -105,7 +110,7 @@ func (b *Bot) Error(ctx context.Context, message string, args ...interface{}) {
noThreads = cfg.NoThreads()
}
b.lp.SendNotice(evt.RoomID, "ERROR: "+err.Error(), utils.RelatesTo(!noThreads, evt.ID))
b.lp.SendNotice(evt.RoomID, "ERROR: "+err.Error(), utils.RelatesTo(!noThreads, threadID))
}
// Start performs matrix /sync