File tree Expand file tree Collapse file tree 6 files changed +94
-0
lines changed Expand file tree Collapse file tree 6 files changed +94
-0
lines changed Original file line number Diff line number Diff line change @@ -46,4 +46,16 @@ func TestAPIExposedSettings(t *testing.T) {
46
46
MirrorsDisabled : setting .Repository .DisableMirrors ,
47
47
HTTPGitDisabled : setting .Repository .DisableHTTPGit ,
48
48
}, repo )
49
+
50
+ attachment := new (api.GeneralAttachmentSettings )
51
+ req = NewRequest (t , "GET" , "/api/v1/settings/attachment" )
52
+ resp = MakeRequest (t , req , http .StatusOK )
53
+
54
+ DecodeJSON (t , resp , & attachment )
55
+ assert .EqualValues (t , & api.GeneralAttachmentSettings {
56
+ Enabled : setting .Attachment .Enabled ,
57
+ AllowedTypes : setting .Attachment .AllowedTypes ,
58
+ MaxFiles : setting .Attachment .MaxFiles ,
59
+ MaxSize : setting .Attachment .MaxSize ,
60
+ }, attachment )
49
61
}
Original file line number Diff line number Diff line change @@ -22,3 +22,11 @@ type GeneralAPISettings struct {
22
22
DefaultGitTreesPerPage int `json:"default_git_trees_per_page"`
23
23
DefaultMaxBlobSize int64 `json:"default_max_blob_size"`
24
24
}
25
+
26
+ // GeneralAttachmentSettings contains global Attachment settings exposed by API
27
+ type GeneralAttachmentSettings struct {
28
+ Enabled bool `json:"enabled"`
29
+ AllowedTypes string `json:"allowed_types"`
30
+ MaxSize int64 `json:"max_size"`
31
+ MaxFiles int `json:"max_files"`
32
+ }
Original file line number Diff line number Diff line change @@ -522,6 +522,7 @@ func RegisterRoutes(m *macaron.Macaron) {
522
522
m .Group ("/settings" , func () {
523
523
m .Get ("/ui" , settings .GetGeneralUISettings )
524
524
m .Get ("/api" , settings .GetGeneralAPISettings )
525
+ m .Get ("/attachment" , settings .GetGeneralAttachmentSettings )
525
526
m .Get ("/repository" , settings .GetGeneralRepoSettings )
526
527
})
527
528
Original file line number Diff line number Diff line change @@ -60,3 +60,21 @@ func GetGeneralRepoSettings(ctx *context.APIContext) {
60
60
HTTPGitDisabled : setting .Repository .DisableHTTPGit ,
61
61
})
62
62
}
63
+
64
+ // GetGeneralAttachmentSettings returns instance's global settings for Attachment
65
+ func GetGeneralAttachmentSettings (ctx * context.APIContext ) {
66
+ // swagger:operation GET /settings/Attachment settings getGeneralAttachmentSettings
67
+ // ---
68
+ // summary: Get instance's global settings for Attachment
69
+ // produces:
70
+ // - application/json
71
+ // responses:
72
+ // "200":
73
+ // "$ref": "#/responses/GeneralAttachmentSettings"
74
+ ctx .JSON (http .StatusOK , api.GeneralAttachmentSettings {
75
+ Enabled : setting .Attachment .Enabled ,
76
+ AllowedTypes : setting .Attachment .AllowedTypes ,
77
+ MaxFiles : setting .Attachment .MaxFiles ,
78
+ MaxSize : setting .Attachment .MaxSize ,
79
+ })
80
+ }
Original file line number Diff line number Diff line change @@ -26,3 +26,10 @@ type swaggerResponseGeneralAPISettings struct {
26
26
// in:body
27
27
Body api.GeneralAPISettings `json:"body"`
28
28
}
29
+
30
+ // GeneralAttachmentSettings
31
+ // swagger:response GeneralAttachmentSettings
32
+ type swaggerResponseGeneralAttachmentSettings struct {
33
+ // in:body
34
+ Body api.GeneralAttachmentSettings `json:"body"`
35
+ }
Original file line number Diff line number Diff line change 8672
8672
}
8673
8673
}
8674
8674
},
8675
+ "/settings/Attachment": {
8676
+ "get": {
8677
+ "produces": [
8678
+ "application/json"
8679
+ ],
8680
+ "tags": [
8681
+ "settings"
8682
+ ],
8683
+ "summary": "Get instance's global settings for Attachment",
8684
+ "operationId": "getGeneralAttachmentSettings",
8685
+ "responses": {
8686
+ "200": {
8687
+ "$ref": "#/responses/GeneralAttachmentSettings"
8688
+ }
8689
+ }
8690
+ }
8691
+ },
8675
8692
"/settings/api": {
8676
8693
"get": {
8677
8694
"produces": [
13021
13038
},
13022
13039
"x-go-package": "code.gitea.io/gitea/modules/structs"
13023
13040
},
13041
+ "GeneralAttachmentSettings": {
13042
+ "description": "GeneralAttachmentSettings contains global Attachment settings exposed by API",
13043
+ "type": "object",
13044
+ "properties": {
13045
+ "allowed_types": {
13046
+ "type": "string",
13047
+ "x-go-name": "AllowedTypes"
13048
+ },
13049
+ "enabled": {
13050
+ "type": "boolean",
13051
+ "x-go-name": "Enabled"
13052
+ },
13053
+ "max_files": {
13054
+ "type": "integer",
13055
+ "format": "int64",
13056
+ "x-go-name": "MaxFiles"
13057
+ },
13058
+ "max_size": {
13059
+ "type": "integer",
13060
+ "format": "int64",
13061
+ "x-go-name": "MaxSize"
13062
+ }
13063
+ },
13064
+ "x-go-package": "code.gitea.io/gitea/modules/structs"
13065
+ },
13024
13066
"GeneralRepoSettings": {
13025
13067
"description": "GeneralRepoSettings contains global repository settings exposed by API",
13026
13068
"type": "object",
15247
15289
"$ref": "#/definitions/GeneralAPISettings"
15248
15290
}
15249
15291
},
15292
+ "GeneralAttachmentSettings": {
15293
+ "description": "GeneralAttachmentSettings",
15294
+ "schema": {
15295
+ "$ref": "#/definitions/GeneralAttachmentSettings"
15296
+ }
15297
+ },
15250
15298
"GeneralRepoSettings": {
15251
15299
"description": "GeneralRepoSettings",
15252
15300
"schema": {
You can’t perform that action at this time.
0 commit comments