mirror of
https://github.com/balzack/databag.git
synced 2025-02-12 03:29:16 +00:00
removed stale account endpoints
This commit is contained in:
parent
2ae2f857f8
commit
e25b95277c
75
doc/api.oa3
75
doc/api.oa3
@ -185,36 +185,6 @@ paths:
|
|||||||
'500':
|
'500':
|
||||||
description: internal server error
|
description: internal server error
|
||||||
|
|
||||||
/admin/accounts/{accountId}/image:
|
|
||||||
get:
|
|
||||||
tags:
|
|
||||||
- admin
|
|
||||||
description: Get profile image of specified account. Access granted to admin username and password
|
|
||||||
operationId: get-node-account-image
|
|
||||||
security:
|
|
||||||
- basicAuth: []
|
|
||||||
parameters:
|
|
||||||
- name: accountId
|
|
||||||
in: path
|
|
||||||
description: id of specified account
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
responses:
|
|
||||||
'200':
|
|
||||||
description: success
|
|
||||||
content:
|
|
||||||
application/octet-stream: # content specific
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
format: binary
|
|
||||||
'401':
|
|
||||||
description: permission denied
|
|
||||||
'405':
|
|
||||||
description: invalid image
|
|
||||||
'500':
|
|
||||||
description: internal server error
|
|
||||||
|
|
||||||
/admin/accounts/{accountId}:
|
/admin/accounts/{accountId}:
|
||||||
delete:
|
delete:
|
||||||
tags:
|
tags:
|
||||||
@ -316,7 +286,32 @@ paths:
|
|||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
$ref: '#/components/schemas/Profile'
|
$ref: '#/components/schemas/Profile'
|
||||||
|
'401':
|
||||||
|
description: permission denied
|
||||||
|
'500':
|
||||||
|
description: internal server error
|
||||||
|
|
||||||
|
/account/listing/{guid}/image:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- account
|
||||||
|
description: Get profile image of searchable accounts. Endpoint is publically accessible.
|
||||||
|
operationId: get-account-listing-image
|
||||||
|
parameters:
|
||||||
|
- name: guid
|
||||||
|
in: path
|
||||||
|
description: filter for specified guid
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: success
|
||||||
|
content:
|
||||||
|
application/octet-stream: # content specific
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
format: binary
|
||||||
'401':
|
'401':
|
||||||
description: permission denied
|
description: permission denied
|
||||||
'500':
|
'500':
|
||||||
@ -386,24 +381,6 @@ paths:
|
|||||||
type: boolean
|
type: boolean
|
||||||
|
|
||||||
/account/profile:
|
/account/profile:
|
||||||
get:
|
|
||||||
tags:
|
|
||||||
- account
|
|
||||||
description: Get account profile. Access granted to account's username and password.
|
|
||||||
operationId: get-account-profile
|
|
||||||
security:
|
|
||||||
- basicAuth: []
|
|
||||||
responses:
|
|
||||||
'200':
|
|
||||||
description: successful operation
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/Profile'
|
|
||||||
'401':
|
|
||||||
description: authentication error
|
|
||||||
'500':
|
|
||||||
description: internal server error
|
|
||||||
post:
|
post:
|
||||||
tags:
|
tags:
|
||||||
- account
|
- account
|
||||||
|
@ -23,21 +23,6 @@ func GetAccountAsset(w http.ResponseWriter, r *http.Request) {
|
|||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetAccountDid(w http.ResponseWriter, r *http.Request) {
|
|
||||||
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
|
|
||||||
w.WriteHeader(http.StatusOK)
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetAccountImage(w http.ResponseWriter, r *http.Request) {
|
|
||||||
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
|
|
||||||
w.WriteHeader(http.StatusOK)
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetAccountProfile(w http.ResponseWriter, r *http.Request) {
|
|
||||||
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
|
|
||||||
w.WriteHeader(http.StatusOK)
|
|
||||||
}
|
|
||||||
|
|
||||||
func RemoveAccount(w http.ResponseWriter, r *http.Request) {
|
func RemoveAccount(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
|
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
|
39
net/server/internal/api_getAccountListingImage.go
Normal file
39
net/server/internal/api_getAccountListingImage.go
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
package databag
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
"bytes"
|
||||||
|
"errors"
|
||||||
|
"net/http"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
"databag/internal/store"
|
||||||
|
"encoding/base64"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetAccountListingImage(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
|
var account store.Account
|
||||||
|
if err := store.DB.Preload("AccountDetail").Where("searchable = ? AND disabled = ?", true, false).First(&account).Error; err != nil {
|
||||||
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
|
ErrResponse(w, http.StatusNotFound, err)
|
||||||
|
} else {
|
||||||
|
ErrResponse(w, http.StatusInternalServerError, err)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if account.AccountDetail.Image == "" {
|
||||||
|
ErrResponse(w, http.StatusNotFound, errors.New("image not set"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
data, err := base64.StdEncoding.DecodeString(account.AccountDetail.Image)
|
||||||
|
if err != nil {
|
||||||
|
ErrResponse(w, http.StatusNotFound, errors.New("image not valid"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// response with content
|
||||||
|
http.ServeContent(w, r, "image", time.Unix(account.Updated, 0), bytes.NewReader(data))
|
||||||
|
}
|
||||||
|
|
@ -97,24 +97,17 @@ var routes = Routes{
|
|||||||
},
|
},
|
||||||
|
|
||||||
Route{
|
Route{
|
||||||
"GetAccountDid",
|
"GetAccountListing",
|
||||||
strings.ToUpper("Get"),
|
strings.ToUpper("Get"),
|
||||||
"/account/did",
|
"/account/listing",
|
||||||
GetAccountDid,
|
GetAccountListing,
|
||||||
},
|
},
|
||||||
|
|
||||||
Route{
|
Route{
|
||||||
"GetAccountImage",
|
"GetAccountListingImage",
|
||||||
strings.ToUpper("Get"),
|
strings.ToUpper("Get"),
|
||||||
"/account/profile/image",
|
"/account/listing/{guid}/image",
|
||||||
GetAccountImage,
|
GetAccountListingImage,
|
||||||
},
|
|
||||||
|
|
||||||
Route{
|
|
||||||
"GetAccountProfile",
|
|
||||||
strings.ToUpper("Get"),
|
|
||||||
"/account/profile",
|
|
||||||
GetAccountProfile,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
Route{
|
Route{
|
||||||
|
Loading…
Reference in New Issue
Block a user