mirror of
				https://codeberg.org/forgejo/forgejo.git
				synced 2025-11-04 00:11:04 +00:00 
			
		
		
		
	Fix #321. Allow empty comments as long as there are attachments.
This commit is contained in:
		
					parent
					
						
							
								30d7397f97
							
						
					
				
			
			
				commit
				
					
						dedb156d4a
					
				
			
		
					 2 changed files with 7 additions and 2 deletions
				
			
		| 
						 | 
					@ -755,7 +755,8 @@ func Comment(ctx *middleware.Context, params martini.Params) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var ms []string
 | 
						var ms []string
 | 
				
			||||||
	content := ctx.Query("content")
 | 
						content := ctx.Query("content")
 | 
				
			||||||
	if len(content) > 0 {
 | 
						// Fix #321. Allow empty comments, as long as we have attachments.
 | 
				
			||||||
 | 
						if len(content) > 0 || len(ctx.Req.MultipartForm.File["attachments"]) > 0 {
 | 
				
			||||||
		switch params["action"] {
 | 
							switch params["action"] {
 | 
				
			||||||
		case "new":
 | 
							case "new":
 | 
				
			||||||
			if comment, err = models.CreateComment(ctx.User.Id, ctx.Repo.Repository.Id, issue.Id, 0, 0, models.COMMENT, content, nil); err != nil {
 | 
								if comment, err = models.CreateComment(ctx.User.Id, ctx.Repo.Repository.Id, issue.Id, 0, 0, models.COMMENT, content, nil); err != nil {
 | 
				
			||||||
| 
						 | 
					@ -1081,5 +1082,5 @@ func IssueGetAttachment(ctx *middleware.Context, params martini.Params) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Fix #312. Attachments with , in their name are not handled correctly by Google Chrome.
 | 
						// Fix #312. Attachments with , in their name are not handled correctly by Google Chrome.
 | 
				
			||||||
	// We must put the name in " manually.
 | 
						// We must put the name in " manually.
 | 
				
			||||||
	ctx.ServeFile(attachment.Path, "\"" + attachment.Name + "\"")
 | 
						ctx.ServeFile(attachment.Path, "\""+attachment.Name+"\"")
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -72,7 +72,11 @@
 | 
				
			||||||
                                <span class="role label label-default pull-right">Owner</span>
 | 
					                                <span class="role label label-default pull-right">Owner</span>
 | 
				
			||||||
                            </div>
 | 
					                            </div>
 | 
				
			||||||
                            <div class="panel-body markdown">
 | 
					                            <div class="panel-body markdown">
 | 
				
			||||||
 | 
					                                {{if len .Content}}
 | 
				
			||||||
                                {{str2html .Content}}
 | 
					                                {{str2html .Content}}
 | 
				
			||||||
 | 
					                                {{else}}
 | 
				
			||||||
 | 
					                                <i>No comment entered</i>
 | 
				
			||||||
 | 
					                                {{end}}
 | 
				
			||||||
                            </div>
 | 
					                            </div>
 | 
				
			||||||
                            {{with $attachments := .Attachments}}
 | 
					                            {{with $attachments := .Attachments}}
 | 
				
			||||||
                            {{if $attachments}}
 | 
					                            {{if $attachments}}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue