From cf80de9f1a18c43c67615ecf33dd6e8019cd4f44 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Fri, 27 Sep 2024 20:45:47 +0300 Subject: [PATCH] bridgev2: don't include weeks in disappearing timer notices --- bridgev2/portal.go | 5 +++-- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/bridgev2/portal.go b/bridgev2/portal.go index 40e4b6ca..fcff8348 100644 --- a/bridgev2/portal.go +++ b/bridgev2/portal.go @@ -3187,12 +3187,13 @@ func (portal *Portal) updateUserLocalInfo(ctx context.Context, info *UserLocalPo } func DisappearingMessageNotice(expiration time.Duration, implicit bool) *event.MessageEventContent { + formattedDuration := exfmt.DurationCustom(expiration, nil, exfmt.Day, time.Hour, time.Minute, time.Second) content := &event.MessageEventContent{ MsgType: event.MsgNotice, - Body: fmt.Sprintf("Set the disappearing message timer to %s", exfmt.Duration(expiration)), + Body: fmt.Sprintf("Set the disappearing message timer to %s", formattedDuration), } if implicit { - content.Body = fmt.Sprintf("Automatically enabled disappearing message timer (%s) because incoming message is disappearing", exfmt.Duration(expiration)) + content.Body = fmt.Sprintf("Automatically enabled disappearing message timer (%s) because incoming message is disappearing", formattedDuration) } else if expiration == 0 { content.Body = "Turned off disappearing messages" } diff --git a/go.mod b/go.mod index ed1f66cf..affeeb31 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,7 @@ require ( github.com/tidwall/gjson v1.17.3 github.com/tidwall/sjson v1.2.5 github.com/yuin/goldmark v1.7.4 - go.mau.fi/util v0.8.0 + go.mau.fi/util v0.8.1-0.20240927174413-000d30f9a02a go.mau.fi/zeroconfig v0.1.3 golang.org/x/crypto v0.27.0 golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 diff --git a/go.sum b/go.sum index 8974dea6..c5058f61 100644 --- a/go.sum +++ b/go.sum @@ -51,8 +51,8 @@ github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY= github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28= github.com/yuin/goldmark v1.7.4 h1:BDXOHExt+A7gwPCJgPIIq7ENvceR7we7rOS9TNoLZeg= github.com/yuin/goldmark v1.7.4/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E= -go.mau.fi/util v0.8.0 h1:MiSny8jgQq4XtCLAT64gDJhZVhqiDeMVIEBDFVw+M0g= -go.mau.fi/util v0.8.0/go.mod h1:1Ixb8HWoVbl3rT6nAX6nV4iMkzn7KU/KXwE0Rn5RmsQ= +go.mau.fi/util v0.8.1-0.20240927174413-000d30f9a02a h1:4TrWJ0ooHT9YssDBUgXNU8FiR2cwi9jEAjtaVur4f0M= +go.mau.fi/util v0.8.1-0.20240927174413-000d30f9a02a/go.mod h1:1Ixb8HWoVbl3rT6nAX6nV4iMkzn7KU/KXwE0Rn5RmsQ= go.mau.fi/zeroconfig v0.1.3 h1:As9wYDKmktjmNZW5i1vn8zvJlmGKHeVxHVIBMXsm4kM= go.mau.fi/zeroconfig v0.1.3/go.mod h1:NcSJkf180JT+1IId76PcMuLTNa1CzsFFZ0nBygIQM70= golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=