mirror of
https://github.com/balzack/databag.git
synced 2025-02-12 11:39:17 +00:00
updated api to support browser app
This commit is contained in:
parent
98f3d2c87c
commit
23b002edc4
165
doc/api.oa3
165
doc/api.oa3
@ -267,45 +267,6 @@ paths:
|
|||||||
type: string
|
type: string
|
||||||
format: binary
|
format: binary
|
||||||
|
|
||||||
/account/public/status:
|
|
||||||
get:
|
|
||||||
tags:
|
|
||||||
- account
|
|
||||||
description: Check if a public account can be created.
|
|
||||||
operationId: get-public-status
|
|
||||||
responses:
|
|
||||||
'200':
|
|
||||||
description: success
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
type: boolean
|
|
||||||
'500':
|
|
||||||
description: internal server error
|
|
||||||
|
|
||||||
/account/public/profile:
|
|
||||||
post:
|
|
||||||
tags:
|
|
||||||
- account
|
|
||||||
description: Add a new account. Basic auth will be used for the accounts username and password. Access granted to when public account available.
|
|
||||||
operationId: add-public-account
|
|
||||||
security:
|
|
||||||
- bearerAuth: []
|
|
||||||
- basicCredentials: []
|
|
||||||
responses:
|
|
||||||
'201':
|
|
||||||
description: successful operation
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/Profile'
|
|
||||||
'400':
|
|
||||||
description: invalid handle or password
|
|
||||||
'406':
|
|
||||||
description: accounts not available
|
|
||||||
'500':
|
|
||||||
description: internal server error
|
|
||||||
|
|
||||||
/account/available:
|
/account/available:
|
||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
@ -333,6 +294,36 @@ paths:
|
|||||||
'500':
|
'500':
|
||||||
description: internal server error
|
description: internal server error
|
||||||
|
|
||||||
|
/account/listing:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- account
|
||||||
|
description: Get profile of searchable accounts. Endpoint is publically accessible.
|
||||||
|
operationId: get-account-listing
|
||||||
|
security:
|
||||||
|
- bearerAuth: []
|
||||||
|
parameters:
|
||||||
|
- name: guid
|
||||||
|
in: query
|
||||||
|
description: filter for specified guid
|
||||||
|
required: false
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: success
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/Profile'
|
||||||
|
|
||||||
|
'401':
|
||||||
|
description: permission denied
|
||||||
|
'500':
|
||||||
|
description: internal server error
|
||||||
|
|
||||||
/account/token:
|
/account/token:
|
||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
@ -353,26 +344,6 @@ paths:
|
|||||||
'500':
|
'500':
|
||||||
description: internal server error
|
description: internal server error
|
||||||
|
|
||||||
/account/did:
|
|
||||||
get:
|
|
||||||
tags:
|
|
||||||
- account
|
|
||||||
description: Retrieve account DIDkey. Authorized to account username and password.
|
|
||||||
operationId: get-account-did
|
|
||||||
security:
|
|
||||||
- basicAuth: []
|
|
||||||
responses:
|
|
||||||
'200':
|
|
||||||
description: successful operation
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
'401':
|
|
||||||
description: authentication error
|
|
||||||
'500':
|
|
||||||
description: internal server error
|
|
||||||
|
|
||||||
/account/status:
|
/account/status:
|
||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
@ -393,6 +364,29 @@ paths:
|
|||||||
'500':
|
'500':
|
||||||
description: internal server error
|
description: internal server error
|
||||||
|
|
||||||
|
/account/searchable:
|
||||||
|
put:
|
||||||
|
tags:
|
||||||
|
- account
|
||||||
|
description: Set whether account is publicly listed.
|
||||||
|
operationId: set-account-seachable
|
||||||
|
security:
|
||||||
|
- basicAuth: []
|
||||||
|
responses:
|
||||||
|
'201':
|
||||||
|
description: success
|
||||||
|
'401':
|
||||||
|
description: permission denied
|
||||||
|
'405':
|
||||||
|
description: failed to confirm
|
||||||
|
'500':
|
||||||
|
description: internal server error
|
||||||
|
requestBody:
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: boolean
|
||||||
|
|
||||||
/account/profile:
|
/account/profile:
|
||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
@ -553,6 +547,11 @@ paths:
|
|||||||
description: failed to confirm
|
description: failed to confirm
|
||||||
'500':
|
'500':
|
||||||
description: internal server error
|
description: internal server error
|
||||||
|
requestBody:
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
|
||||||
/account/apps:
|
/account/apps:
|
||||||
get:
|
get:
|
||||||
@ -1931,7 +1930,7 @@ paths:
|
|||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/Subject'
|
$ref: '#/components/schemas/ChannelParams'
|
||||||
|
|
||||||
/content/channels/{channelId}:
|
/content/channels/{channelId}:
|
||||||
get:
|
get:
|
||||||
@ -2964,9 +2963,6 @@ components:
|
|||||||
properties:
|
properties:
|
||||||
domain:
|
domain:
|
||||||
type: string
|
type: string
|
||||||
publicLimit:
|
|
||||||
type: integer
|
|
||||||
format: int64
|
|
||||||
accountStorage:
|
accountStorage:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
@ -2978,6 +2974,7 @@ components:
|
|||||||
- storageUsed
|
- storageUsed
|
||||||
- storageAvailable
|
- storageAvailable
|
||||||
- forwardingAddress
|
- forwardingAddress
|
||||||
|
- searchable
|
||||||
properties:
|
properties:
|
||||||
disabled:
|
disabled:
|
||||||
type: boolean
|
type: boolean
|
||||||
@ -2989,6 +2986,8 @@ components:
|
|||||||
format: int64
|
format: int64
|
||||||
forwardingAddress:
|
forwardingAddress:
|
||||||
type: string
|
type: string
|
||||||
|
searchable:
|
||||||
|
type: boolean
|
||||||
|
|
||||||
Profile:
|
Profile:
|
||||||
type: object
|
type: object
|
||||||
@ -3197,6 +3196,24 @@ components:
|
|||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
|
|
||||||
|
ChannelParams:
|
||||||
|
type: object
|
||||||
|
required:
|
||||||
|
- subject
|
||||||
|
- groups
|
||||||
|
- cards
|
||||||
|
properties:
|
||||||
|
subject:
|
||||||
|
$ref: '#/components/schemas/Subject'
|
||||||
|
groups:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
cards:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
|
||||||
Channel:
|
Channel:
|
||||||
type: object
|
type: object
|
||||||
required:
|
required:
|
||||||
@ -3245,19 +3262,32 @@ components:
|
|||||||
updated:
|
updated:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
|
contacts:
|
||||||
|
$ref: '#/components/schemas/ChannelContacts'
|
||||||
|
members:
|
||||||
|
$ref: '#/components/schemas/ChannelMembers'
|
||||||
|
|
||||||
|
ChannelContacts:
|
||||||
|
type: object
|
||||||
|
required:
|
||||||
|
- groups
|
||||||
|
- cards
|
||||||
|
properties:
|
||||||
groups:
|
groups:
|
||||||
$ref: '#/components/schemas/ChannelGroups'
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
cards:
|
cards:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
type: string
|
type: string
|
||||||
|
|
||||||
ChannelGroups:
|
ChannelMembers:
|
||||||
type: object
|
type: object
|
||||||
required:
|
required:
|
||||||
- groups
|
- members
|
||||||
properties:
|
properties:
|
||||||
groups:
|
members:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
type: string
|
type: string
|
||||||
@ -3595,3 +3625,4 @@ components:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,11 +18,6 @@ func AddAccountAuthentication(w http.ResponseWriter, r *http.Request) {
|
|||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
}
|
}
|
||||||
|
|
||||||
func AddPublicAccount(w http.ResponseWriter, r *http.Request) {
|
|
||||||
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
|
|
||||||
w.WriteHeader(http.StatusOK)
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetAccountApps(w http.ResponseWriter, r *http.Request) {
|
func GetAccountApps(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)
|
||||||
@ -53,11 +48,6 @@ func GetAccountStatus(w http.ResponseWriter, r *http.Request) {
|
|||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetPublicStatus(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)
|
||||||
@ -83,3 +73,13 @@ func SetAccountNode(w http.ResponseWriter, r *http.Request) {
|
|||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetAccountListing(w http.ResponseWriter, r *http.Request) {
|
||||||
|
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetAccountSeachable(w http.ResponseWriter, r *http.Request) {
|
||||||
|
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
|
}
|
||||||
|
|
||||||
|
BIN
net/server/internal/databag.db
Normal file
BIN
net/server/internal/databag.db
Normal file
Binary file not shown.
@ -173,22 +173,17 @@ func getChannelModel(slot *store.ChannelSlot, showData bool, showList bool) *Cha
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var channelGroups *IdList
|
var contacts *ChannelContacts
|
||||||
if showList {
|
if showList {
|
||||||
var groups []string;
|
var groups []string;
|
||||||
for _, group := range slot.Channel.Groups {
|
for _, group := range slot.Channel.Groups {
|
||||||
groups = append(groups, group.GroupSlot.GroupSlotId)
|
groups = append(groups, group.GroupSlot.GroupSlotId)
|
||||||
}
|
}
|
||||||
channelGroups = &IdList{ Ids: groups }
|
|
||||||
}
|
|
||||||
|
|
||||||
var channelCards *IdList
|
|
||||||
if showList {
|
|
||||||
var cards []string;
|
var cards []string;
|
||||||
for _, card := range slot.Channel.Cards {
|
for _, card := range slot.Channel.Cards {
|
||||||
cards = append(cards, card.CardSlot.CardSlotId)
|
cards = append(cards, card.CardSlot.CardSlotId)
|
||||||
}
|
}
|
||||||
channelCards = &IdList{ Ids: cards }
|
contacts = &ChannelContacts{ Groups: groups, Cards: cards }
|
||||||
}
|
}
|
||||||
|
|
||||||
members := []string{}
|
members := []string{}
|
||||||
@ -207,9 +202,8 @@ func getChannelModel(slot *store.ChannelSlot, showData bool, showList bool) *Cha
|
|||||||
Data: slot.Channel.Data,
|
Data: slot.Channel.Data,
|
||||||
Created: slot.Channel.Created,
|
Created: slot.Channel.Created,
|
||||||
Updated: slot.Channel.Updated,
|
Updated: slot.Channel.Updated,
|
||||||
Groups: channelGroups,
|
Contacts: contacts,
|
||||||
Cards: channelCards,
|
Members: &ChannelMembers{ members },
|
||||||
Members: members,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,8 @@ type AccountStatus struct {
|
|||||||
StorageAvailable float64 `json:"storageAvailable"`
|
StorageAvailable float64 `json:"storageAvailable"`
|
||||||
|
|
||||||
ForwardingAddress string `json:"forwardingAddress"`
|
ForwardingAddress string `json:"forwardingAddress"`
|
||||||
|
|
||||||
|
Searchable bool `json:"searchable"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Announce struct {
|
type Announce struct {
|
||||||
@ -145,6 +147,13 @@ type CardProfile struct {
|
|||||||
Node string `json:"node"`
|
Node string `json:"node"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ChannelContacts struct {
|
||||||
|
|
||||||
|
Groups []string `json:"groups"`
|
||||||
|
|
||||||
|
Cards []string `json:"cards"`
|
||||||
|
}
|
||||||
|
|
||||||
type Channel struct {
|
type Channel struct {
|
||||||
|
|
||||||
Id string `json:"id"`
|
Id string `json:"id"`
|
||||||
@ -173,11 +182,23 @@ type ChannelDetail struct {
|
|||||||
|
|
||||||
Updated int64 `json:"updated"`
|
Updated int64 `json:"updated"`
|
||||||
|
|
||||||
Groups *IdList `json:"groups,omitempty"`
|
Contacts *ChannelContacts `json:"contacts,omitempty"`
|
||||||
|
|
||||||
Cards *IdList `json:"cards,omitempty"`
|
Members *ChannelMembers `json:"members,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
Members []string `json:"members"`
|
type ChannelMembers struct {
|
||||||
|
|
||||||
|
Members []string `json:"members,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ChannelParams struct {
|
||||||
|
|
||||||
|
Subject *Subject `json:"subject"`
|
||||||
|
|
||||||
|
Groups []string `json:"groups"`
|
||||||
|
|
||||||
|
Cards []string `json:"cards"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Claim struct {
|
type Claim struct {
|
||||||
|
@ -82,13 +82,6 @@ var routes = Routes{
|
|||||||
AddAccountAuthentication,
|
AddAccountAuthentication,
|
||||||
},
|
},
|
||||||
|
|
||||||
Route{
|
|
||||||
"AddPublicAccount",
|
|
||||||
strings.ToUpper("Post"),
|
|
||||||
"/account/public/profile",
|
|
||||||
AddPublicAccount,
|
|
||||||
},
|
|
||||||
|
|
||||||
Route{
|
Route{
|
||||||
"GetAccountApps",
|
"GetAccountApps",
|
||||||
strings.ToUpper("Get"),
|
strings.ToUpper("Get"),
|
||||||
@ -145,13 +138,6 @@ var routes = Routes{
|
|||||||
GetAccountUsername,
|
GetAccountUsername,
|
||||||
},
|
},
|
||||||
|
|
||||||
Route{
|
|
||||||
"GetPublicStatus",
|
|
||||||
strings.ToUpper("Get"),
|
|
||||||
"/account/public/status",
|
|
||||||
GetPublicStatus,
|
|
||||||
},
|
|
||||||
|
|
||||||
Route{
|
Route{
|
||||||
"RemoveAccount",
|
"RemoveAccount",
|
||||||
strings.ToUpper("Delete"),
|
strings.ToUpper("Delete"),
|
||||||
|
Loading…
Reference in New Issue
Block a user