@@ -567,6 +567,13 @@ func mustNotBeArchived(ctx *context.APIContext) {
567
567
}
568
568
}
569
569
570
+ func mustEnableAttachments (ctx * context.APIContext ) {
571
+ if ! setting .Attachment .Enabled {
572
+ ctx .NotFound ()
573
+ return
574
+ }
575
+ }
576
+
570
577
// bind binding an obj to a func(ctx *context.APIContext)
571
578
func bind (obj interface {}) http.HandlerFunc {
572
579
tp := reflect .TypeOf (obj )
@@ -892,6 +899,15 @@ func Routes(ctx gocontext.Context) *web.Route {
892
899
Get (repo .GetIssueCommentReactions ).
893
900
Post (reqToken (), bind (api.EditReactionOption {}), repo .PostIssueCommentReaction ).
894
901
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 )
895
911
})
896
912
})
897
913
m .Group ("/{index}" , func () {
@@ -935,6 +951,15 @@ func Routes(ctx gocontext.Context) *web.Route {
935
951
Get (repo .GetIssueReactions ).
936
952
Post (reqToken (), bind (api.EditReactionOption {}), repo .PostIssueReaction ).
937
953
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 )
938
963
})
939
964
}, mustEnableIssuesOrPulls )
940
965
m .Group ("/labels" , func () {
0 commit comments