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
38
doc/api.oa3
38
doc/api.oa3
@ -1111,8 +1111,6 @@ paths:
|
|||||||
description: permission denied
|
description: permission denied
|
||||||
'404':
|
'404':
|
||||||
description: card not found
|
description: card not found
|
||||||
'405':
|
|
||||||
description: invalid card state
|
|
||||||
'410':
|
'410':
|
||||||
description: account disabled
|
description: account disabled
|
||||||
'500':
|
'500':
|
||||||
@ -1130,15 +1128,7 @@ paths:
|
|||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
type: object
|
$ref: '#/components/schemas/ContactStatus'
|
||||||
required:
|
|
||||||
- status
|
|
||||||
properties:
|
|
||||||
token:
|
|
||||||
type: string
|
|
||||||
status:
|
|
||||||
type: string
|
|
||||||
enum: [ pending, confirmed, requested, connecting, connected ]
|
|
||||||
'400':
|
'400':
|
||||||
description: invalid data message
|
description: invalid data message
|
||||||
'410':
|
'410':
|
||||||
@ -4073,30 +4063,30 @@ components:
|
|||||||
required:
|
required:
|
||||||
- cardId
|
- cardId
|
||||||
- profileRevision
|
- profileRevision
|
||||||
- contentRevision
|
- dataRevision
|
||||||
- cardRevision
|
- remoteProfile
|
||||||
|
- remoteContent
|
||||||
properties:
|
properties:
|
||||||
cardId:
|
cardId:
|
||||||
type: string
|
type: string
|
||||||
cardRevision:
|
|
||||||
type: integer
|
|
||||||
format: int64
|
|
||||||
profileRevision:
|
profileRevision:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
contentRevision:
|
dataRevision:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
remoteProfile:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
remoteContent:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
|
|
||||||
CardProfile:
|
CardProfile:
|
||||||
type: object
|
type: object
|
||||||
required:
|
required:
|
||||||
- guid
|
|
||||||
- version
|
|
||||||
- node
|
- node
|
||||||
properties:
|
properties:
|
||||||
guid:
|
|
||||||
type: string
|
|
||||||
handle:
|
handle:
|
||||||
type: string
|
type: string
|
||||||
name:
|
name:
|
||||||
@ -4110,8 +4100,6 @@ components:
|
|||||||
format: int64
|
format: int64
|
||||||
imageSet:
|
imageSet:
|
||||||
type: boolean
|
type: boolean
|
||||||
version:
|
|
||||||
type: string
|
|
||||||
node:
|
node:
|
||||||
type: string
|
type: string
|
||||||
|
|
||||||
@ -4507,7 +4495,7 @@ components:
|
|||||||
value:
|
value:
|
||||||
type: string
|
type: string
|
||||||
format: json string of Connect, Disconnect, Authenticate, or Profile
|
format: json string of Connect, Disconnect, Authenticate, or Profile
|
||||||
|
|
||||||
ContactStatus:
|
ContactStatus:
|
||||||
type: object
|
type: object
|
||||||
required:
|
required:
|
||||||
@ -4518,7 +4506,7 @@ components:
|
|||||||
status:
|
status:
|
||||||
type: string
|
type: string
|
||||||
enum: [ pending, confirmed, requested, connecting, connected ]
|
enum: [ pending, confirmed, requested, connecting, connected ]
|
||||||
|
|
||||||
DataMessage:
|
DataMessage:
|
||||||
type: object
|
type: object
|
||||||
required:
|
required:
|
||||||
|
@ -43,11 +43,6 @@ func GetCardProfileImage(w http.ResponseWriter, r *http.Request) {
|
|||||||
w.WriteHeader(http.StatusOK)
|
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) {
|
func GetCloseMessage(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
|
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
|
||||||
w.WriteHeader(http.StatusOK)
|
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"
|
"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 wsSync sync.Mutex
|
||||||
var wsExit = make(chan bool, 1)
|
var wsExit = make(chan bool, 1)
|
||||||
var statusListener = make(map[uint][]chan<-[]byte)
|
var statusListener = make(map[uint][]chan<-[]byte)
|
||||||
|
@ -98,9 +98,10 @@ type CardProfile struct {
|
|||||||
|
|
||||||
type CardView struct {
|
type CardView struct {
|
||||||
CardId string `json:"cardId"`
|
CardId string `json:"cardId"`
|
||||||
CardRevision int64 `json:"cardRevision"`
|
|
||||||
ProfileRevision int64 `json:"profileRevision"`
|
ProfileRevision int64 `json:"profileRevision"`
|
||||||
ContentRevision int64 `json:"contentRevision"`
|
DataRevision int64 `json:"dataRevision"`
|
||||||
|
RemoteProfile int64 `json:"remoteProfile"`
|
||||||
|
RemoteContent int64 `json:"remoteContent"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ContentArticlesBody struct {
|
type ContentArticlesBody struct {
|
||||||
|
@ -73,17 +73,28 @@ func TestConnectContact(t *testing.T) {
|
|||||||
var contactStatus ContactStatus
|
var contactStatus ContactStatus
|
||||||
assert.NoError(t, ReadResponse(w, &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