Add types

This commit is contained in:
2021-03-10 19:08:58 +01:00
parent 5c74f774ff
commit d3418ced63
8 changed files with 232 additions and 29 deletions

View File

@@ -2,12 +2,33 @@ package pixelapi
import (
"net/url"
"fornaxian.tech/pixeldrain_server/api/restapi/apitype"
"time"
)
// AdminGlobal is a global setting in pixeldrain's back-end
type AdminGlobal struct {
Key string `json:"key"`
Value string `json:"value"`
}
// AdminBlockFiles is an array of files which were blocked
type AdminBlockFiles struct {
FilesBlocked []string `json:"files_blocked"`
}
// AdminAbuseReporter is an e-mail address which is allowed to send abuse
// reports to abuse@pixeldrain.com
type AdminAbuseReporter struct {
Email string `json:"email"`
Name string `json:"name"`
Type string `json:"type"`
Created time.Time `json:"created"`
FilesBlocked int `json:"files_blocked"`
LastUsed time.Time `json:"last_used"`
}
// AdminGetGlobals returns the global API settings
func (p *PixelAPI) AdminGetGlobals() (resp []apitype.AdminGlobal, err error) {
func (p *PixelAPI) AdminGetGlobals() (resp []AdminGlobal, err error) {
return resp, p.jsonRequest("GET", "admin/globals", &resp)
}
@@ -17,7 +38,7 @@ func (p *PixelAPI) AdminSetGlobals(key, value string) (err error) {
}
// AdminBlockFiles blocks files from being downloaded
func (p *PixelAPI) AdminBlockFiles(text, abuseType, reporter string) (bl apitype.AdminBlockFiles, err error) {
func (p *PixelAPI) AdminBlockFiles(text, abuseType, reporter string) (bl AdminBlockFiles, err error) {
return bl, p.form(
"POST", "admin/block_files",
url.Values{"text": {text}, "type": {abuseType}, "reporter": {reporter}},