mirror of
https://github.com/balzack/databag.git
synced 2025-02-12 03:29:16 +00:00
adding get card view
This commit is contained in:
parent
6bfd7762c0
commit
e427f1c302
34
doc/api.oa3
34
doc/api.oa3
@ -1111,8 +1111,6 @@ paths:
|
||||
description: permission denied
|
||||
'404':
|
||||
description: card not found
|
||||
'405':
|
||||
description: invalid card state
|
||||
'410':
|
||||
description: account disabled
|
||||
'500':
|
||||
@ -1130,15 +1128,7 @@ paths:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
required:
|
||||
- status
|
||||
properties:
|
||||
token:
|
||||
type: string
|
||||
status:
|
||||
type: string
|
||||
enum: [ pending, confirmed, requested, connecting, connected ]
|
||||
$ref: '#/components/schemas/ContactStatus'
|
||||
'400':
|
||||
description: invalid data message
|
||||
'410':
|
||||
@ -4073,30 +4063,30 @@ components:
|
||||
required:
|
||||
- cardId
|
||||
- profileRevision
|
||||
- contentRevision
|
||||
- cardRevision
|
||||
- dataRevision
|
||||
- remoteProfile
|
||||
- remoteContent
|
||||
properties:
|
||||
cardId:
|
||||
type: string
|
||||
cardRevision:
|
||||
type: integer
|
||||
format: int64
|
||||
profileRevision:
|
||||
type: integer
|
||||
format: int64
|
||||
contentRevision:
|
||||
dataRevision:
|
||||
type: integer
|
||||
format: int64
|
||||
remoteProfile:
|
||||
type: integer
|
||||
format: int64
|
||||
remoteContent:
|
||||
type: integer
|
||||
format: int64
|
||||
|
||||
CardProfile:
|
||||
type: object
|
||||
required:
|
||||
- guid
|
||||
- version
|
||||
- node
|
||||
properties:
|
||||
guid:
|
||||
type: string
|
||||
handle:
|
||||
type: string
|
||||
name:
|
||||
@ -4110,8 +4100,6 @@ components:
|
||||
format: int64
|
||||
imageSet:
|
||||
type: boolean
|
||||
version:
|
||||
type: string
|
||||
node:
|
||||
type: string
|
||||
|
||||
|
@ -43,11 +43,6 @@ func GetCardProfileImage(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
}
|
||||
|
||||
func GetCardView(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
}
|
||||
|
||||
func GetCloseMessage(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
31
net/server/internal/api_getCardView.go
Normal file
31
net/server/internal/api_getCardView.go
Normal file
@ -0,0 +1,31 @@
|
||||
package databag
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"databag/internal/store"
|
||||
)
|
||||
|
||||
type cardView struct {
|
||||
CardId string
|
||||
ProfileRevision int64
|
||||
DataRevision int64
|
||||
RemoteProfile int64
|
||||
RemoteContent 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.ID).Find(&views).Error; err != nil {
|
||||
ErrResponse(w, http.StatusInternalServerError, err)
|
||||
return
|
||||
}
|
||||
|
||||
WriteResponse(w, &views)
|
||||
}
|
@ -9,17 +9,6 @@ import (
|
||||
"databag/internal/store"
|
||||
)
|
||||
|
||||
type accountRevision struct {
|
||||
ProfileRevision int64
|
||||
ContentRevision int64
|
||||
ViewRevision int64
|
||||
GroupRevision int64
|
||||
LabelRevision int64
|
||||
CardRevision int64
|
||||
DialogueRevision int64
|
||||
InsightRevision int64
|
||||
}
|
||||
|
||||
var wsSync sync.Mutex
|
||||
var wsExit = make(chan bool, 1)
|
||||
var statusListener = make(map[uint][]chan<-[]byte)
|
||||
|
@ -98,9 +98,10 @@ type CardProfile struct {
|
||||
|
||||
type CardView struct {
|
||||
CardId string `json:"cardId"`
|
||||
CardRevision int64 `json:"cardRevision"`
|
||||
ProfileRevision int64 `json:"profileRevision"`
|
||||
ContentRevision int64 `json:"contentRevision"`
|
||||
DataRevision int64 `json:"dataRevision"`
|
||||
RemoteProfile int64 `json:"remoteProfile"`
|
||||
RemoteContent int64 `json:"remoteContent"`
|
||||
}
|
||||
|
||||
type ContentArticlesBody struct {
|
||||
|
@ -73,17 +73,28 @@ func TestConnectContact(t *testing.T) {
|
||||
var contactStatus ContactStatus
|
||||
assert.NoError(t, ReadResponse(w, &contactStatus))
|
||||
|
||||
PrintMsg(contactStatus)
|
||||
// get view of cards in A
|
||||
r, w, _ = NewRequest("GET", "/contact/card/view", nil)
|
||||
SetBearerAuth(r, access[0])
|
||||
GetCardView(w, r)
|
||||
var views []CardView
|
||||
assert.NoError(t, ReadResponse(w, &views))
|
||||
|
||||
// A request B
|
||||
PrintMsg(views);
|
||||
|
||||
// set B card in A
|
||||
|
||||
// get A open message
|
||||
// get new card
|
||||
|
||||
// set A card in B
|
||||
// set status of pending to connecting
|
||||
|
||||
// create open message
|
||||
|
||||
// deliver open message
|
||||
|
||||
// receive websocket message
|
||||
|
||||
// update status to connected
|
||||
|
||||
// accept A
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user