@@ -567,6 +567,13 @@ func mustNotBeArchived(ctx *context.APIContext) {
567567 }
568568}
569569
570+ func mustEnableAttachments (ctx * context.APIContext ) {
571+ if ! setting .Attachment .Enabled {
572+ ctx .NotFound ()
573+ return
574+ }
575+ }
576+
570577// bind binding an obj to a func(ctx *context.APIContext)
571578func bind (obj interface {}) http.HandlerFunc {
572579 tp := reflect .TypeOf (obj )
@@ -892,6 +899,15 @@ func Routes(ctx gocontext.Context) *web.Route {
892899 Get (repo .GetIssueCommentReactions ).
893900 Post (reqToken (), bind (api.EditReactionOption {}), repo .PostIssueCommentReaction ).
894901 Delete (reqToken (), bind (api.EditReactionOption {}), repo .DeleteIssueCommentReaction )
902+ m .Group ("/assets" , func () {
903+ m .Combo ("" ).
904+ Get (repo .ListIssueCommentAttachments ).
905+ Post (reqToken (), mustNotBeArchived , repo .CreateIssueCommentAttachment )
906+ m .Combo ("/{asset}" ).
907+ Get (repo .GetIssueCommentAttachment ).
908+ Patch (reqToken (), mustNotBeArchived , bind (api.EditAttachmentOptions {}), repo .EditIssueCommentAttachment ).
909+ Delete (reqToken (), mustNotBeArchived , repo .DeleteIssueCommentAttachment )
910+ }, mustEnableAttachments )
895911 })
896912 })
897913 m .Group ("/{index}" , func () {
@@ -935,6 +951,15 @@ func Routes(ctx gocontext.Context) *web.Route {
935951 Get (repo .GetIssueReactions ).
936952 Post (reqToken (), bind (api.EditReactionOption {}), repo .PostIssueReaction ).
937953 Delete (reqToken (), bind (api.EditReactionOption {}), repo .DeleteIssueReaction )
954+ m .Group ("/assets" , func () {
955+ m .Combo ("" ).
956+ Get (repo .ListIssueAttachments ).
957+ Post (reqToken (), mustNotBeArchived , repo .CreateIssueAttachment )
958+ m .Combo ("/{asset}" ).
959+ Get (repo .GetIssueAttachment ).
960+ Patch (reqToken (), mustNotBeArchived , bind (api.EditAttachmentOptions {}), repo .EditIssueAttachment ).
961+ Delete (reqToken (), mustNotBeArchived , repo .DeleteIssueAttachment )
962+ }, mustEnableAttachments )
938963 })
939964 }, mustEnableIssuesOrPulls )
940965 m .Group ("/labels" , func () {
0 commit comments