diff --git a/doc/api.oa3 b/doc/api.oa3 index 96c0b99d..fd4af4d5 100644 --- a/doc/api.oa3 +++ b/doc/api.oa3 @@ -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 @@ -3196,7 +3195,25 @@ components: updated: 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,23 +3262,36 @@ components: updated: type: integer format: int64 - groups: - $ref: '#/components/schemas/ChannelGroups' - cards: - type: array - items: - type: string + contacts: + $ref: '#/components/schemas/ChannelContacts' + members: + $ref: '#/components/schemas/ChannelMembers' - ChannelGroups: + ChannelContacts: type: object required: - groups + - cards properties: groups: type: array items: type: string + cards: + type: array + items: + type: string + ChannelMembers: + type: object + required: + - members + properties: + members: + type: array + items: + type: string + Topic: type: object required: @@ -3595,3 +3625,4 @@ components: + diff --git a/net/server/internal/api_account.go b/net/server/internal/api_account.go index 98b6e351..a5d1c76a 100644 --- a/net/server/internal/api_account.go +++ b/net/server/internal/api_account.go @@ -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) +} + diff --git a/net/server/internal/databag.db b/net/server/internal/databag.db new file mode 100644 index 00000000..1eb15c01 Binary files /dev/null and b/net/server/internal/databag.db differ diff --git a/net/server/internal/modelUtil.go b/net/server/internal/modelUtil.go index 6e90ade9..4416cf38 100644 --- a/net/server/internal/modelUtil.go +++ b/net/server/internal/modelUtil.go @@ -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 }, }, }, } diff --git a/net/server/internal/models.go b/net/server/internal/models.go index 0983b543..81b299c9 100644 --- a/net/server/internal/models.go +++ b/net/server/internal/models.go @@ -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 { diff --git a/net/server/internal/routers.go b/net/server/internal/routers.go index 832479b4..4cd081ed 100644 --- a/net/server/internal/routers.go +++ b/net/server/internal/routers.go @@ -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"),