BREAKING: update mautrix to 0.15.x

This commit is contained in:
Aine
2023-06-01 14:32:20 +00:00
parent a6b20a75ab
commit 2bdb8ca635
222 changed files with 7851 additions and 23986 deletions

View File

@@ -19,7 +19,7 @@ func (q *Queue) Add(id, from, to, data string) error {
defer q.mu.Unlock(itemkey)
err := q.lp.SetAccountData(itemkey, item)
if err != nil {
q.log.Error("cannot enqueue email id=%q: %v", id, err)
q.log.Error().Err(err).Str("id", id).Msg("cannot enqueue email")
return err
}
@@ -27,13 +27,13 @@ func (q *Queue) Add(id, from, to, data string) error {
defer q.mu.Unlock(acQueueKey)
queueIndex, err := q.lp.GetAccountData(acQueueKey)
if err != nil {
q.log.Error("cannot get queue index: %v", err)
q.log.Error().Err(err).Msg("cannot get queue index")
return err
}
queueIndex[id] = itemkey
err = q.lp.SetAccountData(acQueueKey, queueIndex)
if err != nil {
q.log.Error("cannot save queue index: %v", err)
q.log.Error().Err(err).Msg("cannot save queue index")
return err
}
@@ -44,7 +44,7 @@ func (q *Queue) Add(id, from, to, data string) error {
func (q *Queue) Remove(id string) error {
index, err := q.lp.GetAccountData(acQueueKey)
if err != nil {
q.log.Error("cannot get queue index: %v", err)
q.log.Error().Err(err).Msg("cannot get queue index")
return err
}
itemkey := index[id]
@@ -54,7 +54,7 @@ func (q *Queue) Remove(id string) error {
delete(index, id)
err = q.lp.SetAccountData(acQueueKey, index)
if err != nil {
q.log.Error("cannot update queue index: %v", err)
q.log.Error().Err(err).Msg("cannot update queue index")
return err
}
@@ -70,13 +70,13 @@ func (q *Queue) try(itemkey string, maxRetries int) bool {
item, err := q.lp.GetAccountData(itemkey)
if err != nil {
q.log.Error("cannot retrieve a queue item %q: %v", itemkey, err)
q.log.Error().Err(err).Str("id", itemkey).Msg("cannot retrieve a queue item")
return false
}
q.log.Debug("processing queue item %+v", item)
q.log.Debug().Any("item", item).Msg("processing queue item")
attempts, err := strconv.Atoi(item["attempts"])
if err != nil {
q.log.Error("cannot parse attempts of %q: %v", itemkey, err)
q.log.Error().Err(err).Str("id", itemkey).Msg("cannot parse attempts")
return false
}
if attempts > maxRetries {
@@ -85,16 +85,16 @@ func (q *Queue) try(itemkey string, maxRetries int) bool {
err = q.sendmail(item["from"], item["to"], item["data"])
if err == nil {
q.log.Info("email %q from queue was delivered")
q.log.Info().Str("id", itemkey).Msg("email from queue was delivered")
return true
}
q.log.Info("attempted to deliver email id=%q, retry=%q, but it's not ready yet: %v", item["id"], item["attempts"], err)
q.log.Info().Str("id", itemkey).Str("from", item["from"]).Str("to", item["to"]).Err(err).Msg("attempted to deliver email, but it's not ready yet")
attempts++
item["attempts"] = strconv.Itoa(attempts)
err = q.lp.SetAccountData(itemkey, item)
if err != nil {
q.log.Error("cannot update attempt count on email %q: %v", itemkey, err)
q.log.Error().Err(err).Str("id", itemkey).Msg("cannot update attempt count on email")
}
return false