[feature] Store delivery errors, add remote instances overview to view stored errors (#4741)
- reworks the `instances` table significantly, to remove a lot of stuff we weren't using, and add fields for storing delivery errors
- adds an `instance_settings` table that just stores local instance settings like title, description, etc, and uses this table for building responses to `/api/v1/instance` and and `/api/v2/instance`, instance metadata, etc
- passes a database connection to delivery workers so that they can store delivery errors or clear delivery errors on successful delivery
- adds admin instance endpoints `/api/v1/admin/instances` and `/api/v1/admin/instances/{instance}` for fetching admin view of instances
- adds setting panel stuff for viewing instances and whatnot
Relates to https://codeberg.org/superseriousbusiness/gotosocial/issues/2493
Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4741
Co-authored-by: tobi <tobi.smethurst@protonmail.com>
Co-committed-by: tobi <tobi.smethurst@protonmail.com>
This commit is contained in:
@@ -47,6 +47,8 @@ const (
|
||||
TargetAccountIDKey = "target_account_id"
|
||||
ResolvedKey = "resolved"
|
||||
OffsetKey = "offset"
|
||||
DomainKey = "domain"
|
||||
OrderKey = "order"
|
||||
|
||||
/* AP endpoint keys */
|
||||
|
||||
@@ -71,27 +73,27 @@ const (
|
||||
DomainPermissionImportKey = "import"
|
||||
DomainPermissionSubscriptionIDKey = "subscription_id"
|
||||
DomainPermissionPermTypeKey = "permission_type"
|
||||
DomainPermissionDomainKey = "domain"
|
||||
|
||||
/* 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"
|
||||
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"
|
||||
AdminWithErrorsOnlyKey = "with_errors_only"
|
||||
|
||||
/* Interaction policy + request keys */
|
||||
|
||||
@@ -103,10 +105,6 @@ const (
|
||||
/* Web view keys */
|
||||
|
||||
WebIncludeBoostsKey = "include_boosts"
|
||||
|
||||
/* Directory keys */
|
||||
|
||||
DirectoryOrderKey = "order"
|
||||
)
|
||||
|
||||
/*
|
||||
@@ -210,6 +208,10 @@ func ParseAdminStaff(value string, defaultValue bool) (bool, gtserror.WithCode)
|
||||
return parseBool(value, defaultValue, AdminStaffKey)
|
||||
}
|
||||
|
||||
func ParseAdminWithErrorsOnly(value string, defaultValue bool) (bool, gtserror.WithCode) {
|
||||
return parseBool(value, defaultValue, AdminWithErrorsOnlyKey)
|
||||
}
|
||||
|
||||
func ParseInteractionFavourites(value string, defaultValue bool) (bool, gtserror.WithCode) {
|
||||
return parseBool(value, defaultValue, InteractionFavouritesKey)
|
||||
}
|
||||
@@ -240,6 +242,20 @@ func ParseDirectoryOrder(value string, defaultValue gtsmodel.DirectoryOrderBy) (
|
||||
}
|
||||
}
|
||||
|
||||
func ParseInstancesOrder(value string, defaultValue gtsmodel.InstanceOrderBy) (gtsmodel.InstanceOrderBy, gtserror.WithCode) {
|
||||
switch strings.ToLower(value) {
|
||||
case "":
|
||||
return defaultValue, nil
|
||||
case "alphabetical":
|
||||
return gtsmodel.InstanceOrderByAlphabetical, nil
|
||||
case "first_seen":
|
||||
return gtsmodel.InstanceOrderByFirstSeen, nil
|
||||
default:
|
||||
const errText = "invalid value for order, valid values are '', 'alphabetical', or 'first_seen'"
|
||||
return gtsmodel.InstanceOrderByUnknown, gtserror.NewErrorBadRequest(errors.New(errText), errText)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Parse functions for *REQUIRED* parameters.
|
||||
*/
|
||||
|
||||
@@ -39,6 +39,7 @@ const (
|
||||
scopeFavourites = "favourites"
|
||||
scopeFilters = "filters"
|
||||
scopeFollows = "follows"
|
||||
scopeInstances = "instances"
|
||||
scopeLists = "lists"
|
||||
scopeMedia = "media"
|
||||
scopeMutes = "mutes"
|
||||
@@ -97,6 +98,7 @@ const (
|
||||
ScopeAdminWriteDomainBlocks Scope = ScopeAdminWrite + ":" + scopeDomainBlocks
|
||||
ScopeAdminReadDomainLimits Scope = ScopeAdminRead + ":" + scopeDomainLimits
|
||||
ScopeAdminWriteDomainLimits Scope = ScopeAdminWrite + ":" + scopeDomainLimits
|
||||
ScopeAdminReadInstances Scope = ScopeAdminRead + ":" + scopeInstances
|
||||
ScopeAdminReadReports Scope = ScopeAdminRead + ":" + scopeReports
|
||||
ScopeAdminWriteReports Scope = ScopeAdminWrite + ":" + scopeReports
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user