diff options
Diffstat (limited to 'internal/api')
-rw-r--r-- | internal/api/client/admin/reportsget_test.go | 64 | ||||
-rw-r--r-- | internal/api/client/instance/instancepatch_test.go | 24 | ||||
-rw-r--r-- | internal/api/model/account.go | 21 | ||||
-rw-r--r-- | internal/api/model/admin.go | 2 |
4 files changed, 80 insertions, 31 deletions
diff --git a/internal/api/client/admin/reportsget_test.go b/internal/api/client/admin/reportsget_test.go index f35720011..706dcbc44 100644 --- a/internal/api/client/admin/reportsget_test.go +++ b/internal/api/client/admin/reportsget_test.go @@ -156,7 +156,9 @@ func (suite *ReportsGetTestSuite) TestReportsGet1() { "ips": [], "locale": "", "invite_request": null, - "role": "user", + "role": { + "name": "user" + }, "confirmed": false, "approved": false, "disabled": false, @@ -195,7 +197,9 @@ func (suite *ReportsGetTestSuite) TestReportsGet1() { "ips": [], "locale": "en", "invite_request": "", - "role": "user", + "role": { + "name": "user" + }, "confirmed": true, "approved": true, "disabled": false, @@ -222,7 +226,9 @@ func (suite *ReportsGetTestSuite) TestReportsGet1() { "last_status_at": "2021-10-20T10:40:37.000Z", "emojis": [], "fields": [], - "role": "user" + "role": { + "name": "user" + } }, "created_by_application_id": "01F8MGY43H3N2C8EWPR2FPYEXG" }, @@ -236,7 +242,9 @@ func (suite *ReportsGetTestSuite) TestReportsGet1() { "ips": [], "locale": "en", "invite_request": "", - "role": "admin", + "role": { + "name": "admin" + }, "confirmed": true, "approved": true, "disabled": false, @@ -264,7 +272,9 @@ func (suite *ReportsGetTestSuite) TestReportsGet1() { "emojis": [], "fields": [], "enable_rss": true, - "role": "admin" + "role": { + "name": "admin" + } }, "created_by_application_id": "01F8MGXQRHYF5QPMTMXP78QC2F" }, @@ -278,7 +288,9 @@ func (suite *ReportsGetTestSuite) TestReportsGet1() { "ips": [], "locale": "en", "invite_request": "", - "role": "admin", + "role": { + "name": "admin" + }, "confirmed": true, "approved": true, "disabled": false, @@ -306,7 +318,9 @@ func (suite *ReportsGetTestSuite) TestReportsGet1() { "emojis": [], "fields": [], "enable_rss": true, - "role": "admin" + "role": { + "name": "admin" + } }, "created_by_application_id": "01F8MGXQRHYF5QPMTMXP78QC2F" }, @@ -333,7 +347,9 @@ func (suite *ReportsGetTestSuite) TestReportsGet1() { "ips": [], "locale": "en", "invite_request": "", - "role": "user", + "role": { + "name": "user" + }, "confirmed": true, "approved": true, "disabled": false, @@ -360,7 +376,9 @@ func (suite *ReportsGetTestSuite) TestReportsGet1() { "last_status_at": "2021-10-20T10:40:37.000Z", "emojis": [], "fields": [], - "role": "user" + "role": { + "name": "user" + } }, "created_by_application_id": "01F8MGY43H3N2C8EWPR2FPYEXG" }, @@ -374,7 +392,9 @@ func (suite *ReportsGetTestSuite) TestReportsGet1() { "ips": [], "locale": "", "invite_request": null, - "role": "user", + "role": { + "name": "user" + }, "confirmed": false, "approved": false, "disabled": false, @@ -528,7 +548,9 @@ func (suite *ReportsGetTestSuite) TestReportsGet2() { "ips": [], "locale": "en", "invite_request": "", - "role": "user", + "role": { + "name": "user" + }, "confirmed": true, "approved": true, "disabled": false, @@ -555,7 +577,9 @@ func (suite *ReportsGetTestSuite) TestReportsGet2() { "last_status_at": "2021-10-20T10:40:37.000Z", "emojis": [], "fields": [], - "role": "user" + "role": { + "name": "user" + } }, "created_by_application_id": "01F8MGY43H3N2C8EWPR2FPYEXG" }, @@ -569,7 +593,9 @@ func (suite *ReportsGetTestSuite) TestReportsGet2() { "ips": [], "locale": "", "invite_request": null, - "role": "user", + "role": { + "name": "user" + }, "confirmed": false, "approved": false, "disabled": false, @@ -723,7 +749,9 @@ func (suite *ReportsGetTestSuite) TestReportsGet3() { "ips": [], "locale": "en", "invite_request": "", - "role": "user", + "role": { + "name": "user" + }, "confirmed": true, "approved": true, "disabled": false, @@ -750,7 +778,9 @@ func (suite *ReportsGetTestSuite) TestReportsGet3() { "last_status_at": "2021-10-20T10:40:37.000Z", "emojis": [], "fields": [], - "role": "user" + "role": { + "name": "user" + } }, "created_by_application_id": "01F8MGY43H3N2C8EWPR2FPYEXG" }, @@ -764,7 +794,9 @@ func (suite *ReportsGetTestSuite) TestReportsGet3() { "ips": [], "locale": "", "invite_request": null, - "role": "user", + "role": { + "name": "user" + }, "confirmed": false, "approved": false, "disabled": false, diff --git a/internal/api/client/instance/instancepatch_test.go b/internal/api/client/instance/instancepatch_test.go index 9233bc2b9..0a508083c 100644 --- a/internal/api/client/instance/instancepatch_test.go +++ b/internal/api/client/instance/instancepatch_test.go @@ -151,7 +151,9 @@ func (suite *InstancePatchTestSuite) TestInstancePatch1() { "emojis": [], "fields": [], "enable_rss": true, - "role": "admin" + "role": { + "name": "admin" + } }, "max_toot_chars": 5000 }`, dst.String()) @@ -247,7 +249,9 @@ func (suite *InstancePatchTestSuite) TestInstancePatch2() { "emojis": [], "fields": [], "enable_rss": true, - "role": "admin" + "role": { + "name": "admin" + } }, "max_toot_chars": 5000 }`, dst.String()) @@ -343,7 +347,9 @@ func (suite *InstancePatchTestSuite) TestInstancePatch3() { "emojis": [], "fields": [], "enable_rss": true, - "role": "admin" + "role": { + "name": "admin" + } }, "max_toot_chars": 5000 }`, dst.String()) @@ -490,7 +496,9 @@ func (suite *InstancePatchTestSuite) TestInstancePatch6() { "emojis": [], "fields": [], "enable_rss": true, - "role": "admin" + "role": { + "name": "admin" + } }, "max_toot_chars": 5000 }`, dst.String()) @@ -609,7 +617,9 @@ func (suite *InstancePatchTestSuite) TestInstancePatch8() { "emojis": [], "fields": [], "enable_rss": true, - "role": "admin" + "role": { + "name": "admin" + } }, "max_toot_chars": 5000 }`, dst.String()) @@ -740,7 +750,9 @@ func (suite *InstancePatchTestSuite) TestInstancePatch9() { "emojis": [], "fields": [], "enable_rss": true, - "role": "admin" + "role": { + "name": "admin" + } }, "max_toot_chars": 5000 }`, dst.String()) diff --git a/internal/api/model/account.go b/internal/api/model/account.go index ddfe6cc3a..238def59d 100644 --- a/internal/api/model/account.go +++ b/internal/api/model/account.go @@ -96,8 +96,7 @@ type Account struct { EnableRSS bool `json:"enable_rss,omitempty"` // Role of the account on this instance. // Omitted for remote accounts. - // example: user - Role AccountRole `json:"role,omitempty"` + Role *AccountRole `json:"role,omitempty"` } // AccountCreateRequest models account creation parameters. @@ -215,13 +214,19 @@ type AccountDeleteRequest struct { // AccountRole models the role of an account. // -// swagger:enum accountRole +// swagger:model accountRole +type AccountRole struct { + Name AccountRoleName `json:"name"` +} + +// AccountRoleName represent the name of the role of an account. +// // swagger:type string -type AccountRole string +type AccountRoleName string const ( - AccountRoleUser AccountRole = "user" // Standard user - AccountRoleModerator AccountRole = "moderator" // Moderator privileges - AccountRoleAdmin AccountRole = "admin" // Instance admin - AccountRoleUnknown AccountRole = "" // We don't know / remote account + AccountRoleUser AccountRoleName = "user" // Standard user + AccountRoleModerator AccountRoleName = "moderator" // Moderator privileges + AccountRoleAdmin AccountRoleName = "admin" // Instance admin + AccountRoleUnknown AccountRoleName = "" // We don't know / remote account ) diff --git a/internal/api/model/admin.go b/internal/api/model/admin.go index df688694d..cc5503770 100644 --- a/internal/api/model/admin.go +++ b/internal/api/model/admin.go @@ -56,7 +56,7 @@ type AdminAccountInfo struct { // example: Pleaaaaaaaaaaaaaaase!! InviteRequest *string `json:"invite_request"` // The current role of the account. - Role string `json:"role"` + Role AccountRole `json:"role"` // Whether the account has confirmed their email address. Confirmed bool `json:"confirmed"` // Whether the account is currently approved. |