refactor: rename accountPins to accountPinsBinary
This commit is contained in:
parent
86c53d3c54
commit
8a2f501e8e
|
@ -8,7 +8,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
_ msgpack.CustomEncoder = (*AccountPinResponse)(nil)
|
_ msgpack.CustomEncoder = (*AccountPinBinaryResponse)(nil)
|
||||||
)
|
)
|
||||||
|
|
||||||
type AccountRegisterRequest struct {
|
type AccountRegisterRequest struct {
|
||||||
|
@ -90,12 +90,12 @@ type DebugStorageLocationsResponse struct {
|
||||||
Locations []DebugStorageLocation `json:"locations"`
|
Locations []DebugStorageLocation `json:"locations"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AccountPinResponse struct {
|
type AccountPinBinaryResponse struct {
|
||||||
Pins []models.Pin
|
Pins []models.Pin
|
||||||
Cursor uint64
|
Cursor uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a AccountPinResponse) EncodeMsgpack(enc *msgpack.Encoder) error {
|
func (a AccountPinBinaryResponse) EncodeMsgpack(enc *msgpack.Encoder) error {
|
||||||
err := enc.EncodeInt(0)
|
err := enc.EncodeInt(0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
17
api/s5/s5.go
17
api/s5/s5.go
|
@ -188,7 +188,7 @@ func (s *S5API) Routes() (*httprouter.Router, error) {
|
||||||
"POST /s5/account/login": s.accountLogin,
|
"POST /s5/account/login": s.accountLogin,
|
||||||
"GET /s5/account": middleware.ApplyMiddlewares(s.accountInfo, authMw),
|
"GET /s5/account": middleware.ApplyMiddlewares(s.accountInfo, authMw),
|
||||||
"GET /s5/account/stats": middleware.ApplyMiddlewares(s.accountStats, authMw),
|
"GET /s5/account/stats": middleware.ApplyMiddlewares(s.accountStats, authMw),
|
||||||
"GET /s5/account/pins.bin": middleware.ApplyMiddlewares(s.accountPins, authMw),
|
"GET /s5/account/pins.bin": middleware.ApplyMiddlewares(s.accountPinsBinary, authMw),
|
||||||
|
|
||||||
// Upload API
|
// Upload API
|
||||||
"POST /s5/upload": middleware.ApplyMiddlewares(s.smallFileUpload, authMw),
|
"POST /s5/upload": middleware.ApplyMiddlewares(s.smallFileUpload, authMw),
|
||||||
|
@ -794,7 +794,7 @@ func (s *S5API) accountStats(jc jape.Context) {
|
||||||
jc.Encode(info)
|
jc.Encode(info)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *S5API) accountPins(jc jape.Context) {
|
func (s *S5API) accountPinsBinary(jc jape.Context) {
|
||||||
var cursor uint64
|
var cursor uint64
|
||||||
if err := jc.DecodeForm("cursor", &cursor); err != nil {
|
if err := jc.DecodeForm("cursor", &cursor); err != nil {
|
||||||
return
|
return
|
||||||
|
@ -808,7 +808,7 @@ func (s *S5API) accountPins(jc jape.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
pinResponse := &AccountPinResponse{Cursor: cursor, Pins: pins}
|
pinResponse := &AccountPinBinaryResponse{Cursor: cursor, Pins: pins}
|
||||||
result, err2 := msgpack.Marshal(pinResponse)
|
result, err2 := msgpack.Marshal(pinResponse)
|
||||||
if err2 != nil {
|
if err2 != nil {
|
||||||
s.sendErrorResponse(jc, NewS5Error(ErrKeyInternalError, err2))
|
s.sendErrorResponse(jc, NewS5Error(ErrKeyInternalError, err2))
|
||||||
|
@ -822,6 +822,17 @@ func (s *S5API) accountPins(jc jape.Context) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *S5API) accountPins(jc jape.Context) {
|
||||||
|
userID := middleware.GetUserFromContext(jc.Request.Context())
|
||||||
|
pins, err := s.accounts.AccountPins(userID, 0)
|
||||||
|
if err != nil {
|
||||||
|
s.sendErrorResponse(jc, NewS5Error(ErrKeyStorageOperationFailed, err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
jc.Encode(&AccountPinBinaryResponse{Pins: pins})
|
||||||
|
}
|
||||||
|
|
||||||
func (s *S5API) accountPinDelete(jc jape.Context) {
|
func (s *S5API) accountPinDelete(jc jape.Context) {
|
||||||
var cid string
|
var cid string
|
||||||
if err := jc.DecodeParam("cid", &cid); err != nil {
|
if err := jc.DecodeParam("cid", &cid); err != nil {
|
||||||
|
|
Loading…
Reference in New Issue