@@ -74,7 +74,7 @@ import (
74
74
api "code.gitea.io/sdk/gitea"
75
75
76
76
"github.com/go-macaron/binding"
77
- "gopkg.in/macaron.v1"
77
+ macaron "gopkg.in/macaron.v1"
78
78
)
79
79
80
80
func sudo () macaron.Handler {
@@ -371,6 +371,12 @@ func mustEnableUserHeatmap(ctx *context.Context) {
371
371
}
372
372
}
373
373
374
+ func mustNotBeArchived (ctx * context.Context ) {
375
+ if ctx .Repo .Repository .IsArchived {
376
+ ctx .Status (404 )
377
+ }
378
+ }
379
+
374
380
// RegisterRoutes registers all v1 APIs routes to web application.
375
381
// FIXME: custom form error response
376
382
func RegisterRoutes (m * macaron.Macaron ) {
@@ -518,11 +524,11 @@ func RegisterRoutes(m *macaron.Macaron) {
518
524
}, mustEnableIssues )
519
525
m .Group ("/issues" , func () {
520
526
m .Combo ("" ).Get (repo .ListIssues ).
521
- Post (reqToken (), bind (api.CreateIssueOption {}), repo .CreateIssue )
527
+ Post (reqToken (), mustNotBeArchived , bind (api.CreateIssueOption {}), repo .CreateIssue )
522
528
m .Group ("/comments" , func () {
523
529
m .Get ("" , repo .ListRepoIssueComments )
524
530
m .Combo ("/:id" , reqToken ()).
525
- Patch (bind (api.EditIssueCommentOption {}), repo .EditIssueComment ).
531
+ Patch (mustNotBeArchived , bind (api.EditIssueCommentOption {}), repo .EditIssueComment ).
526
532
Delete (repo .DeleteIssueComment )
527
533
})
528
534
m .Group ("/:index" , func () {
@@ -531,7 +537,7 @@ func RegisterRoutes(m *macaron.Macaron) {
531
537
532
538
m .Group ("/comments" , func () {
533
539
m .Combo ("" ).Get (repo .ListIssueComments ).
534
- Post (reqToken (), bind (api.CreateIssueCommentOption {}), repo .CreateIssueComment )
540
+ Post (reqToken (), mustNotBeArchived , bind (api.CreateIssueCommentOption {}), repo .CreateIssueComment )
535
541
m .Combo ("/:id" , reqToken ()).Patch (bind (api.EditIssueCommentOption {}), repo .EditIssueCommentDeprecated ).
536
542
Delete (repo .DeleteIssueCommentDeprecated )
537
543
})
@@ -593,12 +599,12 @@ func RegisterRoutes(m *macaron.Macaron) {
593
599
m .Get ("/editorconfig/:filename" , context .RepoRef (), reqRepoReader (models .UnitTypeCode ), repo .GetEditorconfig )
594
600
m .Group ("/pulls" , func () {
595
601
m .Combo ("" ).Get (bind (api.ListPullRequestsOptions {}), repo .ListPullRequests ).
596
- Post (reqToken (), bind (api.CreatePullRequestOption {}), repo .CreatePullRequest )
602
+ Post (reqToken (), mustNotBeArchived , bind (api.CreatePullRequestOption {}), repo .CreatePullRequest )
597
603
m .Group ("/:index" , func () {
598
604
m .Combo ("" ).Get (repo .GetPullRequest ).
599
605
Patch (reqToken (), reqRepoWriter (models .UnitTypePullRequests ), bind (api.EditPullRequestOption {}), repo .EditPullRequest )
600
606
m .Combo ("/merge" ).Get (repo .IsPullRequestMerged ).
601
- Post (reqToken (), reqRepoWriter (models .UnitTypePullRequests ), bind (auth.MergePullRequestForm {}), repo .MergePullRequest )
607
+ Post (reqToken (), mustNotBeArchived , reqRepoWriter (models .UnitTypePullRequests ), bind (auth.MergePullRequestForm {}), repo .MergePullRequest )
602
608
})
603
609
}, mustAllowPulls , reqRepoReader (models .UnitTypeCode ), context .ReferencesGitRepo ())
604
610
m .Group ("/statuses" , func () {
0 commit comments