mirror of
				https://github.com/superseriousbusiness/gotosocial.git
				synced 2025-10-30 22:42:24 -05:00 
			
		
		
		
	[bugfix] Check the length of form.MediaIDs instead of just checking for null (#766)
This commit is contained in:
		
					parent
					
						
							
								79fb8bad04
							
						
					
				
			
			
				commit
				
					
						e9b5ba0502
					
				
			
		
					 1 changed files with 6 additions and 2 deletions
				
			
		|  | @ -105,11 +105,15 @@ func (m *Module) StatusCreatePOSTHandler(c *gin.Context) { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func validateCreateStatus(form *model.AdvancedStatusCreateForm) error { | 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") | 		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") | 		return errors.New("can't post media + poll in same status") | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue