@@ -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,13 @@ 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
+ return
378
+ }
379
+ }
380
+
374
381
// RegisterRoutes registers all v1 APIs routes to web application.
375
382
// FIXME: custom form error response
376
383
func RegisterRoutes (m * macaron.Macaron ) {
@@ -518,11 +525,11 @@ func RegisterRoutes(m *macaron.Macaron) {
518
525
}, mustEnableIssues )
519
526
m .Group ("/issues" , func () {
520
527
m .Combo ("" ).Get (repo .ListIssues ).
521
- Post (reqToken (), bind (api.CreateIssueOption {}), repo .CreateIssue )
528
+ Post (reqToken (), mustNotBeArchived , bind (api.CreateIssueOption {}), repo .CreateIssue )
522
529
m .Group ("/comments" , func () {
523
530
m .Get ("" , repo .ListRepoIssueComments )
524
531
m .Combo ("/:id" , reqToken ()).
525
- Patch (bind (api.EditIssueCommentOption {}), repo .EditIssueComment ).
532
+ Patch (mustNotBeArchived , bind (api.EditIssueCommentOption {}), repo .EditIssueComment ).
526
533
Delete (repo .DeleteIssueComment )
527
534
})
528
535
m .Group ("/:index" , func () {
@@ -531,7 +538,7 @@ func RegisterRoutes(m *macaron.Macaron) {
531
538
532
539
m .Group ("/comments" , func () {
533
540
m .Combo ("" ).Get (repo .ListIssueComments ).
534
- Post (reqToken (), bind (api.CreateIssueCommentOption {}), repo .CreateIssueComment )
541
+ Post (reqToken (), mustNotBeArchived , bind (api.CreateIssueCommentOption {}), repo .CreateIssueComment )
535
542
m .Combo ("/:id" , reqToken ()).Patch (bind (api.EditIssueCommentOption {}), repo .EditIssueCommentDeprecated ).
536
543
Delete (repo .DeleteIssueCommentDeprecated )
537
544
})
@@ -593,12 +600,12 @@ func RegisterRoutes(m *macaron.Macaron) {
593
600
m .Get ("/editorconfig/:filename" , context .RepoRef (), reqRepoReader (models .UnitTypeCode ), repo .GetEditorconfig )
594
601
m .Group ("/pulls" , func () {
595
602
m .Combo ("" ).Get (bind (api.ListPullRequestsOptions {}), repo .ListPullRequests ).
596
- Post (reqToken (), bind (api.CreatePullRequestOption {}), repo .CreatePullRequest )
603
+ Post (reqToken (), mustNotBeArchived , bind (api.CreatePullRequestOption {}), repo .CreatePullRequest )
597
604
m .Group ("/:index" , func () {
598
605
m .Combo ("" ).Get (repo .GetPullRequest ).
599
606
Patch (reqToken (), reqRepoWriter (models .UnitTypePullRequests ), bind (api.EditPullRequestOption {}), repo .EditPullRequest )
600
607
m .Combo ("/merge" ).Get (repo .IsPullRequestMerged ).
601
- Post (reqToken (), reqRepoWriter (models .UnitTypePullRequests ), bind (auth.MergePullRequestForm {}), repo .MergePullRequest )
608
+ Post (reqToken (), mustNotBeArchived , reqRepoWriter (models .UnitTypePullRequests ), bind (auth.MergePullRequestForm {}), repo .MergePullRequest )
602
609
})
603
610
}, mustAllowPulls , reqRepoReader (models .UnitTypeCode ), context .ReferencesGitRepo ())
604
611
m .Group ("/statuses" , func () {
0 commit comments