mirror of
https://github.com/balzack/databag.git
synced 2025-02-11 19:19: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
|
||||
|
||||
/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:
|
||||
tags:
|
||||
- contact
|
||||
@ -961,30 +990,6 @@ paths:
|
||||
'500':
|
||||
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}:
|
||||
get:
|
||||
tags:
|
||||
@ -4042,34 +4047,6 @@ components:
|
||||
type: string
|
||||
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:
|
||||
type: object
|
||||
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"`
|
||||
}
|
||||
|
||||
type ArticleView struct {
|
||||
ArticleId string `json:"articleId"`
|
||||
Revision int64 `json:"revision"`
|
||||
TagRevision int64 `json:"tagRevision"`
|
||||
}
|
||||
|
||||
type ArticleAccess struct {
|
||||
Labels []string `json:"labels"`
|
||||
Groups []string `json:"groups"`
|
||||
@ -117,15 +111,6 @@ type CardProfile struct {
|
||||
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 {
|
||||
Labels []string `json:"labels"`
|
||||
Groups []string `json:"groups"`
|
||||
|
@ -321,10 +321,10 @@ var routes = Routes{
|
||||
},
|
||||
|
||||
Route{
|
||||
"GetCardView",
|
||||
"GetCards",
|
||||
strings.ToUpper("Get"),
|
||||
"/contact/cards/view",
|
||||
GetCardView,
|
||||
"/contact/cards",
|
||||
GetCards,
|
||||
},
|
||||
|
||||
Route{
|
||||
|
@ -71,17 +71,17 @@ func TestConnectContact(t *testing.T) {
|
||||
SetOpenMessage(w, r)
|
||||
assert.NoError(t, ReadResponse(w, &contactStatus))
|
||||
|
||||
// get view of cards in A
|
||||
r, w, _ = NewRequest("GET", "/contact/cards/view", nil)
|
||||
// get cards in A
|
||||
r, w, _ = NewRequest("GET", "/contact/cards", nil)
|
||||
SetBearerAuth(r, a)
|
||||
GetCardView(w, r)
|
||||
var views []CardView
|
||||
assert.NoError(t, ReadResponse(w, &views))
|
||||
assert.Equal(t, len(views), 1)
|
||||
GetCards(w, r)
|
||||
var cards []Card
|
||||
assert.NoError(t, ReadResponse(w, &cards))
|
||||
assert.Equal(t, len(cards), 1)
|
||||
|
||||
// get B card in A
|
||||
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)
|
||||
SetBearerAuth(r, a)
|
||||
GetCard(w, r)
|
||||
@ -89,7 +89,7 @@ func TestConnectContact(t *testing.T) {
|
||||
|
||||
// update B status to connecting
|
||||
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)
|
||||
SetBearerAuth(r, a)
|
||||
SetCardStatus(w, r)
|
||||
@ -97,7 +97,7 @@ func TestConnectContact(t *testing.T) {
|
||||
|
||||
// get open message to B
|
||||
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)
|
||||
SetBearerAuth(r, a)
|
||||
GetOpenMessage(w, r)
|
||||
@ -117,7 +117,7 @@ func TestConnectContact(t *testing.T) {
|
||||
|
||||
// update B status to connected
|
||||
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)
|
||||
SetBearerAuth(r, a)
|
||||
SetCardStatus(w, r)
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
)
|
||||
|
||||
func TestProfileNotification(t *testing.T) {
|
||||
var views []CardView
|
||||
var cards []Card
|
||||
var revision Revision
|
||||
var ws *websocket.Conn
|
||||
var err error
|
||||
@ -20,13 +20,13 @@ func TestProfileNotification(t *testing.T) {
|
||||
OpenTestCard(a, aCard)
|
||||
OpenTestCard(b, bCard)
|
||||
|
||||
// get views list of cards
|
||||
r, w, _ := NewRequest("GET", "/contact/cards/view", nil)
|
||||
// get list of cards
|
||||
r, w, _ := NewRequest("GET", "/contact/cards", nil)
|
||||
SetBearerAuth(r, a)
|
||||
GetCardView(w, r)
|
||||
assert.NoError(t, ReadResponse(w, &views))
|
||||
assert.Equal(t, len(views), 1)
|
||||
profileRevision := views[0].NotifiedProfile
|
||||
GetCards(w, r)
|
||||
assert.NoError(t, ReadResponse(w, &cards))
|
||||
assert.Equal(t, len(cards), 1)
|
||||
profileRevision := cards[0].NotifiedProfile
|
||||
|
||||
// app connects websocket
|
||||
ws, err = StatusConnection(a, &revision);
|
||||
@ -49,11 +49,11 @@ func TestProfileNotification(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
assert.NotEqual(t, cardRevision, revision.Card)
|
||||
|
||||
// get views list of cards
|
||||
r, w, _ = NewRequest("GET", "/contact/cards/view", nil)
|
||||
// get list of cards
|
||||
r, w, _ = NewRequest("GET", "/contact/cards", nil)
|
||||
SetBearerAuth(r, a)
|
||||
GetCardView(w, r)
|
||||
assert.NoError(t, ReadResponse(w, &views))
|
||||
assert.Equal(t, len(views), 1)
|
||||
assert.NotEqual(t, profileRevision, views[0].NotifiedProfile)
|
||||
GetCards(w, r)
|
||||
assert.NoError(t, ReadResponse(w, &cards))
|
||||
assert.Equal(t, len(cards), 1)
|
||||
assert.NotEqual(t, profileRevision, cards[0].NotifiedProfile)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user