mirror of
https://github.com/balzack/databag.git
synced 2025-02-12 03:29:16 +00:00
added status timestamp to cards
This commit is contained in:
parent
067422cfaf
commit
35a4a51094
@ -3510,6 +3510,9 @@ components:
|
|||||||
status:
|
status:
|
||||||
type: string
|
type: string
|
||||||
enum: [ pending, confirmed, requested, connecting, connected ]
|
enum: [ pending, confirmed, requested, connecting, connected ]
|
||||||
|
statusUpdated:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
token:
|
token:
|
||||||
type: string
|
type: string
|
||||||
notes:
|
notes:
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package databag
|
package databag
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"time"
|
||||||
"databag/internal/store"
|
"databag/internal/store"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"errors"
|
"errors"
|
||||||
@ -57,6 +58,7 @@ func AddCard(w http.ResponseWriter, r *http.Request) {
|
|||||||
Node: identity.Node,
|
Node: identity.Node,
|
||||||
ProfileRevision: identity.Revision,
|
ProfileRevision: identity.Revision,
|
||||||
Status: APPCardConfirmed,
|
Status: APPCardConfirmed,
|
||||||
|
StatusUpdated: time.Now().Unix(),
|
||||||
ViewRevision: 0,
|
ViewRevision: 0,
|
||||||
InToken: hex.EncodeToString(data),
|
InToken: hex.EncodeToString(data),
|
||||||
AccountID: account.GUID,
|
AccountID: account.GUID,
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"databag/internal/store"
|
"databag/internal/store"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"errors"
|
"errors"
|
||||||
|
"time"
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"github.com/theckman/go-securerandom"
|
"github.com/theckman/go-securerandom"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
@ -105,6 +106,7 @@ func SetCardStatus(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
slot.Card.Status = status
|
slot.Card.Status = status
|
||||||
|
slot.Card.StatusUpdated = time.Now().Unix()
|
||||||
slot.Card.NotifiedView = viewRevision
|
slot.Card.NotifiedView = viewRevision
|
||||||
slot.Card.NotifiedArticle = articleRevision
|
slot.Card.NotifiedArticle = articleRevision
|
||||||
slot.Card.NotifiedChannel = channelRevision
|
slot.Card.NotifiedChannel = channelRevision
|
||||||
|
@ -56,6 +56,9 @@ func SetCloseMessage(w http.ResponseWriter, r *http.Request) {
|
|||||||
if res := tx.Model(&card).Update("status", APPCardConfirmed).Error; res != nil {
|
if res := tx.Model(&card).Update("status", APPCardConfirmed).Error; res != nil {
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
if res := tx.Model(&card).Update("status_updated", time.Now().Unix()).Error; res != nil {
|
||||||
|
return res
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if res := tx.Model(&card).Update("detail_revision", account.CardRevision+1).Error; res != nil {
|
if res := tx.Model(&card).Update("detail_revision", account.CardRevision+1).Error; res != nil {
|
||||||
return res
|
return res
|
||||||
|
@ -67,6 +67,7 @@ func SetOpenMessage(w http.ResponseWriter, r *http.Request) {
|
|||||||
card.Node = connect.Node
|
card.Node = connect.Node
|
||||||
card.ProfileRevision = connect.ProfileRevision
|
card.ProfileRevision = connect.ProfileRevision
|
||||||
card.Status = APPCardPending
|
card.Status = APPCardPending
|
||||||
|
card.StatusUpdated = time.Now().Unix()
|
||||||
card.NotifiedProfile = connect.ProfileRevision
|
card.NotifiedProfile = connect.ProfileRevision
|
||||||
card.NotifiedArticle = connect.ArticleRevision
|
card.NotifiedArticle = connect.ArticleRevision
|
||||||
card.NotifiedView = connect.ViewRevision
|
card.NotifiedView = connect.ViewRevision
|
||||||
@ -124,9 +125,11 @@ func SetOpenMessage(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
if card.Status == APPCardConfirmed {
|
if card.Status == APPCardConfirmed {
|
||||||
card.Status = APPCardRequested
|
card.Status = APPCardRequested
|
||||||
|
card.StatusUpdated = time.Now().Unix()
|
||||||
}
|
}
|
||||||
if card.Status == APPCardConnecting {
|
if card.Status == APPCardConnecting {
|
||||||
card.Status = APPCardConnected
|
card.Status = APPCardConnected
|
||||||
|
card.StatusUpdated = time.Now().Unix()
|
||||||
}
|
}
|
||||||
card.OutToken = connect.Token
|
card.OutToken = connect.Token
|
||||||
card.DetailRevision = account.CardRevision + 1
|
card.DetailRevision = account.CardRevision + 1
|
||||||
|
@ -69,13 +69,14 @@ func getCardRevisionModel(slot *store.CardSlot) *Card {
|
|||||||
|
|
||||||
func getCardDetailModel(slot *store.CardSlot) *CardDetail {
|
func getCardDetailModel(slot *store.CardSlot) *CardDetail {
|
||||||
|
|
||||||
var groups []string
|
var groups []string = []string{}
|
||||||
for _, group := range slot.Card.Groups {
|
for _, group := range slot.Card.Groups {
|
||||||
groups = append(groups, group.GroupSlot.GroupSlotID)
|
groups = append(groups, group.GroupSlot.GroupSlotID)
|
||||||
}
|
}
|
||||||
|
|
||||||
return &CardDetail{
|
return &CardDetail{
|
||||||
Status: slot.Card.Status,
|
Status: slot.Card.Status,
|
||||||
|
StatusUpdated: slot.Card.StatusUpdated,
|
||||||
Token: slot.Card.OutToken,
|
Token: slot.Card.OutToken,
|
||||||
Notes: slot.Card.Notes,
|
Notes: slot.Card.Notes,
|
||||||
Groups: groups,
|
Groups: groups,
|
||||||
|
@ -113,7 +113,9 @@ type CardData struct {
|
|||||||
type CardDetail struct {
|
type CardDetail struct {
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
|
|
||||||
Token string `json:"token,omitempty"`
|
StatusUpdated int64 `json:"statusUpdated"`
|
||||||
|
|
||||||
|
Token string `json:"token,omitempty"`
|
||||||
|
|
||||||
Notes string `json:"notes,omitempty"`
|
Notes string `json:"notes,omitempty"`
|
||||||
|
|
||||||
|
@ -151,6 +151,7 @@ type Card struct {
|
|||||||
ProfileRevision int64 `gorm:"not null"`
|
ProfileRevision int64 `gorm:"not null"`
|
||||||
DetailRevision int64 `gorm:"not null;default:1"`
|
DetailRevision int64 `gorm:"not null;default:1"`
|
||||||
Status string `gorm:"not null"`
|
Status string `gorm:"not null"`
|
||||||
|
StatusUpdated int64
|
||||||
InToken string `gorm:"not null;index:cardguid,unique"`
|
InToken string `gorm:"not null;index:cardguid,unique"`
|
||||||
OutToken string
|
OutToken string
|
||||||
Notes string
|
Notes string
|
||||||
|
Loading…
Reference in New Issue
Block a user