gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit e9b5ba0502a85a652bf2e4d8b76007767270c2af
parent 79fb8bad04662bfb5aa8990afeba4c134eb06201
Author: Blackle Morisanchetto <isabelle@blackle-mori.com>
Date:   Fri, 26 Aug 2022 11:37:51 -0400

[bugfix] Check the length of form.MediaIDs instead of just checking for null (#766)


Diffstat:
Minternal/api/client/status/statuscreate.go | 8++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/internal/api/client/status/statuscreate.go b/internal/api/client/status/statuscreate.go @@ -105,11 +105,15 @@ func (m *Module) StatusCreatePOSTHandler(c *gin.Context) { } func validateCreateStatus(form *model.AdvancedStatusCreateForm) error { - if form.Status == "" && form.MediaIDs == nil && form.Poll == nil { + hasStatus := form.Status != "" + hasMedia := len(form.MediaIDs) != 0 + hasPoll := form.Poll != nil + + if !hasStatus && !hasMedia && !hasPoll { return errors.New("no status, media, or poll provided") } - if form.MediaIDs != nil && form.Poll != nil { + if hasMedia && hasPoll { return errors.New("can't post media + poll in same status") }