mirror of
https://github.com/balzack/databag.git
synced 2025-02-12 03:29:16 +00:00
removing cardview
This commit is contained in:
parent
83e1afc25e
commit
dfcbb3c49a
81
doc/api.oa3
81
doc/api.oa3
@ -938,6 +938,35 @@ paths:
|
|||||||
description: internal server error
|
description: internal server error
|
||||||
|
|
||||||
/contact/cards:
|
/contact/cards:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- contact
|
||||||
|
description: Get list of cards. Access granted to app tokens of account holder.
|
||||||
|
operationId: get-cards
|
||||||
|
security:
|
||||||
|
- bearerAuth: []
|
||||||
|
parameters:
|
||||||
|
- name: cardRevision
|
||||||
|
in: query
|
||||||
|
description: only return updated cards since specified revision
|
||||||
|
required: false
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: successful operation
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/Card'
|
||||||
|
'401':
|
||||||
|
description: permission denied
|
||||||
|
'410':
|
||||||
|
description: account disabled
|
||||||
|
'500':
|
||||||
|
description: internal server error
|
||||||
post:
|
post:
|
||||||
tags:
|
tags:
|
||||||
- contact
|
- contact
|
||||||
@ -961,30 +990,6 @@ paths:
|
|||||||
'500':
|
'500':
|
||||||
description: internal server error
|
description: internal server error
|
||||||
|
|
||||||
/contact/cards/view:
|
|
||||||
get:
|
|
||||||
tags:
|
|
||||||
- contact
|
|
||||||
description: Get list of card views. Access granted to app tokens of account holder.
|
|
||||||
operationId: get-card-view
|
|
||||||
security:
|
|
||||||
- bearerAuth: []
|
|
||||||
responses:
|
|
||||||
'200':
|
|
||||||
description: successful operation
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
$ref: '#/components/schemas/CardView'
|
|
||||||
'401':
|
|
||||||
description: permission denied
|
|
||||||
'410':
|
|
||||||
description: account disabled
|
|
||||||
'500':
|
|
||||||
description: internal server error
|
|
||||||
|
|
||||||
/contact/cards/{cardId}:
|
/contact/cards/{cardId}:
|
||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
@ -4042,34 +4047,6 @@ components:
|
|||||||
type: string
|
type: string
|
||||||
format: base64 encoded image
|
format: base64 encoded image
|
||||||
|
|
||||||
CardView:
|
|
||||||
type: object
|
|
||||||
required:
|
|
||||||
- cardId
|
|
||||||
- profileRevision
|
|
||||||
- dataRevision
|
|
||||||
- notifiedProfile
|
|
||||||
- notifiedContent
|
|
||||||
- notifiedView
|
|
||||||
properties:
|
|
||||||
cardId:
|
|
||||||
type: string
|
|
||||||
profileRevision:
|
|
||||||
type: integer
|
|
||||||
format: int64
|
|
||||||
dataRevision:
|
|
||||||
type: integer
|
|
||||||
format: int64
|
|
||||||
notifiedProfile:
|
|
||||||
type: integer
|
|
||||||
format: int64
|
|
||||||
notifiedContent:
|
|
||||||
type: integer
|
|
||||||
format: int64
|
|
||||||
notifiedView:
|
|
||||||
type: integer
|
|
||||||
format: int64
|
|
||||||
|
|
||||||
CardProfile:
|
CardProfile:
|
||||||
type: object
|
type: object
|
||||||
required:
|
required:
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
package databag
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net/http"
|
|
||||||
"databag/internal/store"
|
|
||||||
)
|
|
||||||
|
|
||||||
type cardView struct {
|
|
||||||
CardId string
|
|
||||||
ProfileRevision int64
|
|
||||||
DataRevision int64
|
|
||||||
NotifiedProfile int64
|
|
||||||
NotifiedContent int64
|
|
||||||
NotifiedView int64
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetCardView(w http.ResponseWriter, r *http.Request) {
|
|
||||||
|
|
||||||
account, code, err := BearerAppToken(r, false);
|
|
||||||
if err != nil {
|
|
||||||
ErrResponse(w, code, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var views []CardView
|
|
||||||
if err := store.DB.Model(&store.Card{}).Where("account_id = ?", account.Guid).Find(&views).Error; err != nil {
|
|
||||||
ErrResponse(w, http.StatusInternalServerError, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
WriteResponse(w, &views)
|
|
||||||
}
|
|
23
net/server/internal/api_getCards.go
Normal file
23
net/server/internal/api_getCards.go
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
package databag
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"databag/internal/store"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetCards(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
|
account, code, err := BearerAppToken(r, false);
|
||||||
|
if err != nil {
|
||||||
|
ErrResponse(w, code, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var cards []store.Card
|
||||||
|
if err := store.DB.Where("account_id = ?", account.Guid).Find(&cards).Error; err != nil {
|
||||||
|
ErrResponse(w, http.StatusInternalServerError, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
WriteResponse(w, &cards)
|
||||||
|
}
|
@ -62,12 +62,6 @@ type ArticleData struct {
|
|||||||
TagRevision int64 `json:"tagRevision"`
|
TagRevision int64 `json:"tagRevision"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ArticleView struct {
|
|
||||||
ArticleId string `json:"articleId"`
|
|
||||||
Revision int64 `json:"revision"`
|
|
||||||
TagRevision int64 `json:"tagRevision"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ArticleAccess struct {
|
type ArticleAccess struct {
|
||||||
Labels []string `json:"labels"`
|
Labels []string `json:"labels"`
|
||||||
Groups []string `json:"groups"`
|
Groups []string `json:"groups"`
|
||||||
@ -117,15 +111,6 @@ type CardProfile struct {
|
|||||||
Node string `json:"node"`
|
Node string `json:"node"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CardView struct {
|
|
||||||
CardId string `json:"cardId"`
|
|
||||||
ProfileRevision int64 `json:"profileRevision"`
|
|
||||||
DataRevision int64 `json:"dataRevision"`
|
|
||||||
NotifiedProfile int64 `json:"notifiedProfile"`
|
|
||||||
NotifiedContent int64 `json:"notifiedContent"`
|
|
||||||
NotifiedView int64 `json:"notifiedView"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ContentArticlesBody struct {
|
type ContentArticlesBody struct {
|
||||||
Labels []string `json:"labels"`
|
Labels []string `json:"labels"`
|
||||||
Groups []string `json:"groups"`
|
Groups []string `json:"groups"`
|
||||||
|
@ -321,10 +321,10 @@ var routes = Routes{
|
|||||||
},
|
},
|
||||||
|
|
||||||
Route{
|
Route{
|
||||||
"GetCardView",
|
"GetCards",
|
||||||
strings.ToUpper("Get"),
|
strings.ToUpper("Get"),
|
||||||
"/contact/cards/view",
|
"/contact/cards",
|
||||||
GetCardView,
|
GetCards,
|
||||||
},
|
},
|
||||||
|
|
||||||
Route{
|
Route{
|
||||||
|
@ -71,17 +71,17 @@ func TestConnectContact(t *testing.T) {
|
|||||||
SetOpenMessage(w, r)
|
SetOpenMessage(w, r)
|
||||||
assert.NoError(t, ReadResponse(w, &contactStatus))
|
assert.NoError(t, ReadResponse(w, &contactStatus))
|
||||||
|
|
||||||
// get view of cards in A
|
// get cards in A
|
||||||
r, w, _ = NewRequest("GET", "/contact/cards/view", nil)
|
r, w, _ = NewRequest("GET", "/contact/cards", nil)
|
||||||
SetBearerAuth(r, a)
|
SetBearerAuth(r, a)
|
||||||
GetCardView(w, r)
|
GetCards(w, r)
|
||||||
var views []CardView
|
var cards []Card
|
||||||
assert.NoError(t, ReadResponse(w, &views))
|
assert.NoError(t, ReadResponse(w, &cards))
|
||||||
assert.Equal(t, len(views), 1)
|
assert.Equal(t, len(cards), 1)
|
||||||
|
|
||||||
// get B card in A
|
// get B card in A
|
||||||
r, w, _ = NewRequest("GET", "/contact/cards/{cardId}", nil)
|
r, w, _ = NewRequest("GET", "/contact/cards/{cardId}", nil)
|
||||||
vars = map[string]string{ "cardId": views[0].CardId }
|
vars = map[string]string{ "cardId": cards[0].CardId }
|
||||||
r = mux.SetURLVars(r, vars)
|
r = mux.SetURLVars(r, vars)
|
||||||
SetBearerAuth(r, a)
|
SetBearerAuth(r, a)
|
||||||
GetCard(w, r)
|
GetCard(w, r)
|
||||||
@ -89,7 +89,7 @@ func TestConnectContact(t *testing.T) {
|
|||||||
|
|
||||||
// update B status to connecting
|
// update B status to connecting
|
||||||
r, w, _ = NewRequest("PUT", "/contact/cards/{cardId}/status", APP_CARDCONNECTING)
|
r, w, _ = NewRequest("PUT", "/contact/cards/{cardId}/status", APP_CARDCONNECTING)
|
||||||
vars = map[string]string{ "cardId": views[0].CardId }
|
vars = map[string]string{ "cardId": cards[0].CardId }
|
||||||
r = mux.SetURLVars(r, vars)
|
r = mux.SetURLVars(r, vars)
|
||||||
SetBearerAuth(r, a)
|
SetBearerAuth(r, a)
|
||||||
SetCardStatus(w, r)
|
SetCardStatus(w, r)
|
||||||
@ -97,7 +97,7 @@ func TestConnectContact(t *testing.T) {
|
|||||||
|
|
||||||
// get open message to B
|
// get open message to B
|
||||||
r, w, _ = NewRequest("GET", "/contact/cards/{cardId}/openMessage", nil)
|
r, w, _ = NewRequest("GET", "/contact/cards/{cardId}/openMessage", nil)
|
||||||
vars = map[string]string{ "cardId": views[0].CardId }
|
vars = map[string]string{ "cardId": cards[0].CardId }
|
||||||
r = mux.SetURLVars(r, vars)
|
r = mux.SetURLVars(r, vars)
|
||||||
SetBearerAuth(r, a)
|
SetBearerAuth(r, a)
|
||||||
GetOpenMessage(w, r)
|
GetOpenMessage(w, r)
|
||||||
@ -117,7 +117,7 @@ func TestConnectContact(t *testing.T) {
|
|||||||
|
|
||||||
// update B status to connected
|
// update B status to connected
|
||||||
r, w, _ = NewRequest("PUT", "/contact/cards/{cardId}/status?token=" + contactStatus.Token, APP_CARDCONNECTED)
|
r, w, _ = NewRequest("PUT", "/contact/cards/{cardId}/status?token=" + contactStatus.Token, APP_CARDCONNECTED)
|
||||||
vars = map[string]string{ "cardId": views[0].CardId }
|
vars = map[string]string{ "cardId": cards[0].CardId }
|
||||||
r = mux.SetURLVars(r, vars)
|
r = mux.SetURLVars(r, vars)
|
||||||
SetBearerAuth(r, a)
|
SetBearerAuth(r, a)
|
||||||
SetCardStatus(w, r)
|
SetCardStatus(w, r)
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestProfileNotification(t *testing.T) {
|
func TestProfileNotification(t *testing.T) {
|
||||||
var views []CardView
|
var cards []Card
|
||||||
var revision Revision
|
var revision Revision
|
||||||
var ws *websocket.Conn
|
var ws *websocket.Conn
|
||||||
var err error
|
var err error
|
||||||
@ -20,13 +20,13 @@ func TestProfileNotification(t *testing.T) {
|
|||||||
OpenTestCard(a, aCard)
|
OpenTestCard(a, aCard)
|
||||||
OpenTestCard(b, bCard)
|
OpenTestCard(b, bCard)
|
||||||
|
|
||||||
// get views list of cards
|
// get list of cards
|
||||||
r, w, _ := NewRequest("GET", "/contact/cards/view", nil)
|
r, w, _ := NewRequest("GET", "/contact/cards", nil)
|
||||||
SetBearerAuth(r, a)
|
SetBearerAuth(r, a)
|
||||||
GetCardView(w, r)
|
GetCards(w, r)
|
||||||
assert.NoError(t, ReadResponse(w, &views))
|
assert.NoError(t, ReadResponse(w, &cards))
|
||||||
assert.Equal(t, len(views), 1)
|
assert.Equal(t, len(cards), 1)
|
||||||
profileRevision := views[0].NotifiedProfile
|
profileRevision := cards[0].NotifiedProfile
|
||||||
|
|
||||||
// app connects websocket
|
// app connects websocket
|
||||||
ws, err = StatusConnection(a, &revision);
|
ws, err = StatusConnection(a, &revision);
|
||||||
@ -49,11 +49,11 @@ func TestProfileNotification(t *testing.T) {
|
|||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.NotEqual(t, cardRevision, revision.Card)
|
assert.NotEqual(t, cardRevision, revision.Card)
|
||||||
|
|
||||||
// get views list of cards
|
// get list of cards
|
||||||
r, w, _ = NewRequest("GET", "/contact/cards/view", nil)
|
r, w, _ = NewRequest("GET", "/contact/cards", nil)
|
||||||
SetBearerAuth(r, a)
|
SetBearerAuth(r, a)
|
||||||
GetCardView(w, r)
|
GetCards(w, r)
|
||||||
assert.NoError(t, ReadResponse(w, &views))
|
assert.NoError(t, ReadResponse(w, &cards))
|
||||||
assert.Equal(t, len(views), 1)
|
assert.Equal(t, len(cards), 1)
|
||||||
assert.NotEqual(t, profileRevision, views[0].NotifiedProfile)
|
assert.NotEqual(t, profileRevision, cards[0].NotifiedProfile)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user