summaryrefslogtreecommitdiff
path: root/internal/api/client/status/statuscreate.go
diff options
context:
space:
mode:
authorLibravatar Blackle Morisanchetto <isabelle@blackle-mori.com>2022-08-26 11:37:51 -0400
committerLibravatar GitHub <noreply@github.com>2022-08-26 17:37:51 +0200
commite9b5ba0502a85a652bf2e4d8b76007767270c2af (patch)
treeba8b4933cd026892b7ed8209732a08e6f36041f5 /internal/api/client/status/statuscreate.go
parent[feature] Allow footnotes in markdown, use `<br>` instead of `\n` (#767) (diff)
downloadgotosocial-e9b5ba0502a85a652bf2e4d8b76007767270c2af.tar.xz
[bugfix] Check the length of form.MediaIDs instead of just checking for null (#766)
Diffstat (limited to 'internal/api/client/status/statuscreate.go')
-rw-r--r--internal/api/client/status/statuscreate.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/internal/api/client/status/statuscreate.go b/internal/api/client/status/statuscreate.go
index dce6f1296..4218c9d48 100644
--- 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")
}