summaryrefslogtreecommitdiff
path: root/internal/api/client/admin/admin.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2023-01-25 11:12:17 +0100
committerLibravatar GitHub <noreply@github.com>2023-01-25 11:12:17 +0100
commitfaeb7ded3b5d595910f424fd9cf9c6fe5935e648 (patch)
tree5c50b950277ab985e73bfaf027b53ee82f4917a6 /internal/api/client/admin/admin.go
parent[chore] Settings refactor fix4 (#1383) (diff)
downloadgotosocial-faeb7ded3b5d595910f424fd9cf9c6fe5935e648.tar.xz
[feature] Implement reports admin API so admins can view + close reports (#1378)
* add admin report api endpoints + tests * [chore] remove funky duplicate attachment in testrig
Diffstat (limited to 'internal/api/client/admin/admin.go')
-rw-r--r--internal/api/client/admin/admin.go29
1 files changed, 28 insertions, 1 deletions
diff --git a/internal/api/client/admin/admin.go b/internal/api/client/admin/admin.go
index 31670bac8..f7e54d271 100644
--- a/internal/api/client/admin/admin.go
+++ b/internal/api/client/admin/admin.go
@@ -46,6 +46,12 @@ const (
AccountsActionPath = AccountsPathWithID + "/action"
MediaCleanupPath = BasePath + "/media_cleanup"
MediaRefetchPath = BasePath + "/media_refetch"
+ // ReportsPath is for serving admin view of user reports.
+ ReportsPath = BasePath + "/reports"
+ // ReportsPathWithID is for viewing/acting on one report.
+ ReportsPathWithID = ReportsPath + "/:" + IDKey
+ // ReportsResolvePath is for marking one report as resolved.
+ ReportsResolvePath = ReportsPathWithID + "/resolve"
// ExportQueryKey is for requesting a public export of some data.
ExportQueryKey = "export"
@@ -65,6 +71,15 @@ const (
LimitKey = "limit"
// DomainQueryKey is for specifying a domain during admin actions.
DomainQueryKey = "domain"
+ // ResolvedKey is for filtering reports by their resolved status
+ ResolvedKey = "resolved"
+ // AccountIDKey is for selecting account in API paths.
+ AccountIDKey = "account_id"
+ // TargetAccountIDKey is for selecting target account in API paths.
+ TargetAccountIDKey = "target_account_id"
+ MaxIDKey = "max_id"
+ SinceIDKey = "since_id"
+ MinIDKey = "min_id"
)
type Module struct {
@@ -78,17 +93,29 @@ func New(processor processing.Processor) *Module {
}
func (m *Module) Route(attachHandler func(method string, path string, f ...gin.HandlerFunc) gin.IRoutes) {
+ // emoji stuff
attachHandler(http.MethodPost, EmojiPath, m.EmojiCreatePOSTHandler)
attachHandler(http.MethodGet, EmojiPath, m.EmojisGETHandler)
attachHandler(http.MethodDelete, EmojiPathWithID, m.EmojiDELETEHandler)
attachHandler(http.MethodGet, EmojiPathWithID, m.EmojiGETHandler)
attachHandler(http.MethodPatch, EmojiPathWithID, m.EmojiPATCHHandler)
+ attachHandler(http.MethodGet, EmojiCategoriesPath, m.EmojiCategoriesGETHandler)
+
+ // domain block stuff
attachHandler(http.MethodPost, DomainBlocksPath, m.DomainBlocksPOSTHandler)
attachHandler(http.MethodGet, DomainBlocksPath, m.DomainBlocksGETHandler)
attachHandler(http.MethodGet, DomainBlocksPathWithID, m.DomainBlockGETHandler)
attachHandler(http.MethodDelete, DomainBlocksPathWithID, m.DomainBlockDELETEHandler)
+
+ // accounts stuff
attachHandler(http.MethodPost, AccountsActionPath, m.AccountActionPOSTHandler)
+
+ // media stuff
attachHandler(http.MethodPost, MediaCleanupPath, m.MediaCleanupPOSTHandler)
attachHandler(http.MethodPost, MediaRefetchPath, m.MediaRefetchPOSTHandler)
- attachHandler(http.MethodGet, EmojiCategoriesPath, m.EmojiCategoriesGETHandler)
+
+ // reports stuff
+ attachHandler(http.MethodGet, ReportsPath, m.ReportsGETHandler)
+ attachHandler(http.MethodGet, ReportsPathWithID, m.ReportGETHandler)
+ attachHandler(http.MethodPost, ReportsResolvePath, m.ReportResolvePOSTHandler)
}