Skip to content

Commit

Permalink
[bugfix] Check the length of form.MediaIDs instead of just checking f…
Browse files Browse the repository at this point in the history
…or null (#766)
  • Loading branch information
blackle committed Aug 26, 2022
1 parent 79fb8ba commit e9b5ba0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions internal/api/client/status/statuscreate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand Down

0 comments on commit e9b5ba0

Please sign in to comment.