summaryrefslogtreecommitdiff
path: root/internal/api/client/accounts/mute.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2024-11-05 13:29:51 +0100
committerLibravatar GitHub <noreply@github.com>2024-11-05 13:29:51 +0100
commite953d80dff4298bccb4bc96e80e2a0e5831936f5 (patch)
tree4ba7e950c58d105fc04ff2b7b53753475cf06413 /internal/api/client/accounts/mute.go
parentpreviously we were using the ffmpeg runner for ffprobe :facepalm: (#3512) (diff)
downloadgotosocial-e953d80dff4298bccb4bc96e80e2a0e5831936f5.tar.xz
[bugfix] Fix setting immediate `expires_at` value on filter endpoints (#3513)v0.17.2
* [bugfix] Fix setting immediate `expires_at` value on filter endpoints * update wording * update wording * oh my
Diffstat (limited to 'internal/api/client/accounts/mute.go')
-rw-r--r--internal/api/client/accounts/mute.go28
1 files changed, 8 insertions, 20 deletions
diff --git a/internal/api/client/accounts/mute.go b/internal/api/client/accounts/mute.go
index affb0f055..c9a57a348 100644
--- a/internal/api/client/accounts/mute.go
+++ b/internal/api/client/accounts/mute.go
@@ -19,9 +19,7 @@ package accounts
import (
"errors"
- "fmt"
"net/http"
- "strconv"
"github.com/gin-gonic/gin"
apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model"
@@ -140,25 +138,15 @@ func normalizeCreateUpdateMute(form *apimodel.UserMuteCreateUpdateRequest) error
// Apply defaults for missing fields.
form.Notifications = util.Ptr(util.PtrOrValue(form.Notifications, false))
- // Normalize mute duration if necessary.
- // If we parsed this as JSON, expires_in
- // may be either a float64 or a string.
- if ei := form.DurationI; ei != nil {
- switch e := ei.(type) {
- case float64:
- form.Duration = util.Ptr(int(e))
-
- case string:
- duration, err := strconv.Atoi(e)
- if err != nil {
- return fmt.Errorf("could not parse duration value %s as integer: %w", e, err)
- }
-
- form.Duration = &duration
-
- default:
- return fmt.Errorf("could not parse expires_in type %T as integer", ei)
+ // Normalize duration if necessary.
+ if form.DurationI != nil {
+ // If we parsed this as JSON, duration
+ // may be either a float64 or a string.
+ duration, err := apiutil.ParseDuration(form.DurationI, "duration")
+ if err != nil {
+ return err
}
+ form.Duration = duration
}
// Interpret zero as indefinite duration.