diff --git a/doc/api.oa3 b/doc/api.oa3 index a6807fb1..b0ca7305 100644 --- a/doc/api.oa3 +++ b/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 @@ -4507,7 +4495,7 @@ components: value: type: string format: json string of Connect, Disconnect, Authenticate, or Profile - + ContactStatus: type: object required: @@ -4518,7 +4506,7 @@ components: status: type: string enum: [ pending, confirmed, requested, connecting, connected ] - + DataMessage: type: object required: diff --git a/net/server/internal/api_contact.go b/net/server/internal/api_contact.go index 5a8e8517..20e553ae 100644 --- a/net/server/internal/api_contact.go +++ b/net/server/internal/api_contact.go @@ -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) diff --git a/net/server/internal/api_getCardView.go b/net/server/internal/api_getCardView.go new file mode 100644 index 00000000..94f76aae --- /dev/null +++ b/net/server/internal/api_getCardView.go @@ -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) +} diff --git a/net/server/internal/api_status.go b/net/server/internal/api_status.go index db830229..b6a03608 100644 --- a/net/server/internal/api_status.go +++ b/net/server/internal/api_status.go @@ -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) diff --git a/net/server/internal/models.go b/net/server/internal/models.go index d7e81d74..ca751b23 100644 --- a/net/server/internal/models.go +++ b/net/server/internal/models.go @@ -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 { diff --git a/net/server/internal/ucConnectContact_test.go b/net/server/internal/ucConnectContact_test.go index f4e8c9ff..b06390d7 100644 --- a/net/server/internal/ucConnectContact_test.go +++ b/net/server/internal/ucConnectContact_test.go @@ -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 }