mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[feature] Admin accounts endpoints; approve/reject sign-ups (#2826)
* update settings panels, add pending overview + approve/deny functions * add admin accounts get, approve, reject * send approved/rejected emails * use signup URL * docs! * email * swagger * web linting * fix email tests * wee lil fixerinos * use new paging logic for GetAccounts() series of admin endpoints, small changes to query building * shuffle useAccountIDIn check *before* adding to query * fix parse from toot react error * use `netip.Addr` * put valid slices in globals * optimistic updates for account state --------- Co-authored-by: kim <grufwub@gmail.com>
This commit is contained in:
@ -34,12 +34,13 @@ const (
|
||||
|
||||
/* Common keys */
|
||||
|
||||
IDKey = "id"
|
||||
LimitKey = "limit"
|
||||
LocalKey = "local"
|
||||
MaxIDKey = "max_id"
|
||||
SinceIDKey = "since_id"
|
||||
MinIDKey = "min_id"
|
||||
IDKey = "id"
|
||||
LimitKey = "limit"
|
||||
LocalKey = "local"
|
||||
MaxIDKey = "max_id"
|
||||
SinceIDKey = "since_id"
|
||||
MinIDKey = "min_id"
|
||||
UsernameKey = "username"
|
||||
|
||||
/* AP endpoint keys */
|
||||
|
||||
@ -61,19 +62,62 @@ const (
|
||||
|
||||
/* Web endpoint keys */
|
||||
|
||||
WebUsernameKey = "username"
|
||||
WebStatusIDKey = "status"
|
||||
|
||||
/* Domain permission keys */
|
||||
|
||||
DomainPermissionExportKey = "export"
|
||||
DomainPermissionImportKey = "import"
|
||||
|
||||
/* Admin query keys */
|
||||
|
||||
AdminRemoteKey = "remote"
|
||||
AdminActiveKey = "active"
|
||||
AdminPendingKey = "pending"
|
||||
AdminDisabledKey = "disabled"
|
||||
AdminSilencedKey = "silenced"
|
||||
AdminSuspendedKey = "suspended"
|
||||
AdminSensitizedKey = "sensitized"
|
||||
AdminDisplayNameKey = "display_name"
|
||||
AdminByDomainKey = "by_domain"
|
||||
AdminEmailKey = "email"
|
||||
AdminIPKey = "ip"
|
||||
AdminStaffKey = "staff"
|
||||
AdminOriginKey = "origin"
|
||||
AdminStatusKey = "status"
|
||||
AdminPermissionsKey = "permissions"
|
||||
AdminRoleIDsKey = "role_ids[]"
|
||||
AdminInvitedByKey = "invited_by"
|
||||
)
|
||||
|
||||
/*
|
||||
Parse functions for *OPTIONAL* parameters with default values.
|
||||
*/
|
||||
|
||||
func ParseMaxID(value string, defaultValue string) string {
|
||||
if value == "" {
|
||||
return defaultValue
|
||||
}
|
||||
|
||||
return value
|
||||
}
|
||||
|
||||
func ParseSinceID(value string, defaultValue string) string {
|
||||
if value == "" {
|
||||
return defaultValue
|
||||
}
|
||||
|
||||
return value
|
||||
}
|
||||
|
||||
func ParseMinID(value string, defaultValue string) string {
|
||||
if value == "" {
|
||||
return defaultValue
|
||||
}
|
||||
|
||||
return value
|
||||
}
|
||||
|
||||
func ParseLimit(value string, defaultValue int, max, min int) (int, gtserror.WithCode) {
|
||||
i, err := parseInt(value, defaultValue, max, min, LimitKey)
|
||||
if err != nil {
|
||||
@ -87,14 +131,6 @@ func ParseLocal(value string, defaultValue bool) (bool, gtserror.WithCode) {
|
||||
return parseBool(value, defaultValue, LocalKey)
|
||||
}
|
||||
|
||||
func ParseMaxID(value string, defaultValue string) string {
|
||||
if value == "" {
|
||||
return defaultValue
|
||||
}
|
||||
|
||||
return value
|
||||
}
|
||||
|
||||
func ParseSearchExcludeUnreviewed(value string, defaultValue bool) (bool, gtserror.WithCode) {
|
||||
return parseBool(value, defaultValue, SearchExcludeUnreviewedKey)
|
||||
}
|
||||
@ -123,6 +159,34 @@ func ParseOnlyOtherAccounts(value string, defaultValue bool) (bool, gtserror.Wit
|
||||
return parseBool(value, defaultValue, OnlyOtherAccountsKey)
|
||||
}
|
||||
|
||||
func ParseAdminRemote(value string, defaultValue bool) (bool, gtserror.WithCode) {
|
||||
return parseBool(value, defaultValue, AdminRemoteKey)
|
||||
}
|
||||
|
||||
func ParseAdminActive(value string, defaultValue bool) (bool, gtserror.WithCode) {
|
||||
return parseBool(value, defaultValue, AdminActiveKey)
|
||||
}
|
||||
|
||||
func ParseAdminPending(value string, defaultValue bool) (bool, gtserror.WithCode) {
|
||||
return parseBool(value, defaultValue, AdminPendingKey)
|
||||
}
|
||||
|
||||
func ParseAdminDisabled(value string, defaultValue bool) (bool, gtserror.WithCode) {
|
||||
return parseBool(value, defaultValue, AdminDisabledKey)
|
||||
}
|
||||
|
||||
func ParseAdminSilenced(value string, defaultValue bool) (bool, gtserror.WithCode) {
|
||||
return parseBool(value, defaultValue, AdminSilencedKey)
|
||||
}
|
||||
|
||||
func ParseAdminSuspended(value string, defaultValue bool) (bool, gtserror.WithCode) {
|
||||
return parseBool(value, defaultValue, AdminSuspendedKey)
|
||||
}
|
||||
|
||||
func ParseAdminStaff(value string, defaultValue bool) (bool, gtserror.WithCode) {
|
||||
return parseBool(value, defaultValue, AdminStaffKey)
|
||||
}
|
||||
|
||||
/*
|
||||
Parse functions for *REQUIRED* parameters.
|
||||
*/
|
||||
@ -187,8 +251,8 @@ func ParseTagName(value string) (string, gtserror.WithCode) {
|
||||
return value, nil
|
||||
}
|
||||
|
||||
func ParseWebUsername(value string) (string, gtserror.WithCode) {
|
||||
key := WebUsernameKey
|
||||
func ParseUsername(value string) (string, gtserror.WithCode) {
|
||||
key := UsernameKey
|
||||
|
||||
if value == "" {
|
||||
return "", requiredError(key)
|
||||
|
Reference in New Issue
Block a user