updated api to support browser app

This commit is contained in:
Roland Osborne 2022-03-07 15:03:24 -08:00
parent 98f3d2c87c
commit 23b002edc4
6 changed files with 140 additions and 108 deletions

View File

@ -267,45 +267,6 @@ paths:
type: string
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:
get:
tags:
@ -333,6 +294,36 @@ paths:
'500':
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:
get:
tags:
@ -353,26 +344,6 @@ paths:
'500':
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:
get:
tags:
@ -393,6 +364,29 @@ paths:
'500':
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:
get:
tags:
@ -553,6 +547,11 @@ paths:
description: failed to confirm
'500':
description: internal server error
requestBody:
content:
application/json:
schema:
type: string
/account/apps:
get:
@ -1931,7 +1930,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/Subject'
$ref: '#/components/schemas/ChannelParams'
/content/channels/{channelId}:
get:
@ -2964,9 +2963,6 @@ components:
properties:
domain:
type: string
publicLimit:
type: integer
format: int64
accountStorage:
type: integer
format: int64
@ -2978,6 +2974,7 @@ components:
- storageUsed
- storageAvailable
- forwardingAddress
- searchable
properties:
disabled:
type: boolean
@ -2989,6 +2986,8 @@ components:
format: int64
forwardingAddress:
type: string
searchable:
type: boolean
Profile:
type: object
@ -3197,6 +3196,24 @@ components:
type: integer
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:
type: object
required:
@ -3245,19 +3262,32 @@ components:
updated:
type: integer
format: int64
contacts:
$ref: '#/components/schemas/ChannelContacts'
members:
$ref: '#/components/schemas/ChannelMembers'
ChannelContacts:
type: object
required:
- groups
- cards
properties:
groups:
$ref: '#/components/schemas/ChannelGroups'
type: array
items:
type: string
cards:
type: array
items:
type: string
ChannelGroups:
ChannelMembers:
type: object
required:
- groups
- members
properties:
groups:
members:
type: array
items:
type: string
@ -3595,3 +3625,4 @@ components:

View File

@ -18,11 +18,6 @@ func AddAccountAuthentication(w http.ResponseWriter, r *http.Request) {
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) {
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusOK)
@ -53,11 +48,6 @@ func GetAccountStatus(w http.ResponseWriter, r *http.Request) {
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) {
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusOK)
@ -83,3 +73,13 @@ func SetAccountNode(w http.ResponseWriter, r *http.Request) {
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)
}

Binary file not shown.

View File

@ -173,22 +173,17 @@ func getChannelModel(slot *store.ChannelSlot, showData bool, showList bool) *Cha
}
}
var channelGroups *IdList
var contacts *ChannelContacts
if showList {
var groups []string;
for _, group := range slot.Channel.Groups {
groups = append(groups, group.GroupSlot.GroupSlotId)
}
channelGroups = &IdList{ Ids: groups }
}
var channelCards *IdList
if showList {
var cards []string;
for _, card := range slot.Channel.Cards {
cards = append(cards, card.CardSlot.CardSlotId)
}
channelCards = &IdList{ Ids: cards }
contacts = &ChannelContacts{ Groups: groups, Cards: cards }
}
members := []string{}
@ -207,9 +202,8 @@ func getChannelModel(slot *store.ChannelSlot, showData bool, showList bool) *Cha
Data: slot.Channel.Data,
Created: slot.Channel.Created,
Updated: slot.Channel.Updated,
Groups: channelGroups,
Cards: channelCards,
Members: members,
Contacts: contacts,
Members: &ChannelMembers{ members },
},
},
}

View File

@ -22,6 +22,8 @@ type AccountStatus struct {
StorageAvailable float64 `json:"storageAvailable"`
ForwardingAddress string `json:"forwardingAddress"`
Searchable bool `json:"searchable"`
}
type Announce struct {
@ -145,6 +147,13 @@ type CardProfile struct {
Node string `json:"node"`
}
type ChannelContacts struct {
Groups []string `json:"groups"`
Cards []string `json:"cards"`
}
type Channel struct {
Id string `json:"id"`
@ -173,11 +182,23 @@ type ChannelDetail struct {
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 {

View File

@ -82,13 +82,6 @@ var routes = Routes{
AddAccountAuthentication,
},
Route{
"AddPublicAccount",
strings.ToUpper("Post"),
"/account/public/profile",
AddPublicAccount,
},
Route{
"GetAccountApps",
strings.ToUpper("Get"),
@ -145,13 +138,6 @@ var routes = Routes{
GetAccountUsername,
},
Route{
"GetPublicStatus",
strings.ToUpper("Get"),
"/account/public/status",
GetPublicStatus,
},
Route{
"RemoveAccount",
strings.ToUpper("Delete"),