golint doesnt like my naming, fine whatever

This commit is contained in:
Roland Osborne 2022-07-22 10:15:44 -07:00
parent 805b397ddc
commit 4716462368
90 changed files with 969 additions and 969 deletions

View File

@ -82,7 +82,7 @@ func AddAccount(w http.ResponseWriter, r *http.Request) {
Username: username, Username: username,
Handle: strings.ToLower(username), Handle: strings.ToLower(username),
Password: password, Password: password,
Guid: fingerprint, GUID: fingerprint,
} }
detail := store.AccountDetail{ detail := store.AccountDetail{
PublicKey: publicPem, PublicKey: publicPem,
@ -113,7 +113,7 @@ func AddAccount(w http.ResponseWriter, r *http.Request) {
// create response // create response
profile := Profile{ profile := Profile{
Guid: account.Guid, GUID: account.GUID,
Handle: account.Username, Handle: account.Username,
Name: detail.Name, Name: detail.Name,
Description: detail.Description, Description: detail.Description,

View File

@ -33,7 +33,7 @@ func AddAccountApp(w http.ResponseWriter, r *http.Request) {
// create app entry // create app entry
app := store.App { app := store.App {
AccountID: account.Guid, AccountID: account.GUID,
Name: appData.Name, Name: appData.Name,
Description: appData.Description, Description: appData.Description,
Image: appData.Image, Image: appData.Image,
@ -54,7 +54,7 @@ func AddAccountApp(w http.ResponseWriter, r *http.Request) {
} }
login := LoginAccess { login := LoginAccess {
AppToken: account.Guid + "." + access, AppToken: account.GUID + "." + access,
Created: app.Created, Created: app.Created,
} }

View File

@ -32,7 +32,7 @@ func AddArticle(w http.ResponseWriter, r *http.Request) {
return res return res
} }
slot.ArticleSlotId = uuid.New().String() slot.ArticleSlotID = uuid.New().String()
slot.AccountID = account.ID slot.AccountID = account.ID
slot.ArticleID = article.ID slot.ArticleID = article.ID
slot.Revision = account.ArticleRevision + 1 slot.Revision = account.ArticleRevision + 1

View File

@ -33,7 +33,7 @@ func AddCard(w http.ResponseWriter, r *http.Request) {
slot := &store.CardSlot{} slot := &store.CardSlot{}
var card store.Card var card store.Card
if err := store.DB.Preload("CardSlot").Preload("Groups").Where("account_id = ? AND guid = ?", account.Guid, guid).First(&card).Error; err != nil { if err := store.DB.Preload("CardSlot").Preload("Groups").Where("account_id = ? AND guid = ?", account.GUID, guid).First(&card).Error; err != nil {
if !errors.Is(err, gorm.ErrRecordNotFound) { if !errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusInternalServerError, err) ErrResponse(w, http.StatusInternalServerError, err)
return return
@ -46,7 +46,7 @@ func AddCard(w http.ResponseWriter, r *http.Request) {
return return
} }
card := &store.Card{ card := &store.Card{
Guid: guid, GUID: guid,
Username: identity.Handle, Username: identity.Handle,
Name: identity.Name, Name: identity.Name,
Description: identity.Description, Description: identity.Description,
@ -58,7 +58,7 @@ func AddCard(w http.ResponseWriter, r *http.Request) {
Status: APP_CARDCONFIRMED, Status: APP_CARDCONFIRMED,
ViewRevision: 0, ViewRevision: 0,
InToken: hex.EncodeToString(data), InToken: hex.EncodeToString(data),
AccountID: account.Guid, AccountID: account.GUID,
} }
// save new card // save new card
@ -66,7 +66,7 @@ func AddCard(w http.ResponseWriter, r *http.Request) {
if res := tx.Save(card).Error; res != nil { if res := tx.Save(card).Error; res != nil {
return res return res
} }
slot.CardSlotId = uuid.New().String() slot.CardSlotID = uuid.New().String()
slot.AccountID = account.ID slot.AccountID = account.ID
slot.Revision = account.CardRevision + 1 slot.Revision = account.CardRevision + 1
slot.CardID = card.ID slot.CardID = card.ID
@ -110,7 +110,7 @@ func AddCard(w http.ResponseWriter, r *http.Request) {
slot = &card.CardSlot slot = &card.CardSlot
if slot == nil { if slot == nil {
slot = &store.CardSlot{ slot = &store.CardSlot{
CardSlotId: uuid.New().String(), CardSlotID: uuid.New().String(),
AccountID: account.ID, AccountID: account.ID,
Revision: account.CardRevision + 1, Revision: account.CardRevision + 1,
CardID: card.ID, CardID: card.ID,

View File

@ -35,7 +35,7 @@ func AddChannel(w http.ResponseWriter, r *http.Request) {
return res return res
} }
slot.ChannelSlotId = uuid.New().String() slot.ChannelSlotID = uuid.New().String()
slot.AccountID = account.ID slot.AccountID = account.ID
slot.ChannelID = channel.ID slot.ChannelID = channel.ID
slot.Revision = account.ChannelRevision + 1 slot.Revision = account.ChannelRevision + 1
@ -43,9 +43,9 @@ func AddChannel(w http.ResponseWriter, r *http.Request) {
if res := tx.Save(slot).Error; res != nil { if res := tx.Save(slot).Error; res != nil {
return res return res
} }
for _, cardId := range params.Cards { for _, cardID := range params.Cards {
cardSlot := store.CardSlot{} cardSlot := store.CardSlot{}
if res := tx.Preload("Card").Where("account_id = ? AND card_slot_id = ?", account.ID, cardId).First(&cardSlot).Error; res != nil { if res := tx.Preload("Card").Where("account_id = ? AND card_slot_id = ?", account.ID, cardID).First(&cardSlot).Error; res != nil {
return res return res
} }
if res := tx.Model(&slot.Channel).Association("Cards").Append(cardSlot.Card); res != nil { if res := tx.Model(&slot.Channel).Association("Cards").Append(cardSlot.Card); res != nil {
@ -54,9 +54,9 @@ func AddChannel(w http.ResponseWriter, r *http.Request) {
cards = append(cards, cardSlot.Card); cards = append(cards, cardSlot.Card);
} }
for _, groupId := range params.Groups { for _, groupID := range params.Groups {
groupSlot := store.GroupSlot{} groupSlot := store.GroupSlot{}
if res := tx.Preload("Group").Where("account_id = ? AND group_slot_id = ?", account.ID, groupId).First(&groupSlot).Error; res != nil { if res := tx.Preload("Group").Where("account_id = ? AND group_slot_id = ?", account.ID, groupID).First(&groupSlot).Error; res != nil {
return res return res
} }
if res := tx.Model(&slot.Channel).Association("Groups").Append(groupSlot.Group); res != nil { if res := tx.Model(&slot.Channel).Association("Groups").Append(groupSlot.Group); res != nil {

View File

@ -27,7 +27,7 @@ func AddChannelTopic(w http.ResponseWriter, r *http.Request) {
topicSlot := &store.TopicSlot{} topicSlot := &store.TopicSlot{}
err = store.DB.Transaction(func(tx *gorm.DB) error { err = store.DB.Transaction(func(tx *gorm.DB) error {
topicSlot.TopicSlotId = uuid.New().String() topicSlot.TopicSlotID = uuid.New().String()
topicSlot.AccountID = act.ID topicSlot.AccountID = act.ID
topicSlot.ChannelID = channelSlot.Channel.ID topicSlot.ChannelID = channelSlot.Channel.ID
topicSlot.Revision = act.ChannelRevision + 1 topicSlot.Revision = act.ChannelRevision + 1
@ -41,7 +41,7 @@ func AddChannelTopic(w http.ResponseWriter, r *http.Request) {
topic.TopicSlotID = topicSlot.ID topic.TopicSlotID = topicSlot.ID
topic.Data = subject.Data topic.Data = subject.Data
topic.DataType = subject.DataType topic.DataType = subject.DataType
topic.Guid = guid topic.GUID = guid
topic.DetailRevision = act.ChannelRevision + 1 topic.DetailRevision = act.ChannelRevision + 1
topic.TagRevision = act.ChannelRevision + 1 topic.TagRevision = act.ChannelRevision + 1
if confirm == "true" { if confirm == "true" {
@ -75,11 +75,11 @@ func AddChannelTopic(w http.ResponseWriter, r *http.Request) {
// determine affected contact list // determine affected contact list
cards := make(map[string]store.Card) cards := make(map[string]store.Card)
for _, card := range channelSlot.Channel.Cards { for _, card := range channelSlot.Channel.Cards {
cards[card.Guid] = card cards[card.GUID] = card
} }
for _, group := range channelSlot.Channel.Groups { for _, group := range channelSlot.Channel.Groups {
for _, card := range group.Cards { for _, card := range group.Cards {
cards[card.Guid] = card cards[card.GUID] = card
} }
} }

View File

@ -18,7 +18,7 @@ func AddChannelTopicAsset(w http.ResponseWriter, r *http.Request) {
// scan parameters // scan parameters
params := mux.Vars(r) params := mux.Vars(r)
topicId := params["topicId"] topicID := params["topicID"]
var transforms []string var transforms []string
if r.FormValue("transforms") != "" { if r.FormValue("transforms") != "" {
if err := json.Unmarshal([]byte(r.FormValue("transforms")), &transforms); err != nil { if err := json.Unmarshal([]byte(r.FormValue("transforms")), &transforms); err != nil {
@ -45,7 +45,7 @@ func AddChannelTopicAsset(w http.ResponseWriter, r *http.Request) {
// load topic // load topic
var topicSlot store.TopicSlot var topicSlot store.TopicSlot
if err = store.DB.Preload("Topic").Where("channel_id = ? AND topic_slot_id = ?", channelSlot.Channel.ID, topicId).First(&topicSlot).Error; err != nil { if err = store.DB.Preload("Topic").Where("channel_id = ? AND topic_slot_id = ?", channelSlot.Channel.ID, topicID).First(&topicSlot).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) { if errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusNotFound, err) ErrResponse(w, http.StatusNotFound, err)
} else { } else {
@ -59,7 +59,7 @@ func AddChannelTopicAsset(w http.ResponseWriter, r *http.Request) {
} }
// can only update topic if creator // can only update topic if creator
if topicSlot.Topic.Guid != guid { if topicSlot.Topic.GUID != guid {
ErrResponse(w, http.StatusUnauthorized, errors.New("topic not created by you")) ErrResponse(w, http.StatusUnauthorized, errors.New("topic not created by you"))
return return
} }
@ -70,7 +70,7 @@ func AddChannelTopicAsset(w http.ResponseWriter, r *http.Request) {
// save new file // save new file
id := uuid.New().String() id := uuid.New().String()
path := getStrConfigValue(CONFIG_ASSETPATH, APP_DEFAULTPATH) + "/" + channelSlot.Account.Guid + "/" + id path := getStrConfigValue(CONFIG_ASSETPATH, APP_DEFAULTPATH) + "/" + channelSlot.Account.GUID + "/" + id
if err := r.ParseMultipartForm(32 << 20); err != nil { if err := r.ParseMultipartForm(32 << 20); err != nil {
ErrResponse(w, http.StatusBadRequest, err) ErrResponse(w, http.StatusBadRequest, err)
return return
@ -90,7 +90,7 @@ func AddChannelTopicAsset(w http.ResponseWriter, r *http.Request) {
assets := []Asset{} assets := []Asset{}
asset := &store.Asset{} asset := &store.Asset{}
asset.AssetId = id asset.AssetID = id
asset.AccountID = channelSlot.Account.ID asset.AccountID = channelSlot.Account.ID
asset.ChannelID = channelSlot.Channel.ID asset.ChannelID = channelSlot.Channel.ID
asset.TopicID = topicSlot.Topic.ID asset.TopicID = topicSlot.Topic.ID
@ -101,15 +101,15 @@ func AddChannelTopicAsset(w http.ResponseWriter, r *http.Request) {
if res := tx.Save(asset).Error; res != nil { if res := tx.Save(asset).Error; res != nil {
return res return res
} }
assets = append(assets, Asset{ AssetId: id, Status: APP_ASSETREADY}) assets = append(assets, Asset{ AssetID: id, Status: APP_ASSETREADY})
for _, transform := range transforms { for _, transform := range transforms {
asset := &store.Asset{} asset := &store.Asset{}
asset.AssetId = uuid.New().String() asset.AssetID = uuid.New().String()
asset.AccountID = channelSlot.Account.ID asset.AccountID = channelSlot.Account.ID
asset.ChannelID = channelSlot.Channel.ID asset.ChannelID = channelSlot.Channel.ID
asset.TopicID = topicSlot.Topic.ID asset.TopicID = topicSlot.Topic.ID
asset.Status = APP_ASSETWAITING asset.Status = APP_ASSETWAITING
asset.TransformId = id asset.TransformID = id
t := strings.Split(transform, ";") t := strings.Split(transform, ";")
if len(t) > 0 { if len(t) > 0 {
asset.Transform = t[0] asset.Transform = t[0]
@ -123,7 +123,7 @@ func AddChannelTopicAsset(w http.ResponseWriter, r *http.Request) {
if res := tx.Save(asset).Error; res != nil { if res := tx.Save(asset).Error; res != nil {
return res return res
} }
assets = append(assets, Asset{ AssetId: asset.AssetId, Transform: transform, Status: APP_ASSETWAITING}) assets = append(assets, Asset{ AssetID: asset.AssetID, Transform: transform, Status: APP_ASSETWAITING})
} }
if res := tx.Model(&topicSlot.Topic).Update("detail_revision", act.ChannelRevision + 1).Error; res != nil { if res := tx.Model(&topicSlot.Topic).Update("detail_revision", act.ChannelRevision + 1).Error; res != nil {
return res return res
@ -153,11 +153,11 @@ func AddChannelTopicAsset(w http.ResponseWriter, r *http.Request) {
// determine affected contact list // determine affected contact list
cards := make(map[string]store.Card) cards := make(map[string]store.Card)
for _, card := range channelSlot.Channel.Cards { for _, card := range channelSlot.Channel.Cards {
cards[card.Guid] = card cards[card.GUID] = card
} }
for _, group := range channelSlot.Channel.Groups { for _, group := range channelSlot.Channel.Groups {
for _, card := range group.Cards { for _, card := range group.Cards {
cards[card.Guid] = card cards[card.GUID] = card
} }
} }

View File

@ -13,7 +13,7 @@ func AddChannelTopicTag(w http.ResponseWriter, r *http.Request) {
// scan parameters // scan parameters
params := mux.Vars(r) params := mux.Vars(r)
topicId := params["topicId"] topicID := params["topicID"]
var subject Subject var subject Subject
if err := ParseRequest(r, w, &subject); err != nil { if err := ParseRequest(r, w, &subject); err != nil {
@ -30,7 +30,7 @@ func AddChannelTopicTag(w http.ResponseWriter, r *http.Request) {
// load topic // load topic
var topicSlot store.TopicSlot var topicSlot store.TopicSlot
if err = store.DB.Preload("Topic.Tags").Where("channel_id = ? AND topic_slot_id = ?", channelSlot.Channel.ID, topicId).First(&topicSlot).Error; err != nil { if err = store.DB.Preload("Topic.Tags").Where("channel_id = ? AND topic_slot_id = ?", channelSlot.Channel.ID, topicID).First(&topicSlot).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) { if errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusNotFound, err) ErrResponse(w, http.StatusNotFound, err)
} else { } else {
@ -47,7 +47,7 @@ func AddChannelTopicTag(w http.ResponseWriter, r *http.Request) {
tagSlot := &store.TagSlot{} tagSlot := &store.TagSlot{}
err = store.DB.Transaction(func(tx *gorm.DB) error { err = store.DB.Transaction(func(tx *gorm.DB) error {
tagSlot.TagSlotId = uuid.New().String() tagSlot.TagSlotID = uuid.New().String()
tagSlot.AccountID = act.ID tagSlot.AccountID = act.ID
tagSlot.Revision = act.ChannelRevision + 1 tagSlot.Revision = act.ChannelRevision + 1
tagSlot.ChannelID = channelSlot.Channel.ID tagSlot.ChannelID = channelSlot.Channel.ID
@ -61,7 +61,7 @@ func AddChannelTopicTag(w http.ResponseWriter, r *http.Request) {
tag.ChannelID = channelSlot.Channel.ID tag.ChannelID = channelSlot.Channel.ID
tag.TopicID = topicSlot.Topic.ID tag.TopicID = topicSlot.Topic.ID
tag.TagSlotID = tagSlot.ID tag.TagSlotID = tagSlot.ID
tag.Guid = guid tag.GUID = guid
tag.DataType = subject.DataType tag.DataType = subject.DataType
tag.Data = subject.Data tag.Data = subject.Data
if res := tx.Save(tag).Error; res != nil { if res := tx.Save(tag).Error; res != nil {
@ -94,11 +94,11 @@ func AddChannelTopicTag(w http.ResponseWriter, r *http.Request) {
// determine affected contact list // determine affected contact list
cards := make(map[string]store.Card) cards := make(map[string]store.Card)
for _, card := range channelSlot.Channel.Cards { for _, card := range channelSlot.Channel.Cards {
cards[card.Guid] = card cards[card.GUID] = card
} }
for _, group := range channelSlot.Channel.Groups { for _, group := range channelSlot.Channel.Groups {
for _, card := range group.Cards { for _, card := range group.Cards {
cards[card.Guid] = card cards[card.GUID] = card
} }
} }

View File

@ -40,7 +40,7 @@ func AddGroup(w http.ResponseWriter, r *http.Request) {
return res return res
} }
slot.GroupSlotId = uuid.New().String() slot.GroupSlotID = uuid.New().String()
slot.AccountID = account.ID slot.AccountID = account.ID
slot.GroupID = group.ID slot.GroupID = group.ID
slot.Revision = account.GroupRevision + 1 slot.Revision = account.GroupRevision + 1

View File

@ -13,7 +13,7 @@ import (
func AddNodeAccountAccess(w http.ResponseWriter, r *http.Request) { func AddNodeAccountAccess(w http.ResponseWriter, r *http.Request) {
params := mux.Vars(r) params := mux.Vars(r)
accountId, res := strconv.ParseUint(params["accountId"], 10, 32) accountID, res := strconv.ParseUint(params["accountID"], 10, 32)
if res != nil { if res != nil {
ErrResponse(w, http.StatusBadRequest, res) ErrResponse(w, http.StatusBadRequest, res)
return return
@ -32,7 +32,7 @@ func AddNodeAccountAccess(w http.ResponseWriter, r *http.Request) {
token := hex.EncodeToString(data) token := hex.EncodeToString(data)
accountToken := store.AccountToken{ accountToken := store.AccountToken{
AccountID: uint(accountId), AccountID: uint(accountID),
TokenType: APP_TOKENRESET, TokenType: APP_TOKENRESET,
Token: token, Token: token,
Expires: time.Now().Unix() + APP_RESETEXPIRE, Expires: time.Now().Unix() + APP_RESETEXPIRE,

View File

@ -22,7 +22,7 @@ func Authorize(w http.ResponseWriter, r *http.Request) {
claim := &Claim{ Token: token } claim := &Claim{ Token: token }
msg, err := WriteDataMessage(detail.PrivateKey, detail.PublicKey, detail.KeyType, msg, err := WriteDataMessage(detail.PrivateKey, detail.PublicKey, detail.KeyType,
APP_SIGNPKCS1V15, account.Guid, APP_MSGAUTHENTICATE, &claim) APP_SIGNPKCS1V15, account.GUID, APP_MSGAUTHENTICATE, &claim)
if err != nil { if err != nil {
ErrResponse(w, http.StatusInternalServerError, err) ErrResponse(w, http.StatusInternalServerError, err)
return return

View File

@ -18,12 +18,12 @@ func ClearArticleGroup(w http.ResponseWriter, r *http.Request) {
// scan parameters // scan parameters
params := mux.Vars(r) params := mux.Vars(r)
articleId := params["articleId"] articleID := params["articleID"]
groupId := params["groupId"] groupID := params["groupID"]
// load referenced article // load referenced article
var articleSlot store.ArticleSlot var articleSlot store.ArticleSlot
if err := store.DB.Preload("Article").Where("account_id = ? AND article_slot_id = ?", account.ID, articleId).First(&articleSlot).Error; err != nil { if err := store.DB.Preload("Article").Where("account_id = ? AND article_slot_id = ?", account.ID, articleID).First(&articleSlot).Error; err != nil {
if !errors.Is(err, gorm.ErrRecordNotFound) { if !errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusInternalServerError, err) ErrResponse(w, http.StatusInternalServerError, err)
} else { } else {
@ -38,7 +38,7 @@ func ClearArticleGroup(w http.ResponseWriter, r *http.Request) {
// load referenced group // load referenced group
var groupSlot store.GroupSlot var groupSlot store.GroupSlot
if err := store.DB.Preload("Group.Cards").Where("account_id = ? AND group_slot_id = ?", account.ID, groupId).First(&groupSlot).Error; err != nil { if err := store.DB.Preload("Group.Cards").Where("account_id = ? AND group_slot_id = ?", account.ID, groupID).First(&groupSlot).Error; err != nil {
if !errors.Is(err, gorm.ErrRecordNotFound) { if !errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusInternalServerError, err) ErrResponse(w, http.StatusInternalServerError, err)
} else { } else {

View File

@ -18,12 +18,12 @@ func ClearCardGroup(w http.ResponseWriter, r *http.Request) {
// scan parameters // scan parameters
params := mux.Vars(r) params := mux.Vars(r)
cardId := params["cardId"] cardID := params["cardID"]
groupId := params["groupId"] groupID := params["groupID"]
// load referenced card // load referenced card
var cardSlot store.CardSlot var cardSlot store.CardSlot
if err := store.DB.Preload("Card").Where("account_id = ? AND card_slot_id = ?", account.ID, cardId).First(&cardSlot).Error; err != nil { if err := store.DB.Preload("Card").Where("account_id = ? AND card_slot_id = ?", account.ID, cardID).First(&cardSlot).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) { if errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusNotFound, err) ErrResponse(w, http.StatusNotFound, err)
} else { } else {
@ -38,7 +38,7 @@ func ClearCardGroup(w http.ResponseWriter, r *http.Request) {
// load referenced group // load referenced group
var groupSlot store.GroupSlot var groupSlot store.GroupSlot
if err := store.DB.Preload("Group").Where("account_id = ? AND group_slot_id = ?", account.ID, groupId).First(&groupSlot).Error; err != nil { if err := store.DB.Preload("Group").Where("account_id = ? AND group_slot_id = ?", account.ID, groupID).First(&groupSlot).Error; err != nil {
if !errors.Is(err, gorm.ErrRecordNotFound) { if !errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusInternalServerError, err) ErrResponse(w, http.StatusInternalServerError, err)
} else { } else {

View File

@ -18,11 +18,11 @@ func ClearCardNotes(w http.ResponseWriter, r *http.Request) {
// scan parameters // scan parameters
params := mux.Vars(r) params := mux.Vars(r)
cardId := params["cardId"] cardID := params["cardID"]
// load referenced card // load referenced card
var slot store.CardSlot var slot store.CardSlot
if err := store.DB.Preload("Card.Groups").Where("account_id = ? AND card_slot_id = ?", account.ID, cardId).First(&slot).Error; err != nil { if err := store.DB.Preload("Card.Groups").Where("account_id = ? AND card_slot_id = ?", account.ID, cardID).First(&slot).Error; err != nil {
if !errors.Is(err, gorm.ErrRecordNotFound) { if !errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusInternalServerError, err) ErrResponse(w, http.StatusInternalServerError, err)
} else { } else {

View File

@ -18,12 +18,12 @@ func ClearChannelCard(w http.ResponseWriter, r *http.Request) {
// scan parameters // scan parameters
params := mux.Vars(r) params := mux.Vars(r)
channelId := params["channelId"] channelID := params["channelID"]
cardId := params["cardId"] cardID := params["cardID"]
// load referenced channel // load referenced channel
var channelSlot store.ChannelSlot var channelSlot store.ChannelSlot
if err := store.DB.Preload("Channel.Cards.CardSlot").Preload("Channel.Groups.GroupSlot").Preload("Channel.Groups.Cards").Where("account_id = ? AND channel_slot_id = ?", account.ID, channelId).First(&channelSlot).Error; err != nil { if err := store.DB.Preload("Channel.Cards.CardSlot").Preload("Channel.Groups.GroupSlot").Preload("Channel.Groups.Cards").Where("account_id = ? AND channel_slot_id = ?", account.ID, channelID).First(&channelSlot).Error; err != nil {
if !errors.Is(err, gorm.ErrRecordNotFound) { if !errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusInternalServerError, err) ErrResponse(w, http.StatusInternalServerError, err)
} else { } else {
@ -38,7 +38,7 @@ func ClearChannelCard(w http.ResponseWriter, r *http.Request) {
// load referenced card // load referenced card
var cardSlot store.CardSlot var cardSlot store.CardSlot
if err := store.DB.Preload("Card.CardSlot").Where("account_id = ? AND card_slot_id = ?", account.ID, cardId).First(&cardSlot).Error; err != nil { if err := store.DB.Preload("Card.CardSlot").Where("account_id = ? AND card_slot_id = ?", account.ID, cardID).First(&cardSlot).Error; err != nil {
if !errors.Is(err, gorm.ErrRecordNotFound) { if !errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusInternalServerError, err) ErrResponse(w, http.StatusInternalServerError, err)
} else { } else {
@ -54,11 +54,11 @@ func ClearChannelCard(w http.ResponseWriter, r *http.Request) {
// determine contact list // determine contact list
cards := make(map[string]store.Card) cards := make(map[string]store.Card)
for _, card := range channelSlot.Channel.Cards { for _, card := range channelSlot.Channel.Cards {
cards[card.Guid] = card cards[card.GUID] = card
} }
for _, group := range channelSlot.Channel.Groups { for _, group := range channelSlot.Channel.Groups {
for _, card := range group.Cards { for _, card := range group.Cards {
cards[card.Guid] = card cards[card.GUID] = card
} }
} }

View File

@ -18,12 +18,12 @@ func ClearChannelGroup(w http.ResponseWriter, r *http.Request) {
// scan parameters // scan parameters
params := mux.Vars(r) params := mux.Vars(r)
channelId := params["channelId"] channelID := params["channelID"]
groupId := params["groupId"] groupID := params["groupID"]
// load referenced channel // load referenced channel
var channelSlot store.ChannelSlot var channelSlot store.ChannelSlot
if err := store.DB.Preload("Channel.Cards.CardSlot").Preload("Channel.Groups.GroupSlot").Preload("Channel.Groups.Cards").Where("account_id = ? AND channel_slot_id = ?", account.ID, channelId).First(&channelSlot).Error; err != nil { if err := store.DB.Preload("Channel.Cards.CardSlot").Preload("Channel.Groups.GroupSlot").Preload("Channel.Groups.Cards").Where("account_id = ? AND channel_slot_id = ?", account.ID, channelID).First(&channelSlot).Error; err != nil {
if !errors.Is(err, gorm.ErrRecordNotFound) { if !errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusInternalServerError, err) ErrResponse(w, http.StatusInternalServerError, err)
} else { } else {
@ -38,7 +38,7 @@ func ClearChannelGroup(w http.ResponseWriter, r *http.Request) {
// load referenced group // load referenced group
var groupSlot store.GroupSlot var groupSlot store.GroupSlot
if err := store.DB.Preload("Group.Cards").Preload("Group.GroupSlot").Where("account_id = ? AND group_slot_id = ?", account.ID, groupId).First(&groupSlot).Error; err != nil { if err := store.DB.Preload("Group.Cards").Preload("Group.GroupSlot").Where("account_id = ? AND group_slot_id = ?", account.ID, groupID).First(&groupSlot).Error; err != nil {
if !errors.Is(err, gorm.ErrRecordNotFound) { if !errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusInternalServerError, err) ErrResponse(w, http.StatusInternalServerError, err)
} else { } else {
@ -55,7 +55,7 @@ func ClearChannelGroup(w http.ResponseWriter, r *http.Request) {
cards := make(map[string]store.Card) cards := make(map[string]store.Card)
for _, group := range channelSlot.Channel.Groups { for _, group := range channelSlot.Channel.Groups {
for _, card := range group.Cards { for _, card := range group.Cards {
cards[card.Guid] = card cards[card.GUID] = card
} }
} }

View File

@ -16,7 +16,7 @@ func GetAccountListing(w http.ResponseWriter, r *http.Request) {
profiles := []CardProfile{} profiles := []CardProfile{}
for _, account := range accounts { for _, account := range accounts {
profiles = append(profiles, CardProfile{ profiles = append(profiles, CardProfile{
Guid: account.Guid, GUID: account.GUID,
Handle: account.Username, Handle: account.Username,
Name: account.AccountDetail.Name, Name: account.AccountDetail.Name,
Description: account.AccountDetail.Description, Description: account.AccountDetail.Description,

View File

@ -37,7 +37,7 @@ func GetAccountListingMessage(w http.ResponseWriter, r *http.Request) {
Node: getStrConfigValue(CONFIG_DOMAIN, ""), Node: getStrConfigValue(CONFIG_DOMAIN, ""),
} }
msg, res := WriteDataMessage(detail.PrivateKey, detail.PublicKey, detail.KeyType, msg, res := WriteDataMessage(detail.PrivateKey, detail.PublicKey, detail.KeyType,
APP_SIGNPKCS1V15, account.Guid, APP_MSGIDENTITY, &identity) APP_SIGNPKCS1V15, account.GUID, APP_MSGIDENTITY, &identity)
if res != nil { if res != nil {
ErrResponse(w, http.StatusInternalServerError, res) ErrResponse(w, http.StatusInternalServerError, res)
return return

View File

@ -17,7 +17,7 @@ func GetArticleSubjectField(w http.ResponseWriter, r *http.Request) {
// scan parameters // scan parameters
params := mux.Vars(r) params := mux.Vars(r)
articleId := params["articleId"] articleID := params["articleID"]
field := params["field"] field := params["field"]
elements := strings.Split(field, ".") elements := strings.Split(field, ".")
@ -38,7 +38,7 @@ func GetArticleSubjectField(w http.ResponseWriter, r *http.Request) {
return return
} }
act = &card.Account act = &card.Account
guid = card.Guid guid = card.GUID
} else { } else {
ErrResponse(w, http.StatusBadRequest, errors.New("unknown token type")) ErrResponse(w, http.StatusBadRequest, errors.New("unknown token type"))
return return
@ -46,7 +46,7 @@ func GetArticleSubjectField(w http.ResponseWriter, r *http.Request) {
// load article // load article
var slot store.ArticleSlot var slot store.ArticleSlot
if err := store.DB.Preload("Article.Groups.Cards").Where("account_id = ? AND article_slot_id = ?", act.ID, articleId).First(&slot).Error; err != nil { if err := store.DB.Preload("Article.Groups.Cards").Where("account_id = ? AND article_slot_id = ?", act.ID, articleID).First(&slot).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) { if errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusNotFound, err) ErrResponse(w, http.StatusNotFound, err)
} else { } else {

View File

@ -110,7 +110,7 @@ func GetArticles(w http.ResponseWriter, r *http.Request) {
for _, slot := range slots { for _, slot := range slots {
if !typesSet || hasArticleType(types, slot.Article) { if !typesSet || hasArticleType(types, slot.Article) {
shared := isArticleShared(card.Guid, slot.Article) shared := isArticleShared(card.GUID, slot.Article)
if articleRevisionSet { if articleRevisionSet {
response = append(response, getArticleModel(&slot, shared, false)) response = append(response, getArticleModel(&slot, shared, false))
} else if shared { } else if shared {
@ -136,7 +136,7 @@ func isArticleShared(guid string, article *store.Article) bool {
} }
for _, group := range article.Groups { for _, group := range article.Groups {
for _, card := range group.Cards { for _, card := range group.Cards {
if guid == card.Guid { if guid == card.GUID {
return true return true
} }
} }

View File

@ -15,10 +15,10 @@ func GetCard(w http.ResponseWriter, r *http.Request) {
ErrResponse(w, code, err) ErrResponse(w, code, err)
return return
} }
cardId := mux.Vars(r)["cardId"] cardID := mux.Vars(r)["cardID"]
var slot store.CardSlot var slot store.CardSlot
if err := store.DB.Preload("Card.Groups.GroupSlot").Where("account_id = ? AND card_slot_id = ?", account.ID, cardId).First(&slot).Error; err != nil { if err := store.DB.Preload("Card.Groups.GroupSlot").Where("account_id = ? AND card_slot_id = ?", account.ID, cardID).First(&slot).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) { if errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusNotFound, err) ErrResponse(w, http.StatusNotFound, err)
} else { } else {

View File

@ -15,10 +15,10 @@ func GetCardDetail(w http.ResponseWriter, r *http.Request) {
ErrResponse(w, code, err) ErrResponse(w, code, err)
return return
} }
cardId := mux.Vars(r)["cardId"] cardID := mux.Vars(r)["cardID"]
var slot store.CardSlot var slot store.CardSlot
if err := store.DB.Preload("Card.Groups").Where("account_id = ? AND card_slot_id = ?", account.ID, cardId).First(&slot).Error; err != nil { if err := store.DB.Preload("Card.Groups").Where("account_id = ? AND card_slot_id = ?", account.ID, cardID).First(&slot).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) { if errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusNotFound, err) ErrResponse(w, http.StatusNotFound, err)
} else { } else {

View File

@ -19,10 +19,10 @@ func GetCardProfileImage(w http.ResponseWriter, r *http.Request) {
ErrResponse(w, code, err) ErrResponse(w, code, err)
return return
} }
cardId := mux.Vars(r)["cardId"] cardID := mux.Vars(r)["cardID"]
var slot store.CardSlot var slot store.CardSlot
if err := store.DB.Preload("Card.Groups").Where("account_id = ? AND card_slot_id = ?", account.ID, cardId).First(&slot).Error; err != nil { if err := store.DB.Preload("Card.Groups").Where("account_id = ? AND card_slot_id = ?", account.ID, cardID).First(&slot).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) { if errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusNotFound, err) ErrResponse(w, http.StatusNotFound, err)
} else { } else {

View File

@ -15,10 +15,10 @@ func GetCardProfile(w http.ResponseWriter, r *http.Request) {
ErrResponse(w, code, err) ErrResponse(w, code, err)
return return
} }
cardId := mux.Vars(r)["cardId"] cardID := mux.Vars(r)["cardID"]
var slot store.CardSlot var slot store.CardSlot
if err := store.DB.Preload("Card.Groups").Where("account_id = ? AND card_slot_id = ?", account.ID, cardId).First(&slot).Error; err != nil { if err := store.DB.Preload("Card.Groups").Where("account_id = ? AND card_slot_id = ?", account.ID, cardID).First(&slot).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) { if errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusNotFound, err) ErrResponse(w, http.StatusNotFound, err)
} else { } else {

View File

@ -12,7 +12,7 @@ func GetChannelDetail(w http.ResponseWriter, r *http.Request) {
// scan parameters // scan parameters
params := mux.Vars(r) params := mux.Vars(r)
channelId := params["channelId"] channelID := params["channelID"]
var guid string var guid string
var act *store.Account var act *store.Account
@ -31,7 +31,7 @@ func GetChannelDetail(w http.ResponseWriter, r *http.Request) {
return return
} }
act = &card.Account act = &card.Account
guid = card.Guid guid = card.GUID
} else { } else {
ErrResponse(w, http.StatusBadRequest, errors.New("unknown token type")) ErrResponse(w, http.StatusBadRequest, errors.New("unknown token type"))
return return
@ -39,7 +39,7 @@ func GetChannelDetail(w http.ResponseWriter, r *http.Request) {
// load channel // load channel
var slot store.ChannelSlot var slot store.ChannelSlot
if err := store.DB.Preload("Channel.Cards.CardSlot").Preload("Channel.Groups.Cards").Preload("Channel.Groups.GroupSlot").Where("account_id = ? AND channel_slot_id = ?", act.ID, channelId).First(&slot).Error; err != nil { if err := store.DB.Preload("Channel.Cards.CardSlot").Preload("Channel.Groups.Cards").Preload("Channel.Groups.GroupSlot").Where("account_id = ? AND channel_slot_id = ?", act.ID, channelID).First(&slot).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) { if errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusNotFound, err) ErrResponse(w, http.StatusNotFound, err)
} else { } else {

View File

@ -12,7 +12,7 @@ func GetChannelSummary(w http.ResponseWriter, r *http.Request) {
// scan parameters // scan parameters
params := mux.Vars(r) params := mux.Vars(r)
channelId := params["channelId"] channelID := params["channelID"]
var guid string var guid string
var act *store.Account var act *store.Account
@ -31,7 +31,7 @@ func GetChannelSummary(w http.ResponseWriter, r *http.Request) {
return return
} }
act = &card.Account act = &card.Account
guid = card.Guid guid = card.GUID
} else { } else {
ErrResponse(w, http.StatusBadRequest, errors.New("unknown token type")) ErrResponse(w, http.StatusBadRequest, errors.New("unknown token type"))
return return
@ -41,7 +41,7 @@ func GetChannelSummary(w http.ResponseWriter, r *http.Request) {
var slot store.ChannelSlot var slot store.ChannelSlot
if err := store.DB.Preload("Channel.Topics", func(db *gorm.DB) *gorm.DB { if err := store.DB.Preload("Channel.Topics", func(db *gorm.DB) *gorm.DB {
return store.DB.Order("topics.id DESC").Limit(1) return store.DB.Order("topics.id DESC").Limit(1)
}).Preload("Channel.Cards.CardSlot").Preload("Channel.Groups.Cards").Preload("Channel.Groups.GroupSlot").Where("account_id = ? AND channel_slot_id = ?", act.ID, channelId).First(&slot).Error; err != nil { }).Preload("Channel.Cards.CardSlot").Preload("Channel.Groups.Cards").Preload("Channel.Groups.GroupSlot").Where("account_id = ? AND channel_slot_id = ?", act.ID, channelID).First(&slot).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) { if errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusNotFound, err) ErrResponse(w, http.StatusNotFound, err)
} else { } else {

View File

@ -12,7 +12,7 @@ func GetChannelTopic(w http.ResponseWriter, r *http.Request) {
// scan parameters // scan parameters
params := mux.Vars(r) params := mux.Vars(r)
topicId := params["topicId"] topicID := params["topicID"]
channelSlot, _, err, code := getChannelSlot(r, false) channelSlot, _, err, code := getChannelSlot(r, false)
if err != nil { if err != nil {
@ -22,7 +22,7 @@ func GetChannelTopic(w http.ResponseWriter, r *http.Request) {
// load topic // load topic
var topicSlot store.TopicSlot var topicSlot store.TopicSlot
if err = store.DB.Preload("Topic.Assets").Where("channel_id = ? AND topic_slot_id = ?", channelSlot.Channel.ID, topicId).First(&topicSlot).Error; err != nil { if err = store.DB.Preload("Topic.Assets").Where("channel_id = ? AND topic_slot_id = ?", channelSlot.Channel.ID, topicID).First(&topicSlot).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) { if errors.Is(err, gorm.ErrRecordNotFound) {
code = http.StatusNotFound code = http.StatusNotFound
} else { } else {
@ -36,7 +36,7 @@ func GetChannelTopic(w http.ResponseWriter, r *http.Request) {
func isMember(guid string, cards []store.Card) bool { func isMember(guid string, cards []store.Card) bool {
for _, card := range cards { for _, card := range cards {
if guid == card.Guid { if guid == card.GUID {
return true return true
} }
} }
@ -46,7 +46,7 @@ func isMember(guid string, cards []store.Card) bool {
func isViewer(guid string, groups []store.Group) bool { func isViewer(guid string, groups []store.Group) bool {
for _, group := range groups { for _, group := range groups {
for _, card := range group.Cards { for _, card := range group.Cards {
if guid == card.Guid { if guid == card.GUID {
return true return true
} }
} }
@ -58,7 +58,7 @@ func getChannelSlot(r *http.Request, member bool) (slot store.ChannelSlot, guid
// scan parameters // scan parameters
params := mux.Vars(r) params := mux.Vars(r)
channelId := params["channelId"] channelID := params["channelID"]
// validate contact access // validate contact access
var account *store.Account var account *store.Account
@ -68,7 +68,7 @@ func getChannelSlot(r *http.Request, member bool) (slot store.ChannelSlot, guid
if err != nil { if err != nil {
return return
} }
guid = account.Guid guid = account.GUID
} else if tokenType == APP_TOKENCONTACT { } else if tokenType == APP_TOKENCONTACT {
var card *store.Card var card *store.Card
card, code, err = ParamContactToken(r, true) card, code, err = ParamContactToken(r, true)
@ -76,7 +76,7 @@ func getChannelSlot(r *http.Request, member bool) (slot store.ChannelSlot, guid
return return
} }
account = &card.Account account = &card.Account
guid = card.Guid guid = card.GUID
} else { } else {
err = errors.New("unknown token type") err = errors.New("unknown token type")
code = http.StatusBadRequest code = http.StatusBadRequest
@ -84,7 +84,7 @@ func getChannelSlot(r *http.Request, member bool) (slot store.ChannelSlot, guid
} }
// load channel // load channel
if err = store.DB.Preload("Account").Preload("Channel.Cards").Preload("Channel.Groups.Cards").Where("account_id = ? AND channel_slot_id = ?", account.ID, channelId).First(&slot).Error; err != nil { if err = store.DB.Preload("Account").Preload("Channel.Cards").Preload("Channel.Groups.Cards").Where("account_id = ? AND channel_slot_id = ?", account.ID, channelID).First(&slot).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) { if errors.Is(err, gorm.ErrRecordNotFound) {
code = http.StatusNotFound code = http.StatusNotFound
} else { } else {

View File

@ -12,8 +12,8 @@ func GetChannelTopicAsset(w http.ResponseWriter, r *http.Request) {
// scan parameters // scan parameters
params := mux.Vars(r) params := mux.Vars(r)
topicId := params["topicId"] topicID := params["topicID"]
assetId := params["assetId"] assetID := params["assetID"]
channelSlot, _, err, code := getChannelSlot(r, true) channelSlot, _, err, code := getChannelSlot(r, true)
if err != nil { if err != nil {
@ -24,7 +24,7 @@ func GetChannelTopicAsset(w http.ResponseWriter, r *http.Request) {
// load asset // load asset
var asset store.Asset var asset store.Asset
if err = store.DB.Preload("Topic.TopicSlot").Where("channel_id = ? AND asset_id = ?", channelSlot.Channel.ID, assetId).First(&asset).Error; err != nil { if err = store.DB.Preload("Topic.TopicSlot").Where("channel_id = ? AND asset_id = ?", channelSlot.Channel.ID, assetID).First(&asset).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) { if errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusNotFound, err) ErrResponse(w, http.StatusNotFound, err)
} else { } else {
@ -32,7 +32,7 @@ func GetChannelTopicAsset(w http.ResponseWriter, r *http.Request) {
} }
return return
} }
if asset.Topic.TopicSlot.TopicSlotId != topicId { if asset.Topic.TopicSlot.TopicSlotID != topicID {
ErrResponse(w, http.StatusNotFound, errors.New("invalid topic asset")) ErrResponse(w, http.StatusNotFound, errors.New("invalid topic asset"))
return return
} }
@ -42,7 +42,7 @@ func GetChannelTopicAsset(w http.ResponseWriter, r *http.Request) {
} }
// construct file path // construct file path
path := getStrConfigValue(CONFIG_ASSETPATH, APP_DEFAULTPATH) + "/" + act.Guid + "/" + asset.AssetId path := getStrConfigValue(CONFIG_ASSETPATH, APP_DEFAULTPATH) + "/" + act.GUID + "/" + asset.AssetID
http.ServeFile(w, r, path) http.ServeFile(w, r, path)
} }

View File

@ -12,7 +12,7 @@ func GetChannelTopicAssets(w http.ResponseWriter, r *http.Request) {
// scan parameters // scan parameters
params := mux.Vars(r) params := mux.Vars(r)
topicId := params["topicId"] topicID := params["topicID"]
channelSlot, guid, err, code := getChannelSlot(r, true) channelSlot, guid, err, code := getChannelSlot(r, true)
if err != nil { if err != nil {
@ -22,7 +22,7 @@ func GetChannelTopicAssets(w http.ResponseWriter, r *http.Request) {
// load topic // load topic
var topicSlot store.TopicSlot var topicSlot store.TopicSlot
if err = store.DB.Preload("Topic.Assets").Where("channel_id = ? AND topic_slot_id = ?", channelSlot.Channel.ID, topicId).First(&topicSlot).Error; err != nil { if err = store.DB.Preload("Topic.Assets").Where("channel_id = ? AND topic_slot_id = ?", channelSlot.Channel.ID, topicID).First(&topicSlot).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) { if errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusNotFound, err) ErrResponse(w, http.StatusNotFound, err)
} else { } else {
@ -36,7 +36,7 @@ func GetChannelTopicAssets(w http.ResponseWriter, r *http.Request) {
} }
// only creator can list assets // only creator can list assets
if topicSlot.Topic.Guid != guid { if topicSlot.Topic.GUID != guid {
ErrResponse(w, http.StatusUnauthorized, errors.New("permission denied to asset list")) ErrResponse(w, http.StatusUnauthorized, errors.New("permission denied to asset list"))
return return
} }
@ -44,7 +44,7 @@ func GetChannelTopicAssets(w http.ResponseWriter, r *http.Request) {
// return list of assets // return list of assets
assets := []Asset{} assets := []Asset{}
for _, asset := range topicSlot.Topic.Assets { for _, asset := range topicSlot.Topic.Assets {
assets = append(assets, Asset{ AssetId: asset.AssetId, Status: asset.Status }) assets = append(assets, Asset{ AssetID: asset.AssetID, Status: asset.Status })
} }
WriteResponse(w, &assets) WriteResponse(w, &assets)
} }

View File

@ -12,7 +12,7 @@ func GetChannelTopicDetail(w http.ResponseWriter, r *http.Request) {
// scan parameters // scan parameters
params := mux.Vars(r) params := mux.Vars(r)
topicId := params["topicId"] topicID := params["topicID"]
var subject Subject var subject Subject
if err := ParseRequest(r, w, &subject); err != nil { if err := ParseRequest(r, w, &subject); err != nil {
@ -28,7 +28,7 @@ func GetChannelTopicDetail(w http.ResponseWriter, r *http.Request) {
// load topic // load topic
var topicSlot store.TopicSlot var topicSlot store.TopicSlot
if err = store.DB.Where("channel_id = ? AND topic_slot_id = ?", channelSlot.Channel.ID, topicId).First(&topicSlot).Error; err != nil { if err = store.DB.Where("channel_id = ? AND topic_slot_id = ?", channelSlot.Channel.ID, topicID).First(&topicSlot).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) { if errors.Is(err, gorm.ErrRecordNotFound) {
code = http.StatusNotFound code = http.StatusNotFound
} else { } else {

View File

@ -17,7 +17,7 @@ func GetChannelTopicSubjectField(w http.ResponseWriter, r *http.Request) {
// scan parameters // scan parameters
params := mux.Vars(r) params := mux.Vars(r)
topicId := params["topicId"] topicID := params["topicID"]
field := params["field"] field := params["field"]
elements := strings.Split(field, ".") elements := strings.Split(field, ".")
@ -29,7 +29,7 @@ func GetChannelTopicSubjectField(w http.ResponseWriter, r *http.Request) {
// load topic // load topic
var topicSlot store.TopicSlot var topicSlot store.TopicSlot
if err = store.DB.Where("channel_id = ? AND topic_slot_id = ?", channelSlot.Channel.ID, topicId).First(&topicSlot).Error; err != nil { if err = store.DB.Where("channel_id = ? AND topic_slot_id = ?", channelSlot.Channel.ID, topicID).First(&topicSlot).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) { if errors.Is(err, gorm.ErrRecordNotFound) {
code = http.StatusNotFound code = http.StatusNotFound
} else { } else {

View File

@ -17,8 +17,8 @@ func GetChannelTopicTagSubjectField(w http.ResponseWriter, r *http.Request) {
// scan parameters // scan parameters
params := mux.Vars(r) params := mux.Vars(r)
topicId := params["topicId"] topicID := params["topicID"]
tagId := params["tagId"] tagID := params["tagID"]
field := params["field"] field := params["field"]
elements := strings.Split(field, ".") elements := strings.Split(field, ".")
@ -30,7 +30,7 @@ func GetChannelTopicTagSubjectField(w http.ResponseWriter, r *http.Request) {
// load tag // load tag
var tagSlot store.TagSlot var tagSlot store.TagSlot
if err = store.DB.Preload("Tag.Topic.TopicSlot").Where("channel_id = ? AND tag_slot_id = ?", channelSlot.Channel.ID, tagId).First(&tagSlot).Error; err != nil { if err = store.DB.Preload("Tag.Topic.TopicSlot").Where("channel_id = ? AND tag_slot_id = ?", channelSlot.Channel.ID, tagID).First(&tagSlot).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) { if errors.Is(err, gorm.ErrRecordNotFound) {
code = http.StatusNotFound code = http.StatusNotFound
} else { } else {
@ -42,7 +42,7 @@ func GetChannelTopicTagSubjectField(w http.ResponseWriter, r *http.Request) {
ErrResponse(w, http.StatusNotFound, errors.New("referenced missing tag")) ErrResponse(w, http.StatusNotFound, errors.New("referenced missing tag"))
return return
} }
if tagSlot.Tag.Topic.TopicSlot.TopicSlotId != topicId { if tagSlot.Tag.Topic.TopicSlot.TopicSlotID != topicID {
ErrResponse(w, http.StatusNotFound, errors.New("invalid topic tag")) ErrResponse(w, http.StatusNotFound, errors.New("invalid topic tag"))
return return
} }

View File

@ -36,7 +36,7 @@ func GetChannelTopicTags(w http.ResponseWriter, r *http.Request) {
// scan parameters // scan parameters
params := mux.Vars(r) params := mux.Vars(r)
topicId := params["topicId"] topicID := params["topicID"]
rev := r.FormValue("revision") rev := r.FormValue("revision")
if rev != "" { if rev != "" {
@ -76,7 +76,7 @@ func GetChannelTopicTags(w http.ResponseWriter, r *http.Request) {
// load topic // load topic
var topicSlot store.TopicSlot var topicSlot store.TopicSlot
if err = store.DB.Preload("Topic").Where("channel_id = ? AND topic_slot_id = ?", channelSlot.Channel.ID, topicId).First(&topicSlot).Error; err != nil { if err = store.DB.Preload("Topic").Where("channel_id = ? AND topic_slot_id = ?", channelSlot.Channel.ID, topicID).First(&topicSlot).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) { if errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusNotFound, err) ErrResponse(w, http.StatusNotFound, err)
} else { } else {

View File

@ -119,7 +119,7 @@ func GetChannels(w http.ResponseWriter, r *http.Request) {
for _, slot := range slots { for _, slot := range slots {
if !typesSet || hasChannelType(types, slot.Channel) { if !typesSet || hasChannelType(types, slot.Channel) {
shared := isChannelShared(card.Guid, slot.Channel) shared := isChannelShared(card.GUID, slot.Channel)
if channelRevisionSet { if channelRevisionSet {
response = append(response, getChannelRevisionModel(&slot, shared)) response = append(response, getChannelRevisionModel(&slot, shared))
} else if shared { } else if shared {
@ -144,13 +144,13 @@ func isChannelShared(guid string, channel *store.Channel) bool {
return false return false
} }
for _, card := range channel.Cards { for _, card := range channel.Cards {
if guid == card.Guid { if guid == card.GUID {
return true return true
} }
} }
for _, group := range channel.Groups { for _, group := range channel.Groups {
for _, card := range group.Cards { for _, card := range group.Cards {
if guid == card.Guid { if guid == card.GUID {
return true return true
} }
} }

View File

@ -16,10 +16,10 @@ func GetCloseMessage(w http.ResponseWriter, r *http.Request) {
return return
} }
detail := account.AccountDetail detail := account.AccountDetail
cardId := mux.Vars(r)["cardId"] cardID := mux.Vars(r)["cardID"]
var slot store.CardSlot var slot store.CardSlot
if err := store.DB.Preload("Card").Where("account_id = ? AND card_slot_id = ?", account.ID, cardId).First(&slot).Error; err != nil { if err := store.DB.Preload("Card").Where("account_id = ? AND card_slot_id = ?", account.ID, cardID).First(&slot).Error; err != nil {
if !errors.Is(err, gorm.ErrRecordNotFound) { if !errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusInternalServerError, err) ErrResponse(w, http.StatusInternalServerError, err)
} else { } else {
@ -38,11 +38,11 @@ func GetCloseMessage(w http.ResponseWriter, r *http.Request) {
} }
disconnect := &Disconnect{ disconnect := &Disconnect{
Contact: slot.Card.Guid, Contact: slot.Card.GUID,
} }
msg, err := WriteDataMessage(detail.PrivateKey, detail.PublicKey, detail.KeyType, msg, err := WriteDataMessage(detail.PrivateKey, detail.PublicKey, detail.KeyType,
APP_SIGNPKCS1V15, account.Guid, APP_MSGDISCONNECT, &disconnect) APP_SIGNPKCS1V15, account.GUID, APP_MSGDISCONNECT, &disconnect)
if err != nil { if err != nil {
ErrResponse(w, http.StatusInternalServerError, err) ErrResponse(w, http.StatusInternalServerError, err)
return return

View File

@ -17,7 +17,7 @@ func GetGroupSubjectField(w http.ResponseWriter, r *http.Request) {
// scan parameters // scan parameters
params := mux.Vars(r) params := mux.Vars(r)
groupId := params["groupId"] groupID := params["groupID"]
field := params["field"] field := params["field"]
elements := strings.Split(field, ".") elements := strings.Split(field, ".")
@ -29,7 +29,7 @@ func GetGroupSubjectField(w http.ResponseWriter, r *http.Request) {
// load group // load group
var slot store.GroupSlot var slot store.GroupSlot
if err := store.DB.Preload("Group.GroupData").Where("account_id = ? AND group_slot_id = ?", account.ID, groupId).First(&slot).Error; err != nil { if err := store.DB.Preload("Group.GroupData").Where("account_id = ? AND group_slot_id = ?", account.ID, groupID).First(&slot).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) { if errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusNotFound, err) ErrResponse(w, http.StatusNotFound, err)
} else { } else {

View File

@ -16,7 +16,7 @@ func GetNodeAccountImage(w http.ResponseWriter, r *http.Request) {
// get referenced account id // get referenced account id
params := mux.Vars(r) params := mux.Vars(r)
accountId, res := strconv.ParseUint(params["accountId"], 10, 32) accountID, res := strconv.ParseUint(params["accountID"], 10, 32)
if res != nil { if res != nil {
ErrResponse(w, http.StatusBadRequest, res) ErrResponse(w, http.StatusBadRequest, res)
return return
@ -28,7 +28,7 @@ func GetNodeAccountImage(w http.ResponseWriter, r *http.Request) {
} }
var account store.Account var account store.Account
if err := store.DB.Preload("AccountDetail").First(&account, uint(accountId)).Error; err != nil { if err := store.DB.Preload("AccountDetail").First(&account, uint(accountID)).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) { if errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusNotFound, err) ErrResponse(w, http.StatusNotFound, err)
} else { } else {

View File

@ -21,8 +21,8 @@ func GetNodeAccounts(w http.ResponseWriter, r *http.Request) {
profiles := []AccountProfile{} profiles := []AccountProfile{}
for _, account := range accounts { for _, account := range accounts {
profiles = append(profiles, AccountProfile{ profiles = append(profiles, AccountProfile{
AccountId: uint32(account.ID), AccountID: uint32(account.ID),
Guid: account.Guid, GUID: account.GUID,
Handle: account.Username, Handle: account.Username,
Name: account.AccountDetail.Name, Name: account.AccountDetail.Name,
Description: account.AccountDetail.Description, Description: account.AccountDetail.Description,

View File

@ -16,10 +16,10 @@ func GetOpenMessage(w http.ResponseWriter, r *http.Request) {
return return
} }
detail := account.AccountDetail detail := account.AccountDetail
cardId := mux.Vars(r)["cardId"] cardID := mux.Vars(r)["cardID"]
var slot store.CardSlot var slot store.CardSlot
if err := store.DB.Preload("Card").Where("account_id = ? AND card_slot_id = ?", account.ID, cardId).First(&slot).Error; err != nil { if err := store.DB.Preload("Card").Where("account_id = ? AND card_slot_id = ?", account.ID, cardID).First(&slot).Error; err != nil {
if !errors.Is(err, gorm.ErrRecordNotFound) { if !errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusInternalServerError, err) ErrResponse(w, http.StatusInternalServerError, err)
} else { } else {
@ -38,7 +38,7 @@ func GetOpenMessage(w http.ResponseWriter, r *http.Request) {
} }
connect := &Connect{ connect := &Connect{
Contact: slot.Card.Guid, Contact: slot.Card.GUID,
Token: slot.Card.InToken, Token: slot.Card.InToken,
ArticleRevision: account.ArticleRevision, ArticleRevision: account.ArticleRevision,
ProfileRevision: account.ProfileRevision, ProfileRevision: account.ProfileRevision,
@ -54,7 +54,7 @@ func GetOpenMessage(w http.ResponseWriter, r *http.Request) {
} }
msg, err := WriteDataMessage(detail.PrivateKey, detail.PublicKey, detail.KeyType, msg, err := WriteDataMessage(detail.PrivateKey, detail.PublicKey, detail.KeyType,
APP_SIGNPKCS1V15, account.Guid, APP_MSGCONNECT, &connect) APP_SIGNPKCS1V15, account.GUID, APP_MSGCONNECT, &connect)
if err != nil { if err != nil {
ErrResponse(w, http.StatusInternalServerError, err) ErrResponse(w, http.StatusInternalServerError, err)
return return

View File

@ -43,7 +43,7 @@ func GetProfileMessage(w http.ResponseWriter, r *http.Request) {
Node: getStrConfigValue(CONFIG_DOMAIN, ""), Node: getStrConfigValue(CONFIG_DOMAIN, ""),
} }
msg, res := WriteDataMessage(detail.PrivateKey, detail.PublicKey, detail.KeyType, msg, res := WriteDataMessage(detail.PrivateKey, detail.PublicKey, detail.KeyType,
APP_SIGNPKCS1V15, account.Guid, APP_MSGIDENTITY, &identity) APP_SIGNPKCS1V15, account.GUID, APP_MSGIDENTITY, &identity)
if res != nil { if res != nil {
ErrResponse(w, http.StatusInternalServerError, res) ErrResponse(w, http.StatusInternalServerError, res)
return return

View File

@ -78,7 +78,7 @@ func RemoveAccount(w http.ResponseWriter, r *http.Request) {
} }
// delete asset files // delete asset files
path := getStrConfigValue(CONFIG_ASSETPATH, APP_DEFAULTPATH) + "/" + account.Guid path := getStrConfigValue(CONFIG_ASSETPATH, APP_DEFAULTPATH) + "/" + account.GUID
if err = os.RemoveAll(path); err != nil { if err = os.RemoveAll(path); err != nil {
ErrMsg(err) ErrMsg(err)
} }

View File

@ -18,11 +18,11 @@ func RemoveArticle(w http.ResponseWriter, r *http.Request) {
// scan parameters // scan parameters
params := mux.Vars(r) params := mux.Vars(r)
articleId := params["articleId"] articleID := params["articleID"]
// load referenced article // load referenced article
var slot store.ArticleSlot var slot store.ArticleSlot
if err := store.DB.Preload("Article.Groups.Cards").Where("account_id = ? AND article_slot_id = ?", account.ID, articleId).First(&slot).Error; err != nil { if err := store.DB.Preload("Article.Groups.Cards").Where("account_id = ? AND article_slot_id = ?", account.ID, articleID).First(&slot).Error; err != nil {
if !errors.Is(err, gorm.ErrRecordNotFound) { if !errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusInternalServerError, err) ErrResponse(w, http.StatusInternalServerError, err)
} else { } else {
@ -39,7 +39,7 @@ func RemoveArticle(w http.ResponseWriter, r *http.Request) {
cards := make(map[string]*store.Card) cards := make(map[string]*store.Card)
for _, group := range slot.Article.Groups { for _, group := range slot.Article.Groups {
for _, card := range group.Cards { for _, card := range group.Cards {
cards[card.Guid] = &card cards[card.GUID] = &card
} }
} }

View File

@ -18,11 +18,11 @@ func RemoveCard(w http.ResponseWriter, r *http.Request) {
// scan parameters // scan parameters
params := mux.Vars(r) params := mux.Vars(r)
cardId := params["cardId"] cardID := params["cardID"]
// load referenced card // load referenced card
var slot store.CardSlot var slot store.CardSlot
if err := store.DB.Preload("Card.Groups").Preload("Card.Channels.Cards").Preload("Card.Channels.ChannelSlot").Where("account_id = ? AND card_slot_id = ?", account.ID, cardId).First(&slot).Error; err != nil { if err := store.DB.Preload("Card.Groups").Preload("Card.Channels.Cards").Preload("Card.Channels.ChannelSlot").Where("account_id = ? AND card_slot_id = ?", account.ID, cardID).First(&slot).Error; err != nil {
if !errors.Is(err, gorm.ErrRecordNotFound) { if !errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusInternalServerError, err) ErrResponse(w, http.StatusInternalServerError, err)
} else { } else {
@ -48,7 +48,7 @@ func RemoveCard(w http.ResponseWriter, r *http.Request) {
return res return res
} }
for _, card := range channel.Cards { for _, card := range channel.Cards {
cards[card.Guid] = &card cards[card.GUID] = &card
} }
} }
if res := tx.Model(&slot.Card).Association("Groups").Clear(); res != nil { if res := tx.Model(&slot.Card).Association("Groups").Clear(); res != nil {

View File

@ -14,7 +14,7 @@ func RemoveChannel(w http.ResponseWriter, r *http.Request) {
// scan parameters // scan parameters
params := mux.Vars(r) params := mux.Vars(r)
channelId := params["channelId"] channelID := params["channelID"]
// validate contact access // validate contact access
var account *store.Account var account *store.Account
@ -41,7 +41,7 @@ func RemoveChannel(w http.ResponseWriter, r *http.Request) {
// load channel // load channel
var slot store.ChannelSlot var slot store.ChannelSlot
if err = store.DB.Preload("Channel.Cards").Preload("Channel.Groups.Cards").Where("account_id = ? AND channel_slot_id = ?", account.ID, channelId).First(&slot).Error; err != nil { if err = store.DB.Preload("Channel.Cards").Preload("Channel.Groups.Cards").Where("account_id = ? AND channel_slot_id = ?", account.ID, channelID).First(&slot).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) { if errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusNotFound, err) ErrResponse(w, http.StatusNotFound, err)
} else { } else {
@ -57,11 +57,11 @@ func RemoveChannel(w http.ResponseWriter, r *http.Request) {
// determine affected contact list // determine affected contact list
cards := make(map[string]store.Card) cards := make(map[string]store.Card)
for _, card := range slot.Channel.Cards { for _, card := range slot.Channel.Cards {
cards[card.Guid] = card cards[card.GUID] = card
} }
for _, group := range slot.Channel.Groups { for _, group := range slot.Channel.Groups {
for _, card := range group.Cards { for _, card := range group.Cards {
cards[card.Guid] = card cards[card.GUID] = card
} }
} }
@ -114,7 +114,7 @@ func RemoveChannel(w http.ResponseWriter, r *http.Request) {
// cleanup file assets // cleanup file assets
go garbageCollect(account) go garbageCollect(account)
} else { } else {
if _, member := cards[contact.Guid]; !member { if _, member := cards[contact.GUID]; !member {
ErrResponse(w, http.StatusNotFound, errors.New("member channel not found")); ErrResponse(w, http.StatusNotFound, errors.New("member channel not found"));
return return
} }

View File

@ -12,8 +12,8 @@ func RemoveChannelTopic(w http.ResponseWriter, r *http.Request) {
// scan parameters // scan parameters
params := mux.Vars(r) params := mux.Vars(r)
channelId := params["channelId"] channelID := params["channelID"]
topicId := params["topicId"] topicID := params["topicID"]
channelSlot, guid, err, code := getChannelSlot(r, true) channelSlot, guid, err, code := getChannelSlot(r, true)
if err != nil { if err != nil {
@ -24,7 +24,7 @@ func RemoveChannelTopic(w http.ResponseWriter, r *http.Request) {
// load topic // load topic
var topicSlot store.TopicSlot var topicSlot store.TopicSlot
if ret := store.DB.Preload("Topic.Channel.ChannelSlot").Where("account_id = ? AND topic_slot_id = ?", act.ID, topicId).First(&topicSlot).Error; ret != nil { if ret := store.DB.Preload("Topic.Channel.ChannelSlot").Where("account_id = ? AND topic_slot_id = ?", act.ID, topicID).First(&topicSlot).Error; ret != nil {
if errors.Is(err, gorm.ErrRecordNotFound) { if errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusNotFound, ret) ErrResponse(w, http.StatusNotFound, ret)
} else { } else {
@ -35,13 +35,13 @@ func RemoveChannelTopic(w http.ResponseWriter, r *http.Request) {
ErrResponse(w, http.StatusNotFound, errors.New("referenced empty topic")) ErrResponse(w, http.StatusNotFound, errors.New("referenced empty topic"))
return return
} }
if topicSlot.Topic.Channel.ChannelSlot.ChannelSlotId != channelId { if topicSlot.Topic.Channel.ChannelSlot.ChannelSlotID != channelID {
ErrResponse(w, http.StatusNotFound, errors.New("channel topic not found")) ErrResponse(w, http.StatusNotFound, errors.New("channel topic not found"))
return return
} }
// check permission // check permission
if act.Guid != guid && topicSlot.Topic.Guid != guid { if act.GUID != guid && topicSlot.Topic.GUID != guid {
ErrResponse(w, http.StatusUnauthorized, errors.New("not creator of topic or host")) ErrResponse(w, http.StatusUnauthorized, errors.New("not creator of topic or host"))
return return
} }
@ -86,11 +86,11 @@ func RemoveChannelTopic(w http.ResponseWriter, r *http.Request) {
// determine affected contact list // determine affected contact list
cards := make(map[string]store.Card) cards := make(map[string]store.Card)
for _, card := range channelSlot.Channel.Cards { for _, card := range channelSlot.Channel.Cards {
cards[card.Guid] = card cards[card.GUID] = card
} }
for _, group := range channelSlot.Channel.Groups { for _, group := range channelSlot.Channel.Groups {
for _, card := range group.Cards { for _, card := range group.Cards {
cards[card.Guid] = card cards[card.GUID] = card
} }
} }

View File

@ -12,8 +12,8 @@ func RemoveChannelTopicAsset(w http.ResponseWriter, r *http.Request) {
// scan parameters // scan parameters
params := mux.Vars(r) params := mux.Vars(r)
topicId := params["topicId"] topicID := params["topicID"]
assetId := params["assetId"] assetID := params["assetID"]
channelSlot, guid, err, code := getChannelSlot(r, true) channelSlot, guid, err, code := getChannelSlot(r, true)
if err != nil { if err != nil {
@ -24,7 +24,7 @@ func RemoveChannelTopicAsset(w http.ResponseWriter, r *http.Request) {
// load asset // load asset
var asset store.Asset var asset store.Asset
if err = store.DB.Preload("Topic.TopicSlot").Where("channel_id = ? AND asset_id = ?", channelSlot.Channel.ID, assetId).First(&asset).Error; err != nil { if err = store.DB.Preload("Topic.TopicSlot").Where("channel_id = ? AND asset_id = ?", channelSlot.Channel.ID, assetID).First(&asset).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) { if errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusNotFound, err) ErrResponse(w, http.StatusNotFound, err)
} else { } else {
@ -32,13 +32,13 @@ func RemoveChannelTopicAsset(w http.ResponseWriter, r *http.Request) {
} }
return return
} }
if asset.Topic.TopicSlot.TopicSlotId != topicId { if asset.Topic.TopicSlot.TopicSlotID != topicID {
ErrResponse(w, http.StatusNotFound, errors.New("invalid topic")) ErrResponse(w, http.StatusNotFound, errors.New("invalid topic"))
return return
} }
// can only update topic if creator // can only update topic if creator
if asset.Topic.Guid != guid { if asset.Topic.GUID != guid {
ErrResponse(w, http.StatusUnauthorized, errors.New("topic not created by you")) ErrResponse(w, http.StatusUnauthorized, errors.New("topic not created by you"))
return return
} }
@ -76,11 +76,11 @@ func RemoveChannelTopicAsset(w http.ResponseWriter, r *http.Request) {
// determine affected contact list // determine affected contact list
cards := make(map[string]store.Card) cards := make(map[string]store.Card)
for _, card := range channelSlot.Channel.Cards { for _, card := range channelSlot.Channel.Cards {
cards[card.Guid] = card cards[card.GUID] = card
} }
for _, group := range channelSlot.Channel.Groups { for _, group := range channelSlot.Channel.Groups {
for _, card := range group.Cards { for _, card := range group.Cards {
cards[card.Guid] = card cards[card.GUID] = card
} }
} }

View File

@ -12,9 +12,9 @@ func RemoveChannelTopicTag(w http.ResponseWriter, r *http.Request) {
// scan parameters // scan parameters
params := mux.Vars(r) params := mux.Vars(r)
channelId := params["channelId"] channelID := params["channelID"]
topicId := params["topicId"] topicID := params["topicID"]
tagId := params["tagId"] tagID := params["tagID"]
channelSlot, guid, err, code := getChannelSlot(r, false) channelSlot, guid, err, code := getChannelSlot(r, false)
if err != nil { if err != nil {
@ -25,7 +25,7 @@ func RemoveChannelTopicTag(w http.ResponseWriter, r *http.Request) {
// load topic // load topic
var topicSlot store.TopicSlot var topicSlot store.TopicSlot
if ret := store.DB.Preload("Topic.Tags.TagSlot").Preload("Topic.Channel.ChannelSlot").Where("account_id = ? AND topic_slot_id = ?", act.ID, topicId).First(&topicSlot).Error; ret != nil { if ret := store.DB.Preload("Topic.Tags.TagSlot").Preload("Topic.Channel.ChannelSlot").Where("account_id = ? AND topic_slot_id = ?", act.ID, topicID).First(&topicSlot).Error; ret != nil {
if errors.Is(err, gorm.ErrRecordNotFound) { if errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusNotFound, ret) ErrResponse(w, http.StatusNotFound, ret)
} else { } else {
@ -36,7 +36,7 @@ func RemoveChannelTopicTag(w http.ResponseWriter, r *http.Request) {
ErrResponse(w, http.StatusNotFound, errors.New("referenced empty topic")) ErrResponse(w, http.StatusNotFound, errors.New("referenced empty topic"))
return return
} }
if topicSlot.Topic.Channel.ChannelSlot.ChannelSlotId != channelId { if topicSlot.Topic.Channel.ChannelSlot.ChannelSlotID != channelID {
ErrResponse(w, http.StatusNotFound, errors.New("channel topic not found")) ErrResponse(w, http.StatusNotFound, errors.New("channel topic not found"))
return return
} }
@ -45,7 +45,7 @@ func RemoveChannelTopicTag(w http.ResponseWriter, r *http.Request) {
var tag *store.Tag var tag *store.Tag
var tags []store.Tag var tags []store.Tag
for _, t := range topicSlot.Topic.Tags { for _, t := range topicSlot.Topic.Tags {
if t.TagSlot.TagSlotId == tagId { if t.TagSlot.TagSlotID == tagID {
tag = &t tag = &t
} else { } else {
tags = append(tags, t) tags = append(tags, t)
@ -60,7 +60,7 @@ func RemoveChannelTopicTag(w http.ResponseWriter, r *http.Request) {
} }
// check permission // check permission
if tag.Guid != guid { if tag.GUID != guid {
ErrResponse(w, http.StatusUnauthorized, errors.New("not creator of tag")) ErrResponse(w, http.StatusUnauthorized, errors.New("not creator of tag"))
return return
} }
@ -98,11 +98,11 @@ func RemoveChannelTopicTag(w http.ResponseWriter, r *http.Request) {
// determine affected contact list // determine affected contact list
cards := make(map[string]store.Card) cards := make(map[string]store.Card)
for _, card := range channelSlot.Channel.Cards { for _, card := range channelSlot.Channel.Cards {
cards[card.Guid] = card cards[card.GUID] = card
} }
for _, group := range channelSlot.Channel.Groups { for _, group := range channelSlot.Channel.Groups {
for _, card := range group.Cards { for _, card := range group.Cards {
cards[card.Guid] = card cards[card.GUID] = card
} }
} }

View File

@ -18,11 +18,11 @@ func RemoveGroup(w http.ResponseWriter, r *http.Request) {
// scan parameters // scan parameters
params := mux.Vars(r) params := mux.Vars(r)
groupId := params["groupId"] groupID := params["groupID"]
// load referenced group // load referenced group
var slot store.GroupSlot var slot store.GroupSlot
if err := store.DB.Preload("Group.Cards.CardSlot").Where("account_id = ? AND group_slot_id = ?", account.ID, groupId).First(&slot).Error; err != nil { if err := store.DB.Preload("Group.Cards.CardSlot").Where("account_id = ? AND group_slot_id = ?", account.ID, groupID).First(&slot).Error; err != nil {
if !errors.Is(err, gorm.ErrRecordNotFound) { if !errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusInternalServerError, err) ErrResponse(w, http.StatusInternalServerError, err)
} else { } else {

View File

@ -14,7 +14,7 @@ func RemoveNodeAccount(w http.ResponseWriter, r *http.Request) {
// get referenced account id // get referenced account id
params := mux.Vars(r) params := mux.Vars(r)
accountId, res := strconv.ParseUint(params["accountId"], 10, 32) accountID, res := strconv.ParseUint(params["accountID"], 10, 32)
if res != nil { if res != nil {
ErrResponse(w, http.StatusBadRequest, res) ErrResponse(w, http.StatusBadRequest, res)
return return
@ -26,7 +26,7 @@ func RemoveNodeAccount(w http.ResponseWriter, r *http.Request) {
} }
var account store.Account var account store.Account
if err := store.DB.First(&account, accountId).Error; err != nil { if err := store.DB.First(&account, accountID).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) { if errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusNotFound, err) ErrResponse(w, http.StatusNotFound, err)
} else { } else {
@ -98,7 +98,7 @@ func RemoveNodeAccount(w http.ResponseWriter, r *http.Request) {
} }
// delete asset files // delete asset files
path := getStrConfigValue(CONFIG_ASSETPATH, APP_DEFAULTPATH) + "/" + account.Guid path := getStrConfigValue(CONFIG_ASSETPATH, APP_DEFAULTPATH) + "/" + account.GUID
if err = os.RemoveAll(path); err != nil { if err = os.RemoveAll(path); err != nil {
ErrMsg(err) ErrMsg(err)
} }

View File

@ -39,7 +39,7 @@ func SetAccountAccess(w http.ResponseWriter, r *http.Request) {
// create app entry // create app entry
app := store.App { app := store.App {
AccountID: account.Guid, AccountID: account.GUID,
Name: appData.Name, Name: appData.Name,
Description: appData.Description, Description: appData.Description,
Image: appData.Image, Image: appData.Image,
@ -65,7 +65,7 @@ func SetAccountAccess(w http.ResponseWriter, r *http.Request) {
return return
} }
WriteResponse(w, account.Guid + "." + access) WriteResponse(w, account.GUID + "." + access)
} }

View File

@ -18,12 +18,12 @@ func SetArticleGroup(w http.ResponseWriter, r *http.Request) {
// scan parameters // scan parameters
params := mux.Vars(r) params := mux.Vars(r)
articleId := params["articleId"] articleID := params["articleID"]
groupId := params["groupId"] groupID := params["groupID"]
// load referenced article // load referenced article
var articleSlot store.ArticleSlot var articleSlot store.ArticleSlot
if err := store.DB.Preload("Article").Where("account_id = ? AND article_slot_id = ?", account.ID, articleId).First(&articleSlot).Error; err != nil { if err := store.DB.Preload("Article").Where("account_id = ? AND article_slot_id = ?", account.ID, articleID).First(&articleSlot).Error; err != nil {
if !errors.Is(err, gorm.ErrRecordNotFound) { if !errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusInternalServerError, err) ErrResponse(w, http.StatusInternalServerError, err)
} else { } else {
@ -38,7 +38,7 @@ func SetArticleGroup(w http.ResponseWriter, r *http.Request) {
// load referenced group // load referenced group
var groupSlot store.GroupSlot var groupSlot store.GroupSlot
if err := store.DB.Preload("Group.Cards").Preload("Group.GroupSlot").Where("account_id = ? AND group_slot_id = ?", account.ID, groupId).First(&groupSlot).Error; err != nil { if err := store.DB.Preload("Group.Cards").Preload("Group.GroupSlot").Where("account_id = ? AND group_slot_id = ?", account.ID, groupID).First(&groupSlot).Error; err != nil {
if !errors.Is(err, gorm.ErrRecordNotFound) { if !errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusInternalServerError, err) ErrResponse(w, http.StatusInternalServerError, err)
} else { } else {

View File

@ -18,7 +18,7 @@ func SetArticleSubject(w http.ResponseWriter, r *http.Request) {
// scan parameters // scan parameters
params := mux.Vars(r) params := mux.Vars(r)
articleId := params["articleId"] articleID := params["articleID"]
var subject Subject var subject Subject
if err := ParseRequest(r, w, &subject); err != nil { if err := ParseRequest(r, w, &subject); err != nil {
@ -28,7 +28,7 @@ func SetArticleSubject(w http.ResponseWriter, r *http.Request) {
// load referenced article // load referenced article
var slot store.ArticleSlot var slot store.ArticleSlot
if err := store.DB.Preload("Article.Groups.Cards").Where("account_id = ? AND article_slot_id = ?", account.ID, articleId).First(&slot).Error; err != nil { if err := store.DB.Preload("Article.Groups.Cards").Where("account_id = ? AND article_slot_id = ?", account.ID, articleID).First(&slot).Error; err != nil {
if !errors.Is(err, gorm.ErrRecordNotFound) { if !errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusInternalServerError, err) ErrResponse(w, http.StatusInternalServerError, err)
} else { } else {
@ -45,7 +45,7 @@ func SetArticleSubject(w http.ResponseWriter, r *http.Request) {
cards := make(map[string]store.Card) cards := make(map[string]store.Card)
for _, group := range slot.Article.Groups { for _, group := range slot.Article.Groups {
for _, card := range group.Cards { for _, card := range group.Cards {
cards[card.Guid] = card cards[card.GUID] = card
} }
} }

View File

@ -17,12 +17,12 @@ func SetCardGroup(w http.ResponseWriter, r *http.Request) {
// scan parameters // scan parameters
params := mux.Vars(r) params := mux.Vars(r)
cardId := params["cardId"] cardID := params["cardID"]
groupId := params["groupId"] groupID := params["groupID"]
// load referenced card // load referenced card
var slot store.CardSlot var slot store.CardSlot
if err := store.DB.Preload("Card").Where("account_id = ? AND card_slot_id = ?", account.ID, cardId).First(&slot).Error; err != nil { if err := store.DB.Preload("Card").Where("account_id = ? AND card_slot_id = ?", account.ID, cardID).First(&slot).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) { if errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusNotFound, err) ErrResponse(w, http.StatusNotFound, err)
} else { } else {
@ -37,7 +37,7 @@ func SetCardGroup(w http.ResponseWriter, r *http.Request) {
// load referenced group // load referenced group
var groupSlot store.GroupSlot var groupSlot store.GroupSlot
if err := store.DB.Preload("Group").Where("account_id = ? AND group_slot_id = ?", account.ID, groupId).First(&groupSlot).Error; err != nil { if err := store.DB.Preload("Group").Where("account_id = ? AND group_slot_id = ?", account.ID, groupID).First(&groupSlot).Error; err != nil {
if !errors.Is(err, gorm.ErrRecordNotFound) { if !errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusInternalServerError, err) ErrResponse(w, http.StatusInternalServerError, err)
} else { } else {

View File

@ -18,7 +18,7 @@ func SetCardNotes(w http.ResponseWriter, r *http.Request) {
// scan parameters // scan parameters
params := mux.Vars(r) params := mux.Vars(r)
cardId := params["cardId"] cardID := params["cardID"]
var notes string var notes string
if err := ParseRequest(r, w, &notes); err != nil { if err := ParseRequest(r, w, &notes); err != nil {
@ -28,7 +28,7 @@ func SetCardNotes(w http.ResponseWriter, r *http.Request) {
// load referenced card // load referenced card
var slot store.CardSlot var slot store.CardSlot
if err := store.DB.Preload("Card.Groups").Where("account_id = ? AND card_slot_id = ?", account.ID, cardId).First(&slot).Error; err != nil { if err := store.DB.Preload("Card.Groups").Where("account_id = ? AND card_slot_id = ?", account.ID, cardID).First(&slot).Error; err != nil {
if !errors.Is(err, gorm.ErrRecordNotFound) { if !errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusInternalServerError, err) ErrResponse(w, http.StatusInternalServerError, err)
} else { } else {

View File

@ -18,7 +18,7 @@ func SetCardProfile(w http.ResponseWriter, r *http.Request) {
// scan parameters // scan parameters
params := mux.Vars(r) params := mux.Vars(r)
cardId := params["cardId"] cardID := params["cardID"]
var message DataMessage var message DataMessage
if err := ParseRequest(r, w, &message); err != nil { if err := ParseRequest(r, w, &message); err != nil {
@ -34,7 +34,7 @@ func SetCardProfile(w http.ResponseWriter, r *http.Request) {
} }
slot := store.CardSlot{} slot := store.CardSlot{}
if err := store.DB.Preload("Card.Groups").Where("account_id = ? AND card_slot_id = ?", account.ID, cardId).First(&slot).Error; err != nil { if err := store.DB.Preload("Card.Groups").Where("account_id = ? AND card_slot_id = ?", account.ID, cardID).First(&slot).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) { if errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusNotFound, err) ErrResponse(w, http.StatusNotFound, err)
} else { } else {
@ -47,7 +47,7 @@ func SetCardProfile(w http.ResponseWriter, r *http.Request) {
ErrResponse(w, http.StatusNotFound, errors.New("referenced empty card")) ErrResponse(w, http.StatusNotFound, errors.New("referenced empty card"))
return return
} }
if card.Guid != guid { if card.GUID != guid {
ErrResponse(w, http.StatusBadRequest, errors.New("invalid profile")) ErrResponse(w, http.StatusBadRequest, errors.New("invalid profile"))
return return
} }

View File

@ -22,7 +22,7 @@ func SetCardStatus(w http.ResponseWriter, r *http.Request) {
// scan parameters // scan parameters
params := mux.Vars(r) params := mux.Vars(r)
cardId := params["cardId"] cardID := params["cardID"]
token := r.FormValue("token") token := r.FormValue("token")
// scan revisions // scan revisions
@ -75,7 +75,7 @@ func SetCardStatus(w http.ResponseWriter, r *http.Request) {
// load referenced card // load referenced card
var slot store.CardSlot var slot store.CardSlot
if err := store.DB.Preload("Card.Groups").Where("account_id = ? AND card_slot_id = ?", account.ID, cardId).First(&slot).Error; err != nil { if err := store.DB.Preload("Card.Groups").Where("account_id = ? AND card_slot_id = ?", account.ID, cardID).First(&slot).Error; err != nil {
if !errors.Is(err, gorm.ErrRecordNotFound) { if !errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusInternalServerError, err) ErrResponse(w, http.StatusInternalServerError, err)
} else { } else {

View File

@ -18,12 +18,12 @@ func SetChannelCard(w http.ResponseWriter, r *http.Request) {
// scan parameters // scan parameters
params := mux.Vars(r) params := mux.Vars(r)
channelId := params["channelId"] channelID := params["channelID"]
cardId := params["cardId"] cardID := params["cardID"]
// load referenced channel // load referenced channel
var channelSlot store.ChannelSlot var channelSlot store.ChannelSlot
if err := store.DB.Preload("Channel.Cards.CardSlot").Preload("Channel.Groups.GroupSlot").Preload("Channel.Groups.Cards").Where("account_id = ? AND channel_slot_id = ?", account.ID, channelId).First(&channelSlot).Error; err != nil { if err := store.DB.Preload("Channel.Cards.CardSlot").Preload("Channel.Groups.GroupSlot").Preload("Channel.Groups.Cards").Where("account_id = ? AND channel_slot_id = ?", account.ID, channelID).First(&channelSlot).Error; err != nil {
if !errors.Is(err, gorm.ErrRecordNotFound) { if !errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusInternalServerError, err) ErrResponse(w, http.StatusInternalServerError, err)
} else { } else {
@ -38,7 +38,7 @@ func SetChannelCard(w http.ResponseWriter, r *http.Request) {
// load referenced card // load referenced card
var cardSlot store.CardSlot var cardSlot store.CardSlot
if err := store.DB.Preload("Card.CardSlot").Where("account_id = ? AND card_slot_id = ?", account.ID, cardId).First(&cardSlot).Error; err != nil { if err := store.DB.Preload("Card.CardSlot").Where("account_id = ? AND card_slot_id = ?", account.ID, cardID).First(&cardSlot).Error; err != nil {
if !errors.Is(err, gorm.ErrRecordNotFound) { if !errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusInternalServerError, err) ErrResponse(w, http.StatusInternalServerError, err)
} else { } else {
@ -54,14 +54,14 @@ func SetChannelCard(w http.ResponseWriter, r *http.Request) {
// determine contact list // determine contact list
cards := make(map[string]store.Card) cards := make(map[string]store.Card)
for _, card := range channelSlot.Channel.Cards { for _, card := range channelSlot.Channel.Cards {
cards[card.Guid] = card cards[card.GUID] = card
} }
for _, group := range channelSlot.Channel.Groups { for _, group := range channelSlot.Channel.Groups {
for _, card := range group.Cards { for _, card := range group.Cards {
cards[card.Guid] = card cards[card.GUID] = card
} }
} }
cards[cardSlot.Card.Guid] = *cardSlot.Card cards[cardSlot.Card.GUID] = *cardSlot.Card
// save and update contact revision // save and update contact revision
err = store.DB.Transaction(func(tx *gorm.DB) error { err = store.DB.Transaction(func(tx *gorm.DB) error {

View File

@ -18,12 +18,12 @@ func SetChannelGroup(w http.ResponseWriter, r *http.Request) {
// scan parameters // scan parameters
params := mux.Vars(r) params := mux.Vars(r)
channelId := params["channelId"] channelID := params["channelID"]
groupId := params["groupId"] groupID := params["groupID"]
// load referenced channel // load referenced channel
var channelSlot store.ChannelSlot var channelSlot store.ChannelSlot
if err := store.DB.Preload("Channel.Cards.CardSlot").Preload("Channel.Groups.GroupSlot").Preload("Channel.Groups.Cards").Where("account_id = ? AND channel_slot_id = ?", account.ID, channelId).First(&channelSlot).Error; err != nil { if err := store.DB.Preload("Channel.Cards.CardSlot").Preload("Channel.Groups.GroupSlot").Preload("Channel.Groups.Cards").Where("account_id = ? AND channel_slot_id = ?", account.ID, channelID).First(&channelSlot).Error; err != nil {
if !errors.Is(err, gorm.ErrRecordNotFound) { if !errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusInternalServerError, err) ErrResponse(w, http.StatusInternalServerError, err)
} else { } else {
@ -38,7 +38,7 @@ func SetChannelGroup(w http.ResponseWriter, r *http.Request) {
// load referenced group // load referenced group
var groupSlot store.GroupSlot var groupSlot store.GroupSlot
if err := store.DB.Preload("Group.Cards").Preload("Group.GroupSlot").Where("account_id = ? AND group_slot_id = ?", account.ID, groupId).First(&groupSlot).Error; err != nil { if err := store.DB.Preload("Group.Cards").Preload("Group.GroupSlot").Where("account_id = ? AND group_slot_id = ?", account.ID, groupID).First(&groupSlot).Error; err != nil {
if !errors.Is(err, gorm.ErrRecordNotFound) { if !errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusInternalServerError, err) ErrResponse(w, http.StatusInternalServerError, err)
} else { } else {
@ -73,7 +73,7 @@ func SetChannelGroup(w http.ResponseWriter, r *http.Request) {
cards := make(map[string]store.Card) cards := make(map[string]store.Card)
for _, group := range channelSlot.Channel.Groups { for _, group := range channelSlot.Channel.Groups {
for _, card := range group.Cards { for _, card := range group.Cards {
cards[card.Guid] = card cards[card.GUID] = card
} }
} }

View File

@ -18,7 +18,7 @@ func SetChannelSubject(w http.ResponseWriter, r *http.Request) {
// scan parameters // scan parameters
params := mux.Vars(r) params := mux.Vars(r)
channelId := params["channelId"] channelID := params["channelID"]
var subject Subject var subject Subject
if err := ParseRequest(r, w, &subject); err != nil { if err := ParseRequest(r, w, &subject); err != nil {
@ -28,7 +28,7 @@ func SetChannelSubject(w http.ResponseWriter, r *http.Request) {
// load referenced channel // load referenced channel
var slot store.ChannelSlot var slot store.ChannelSlot
if err := store.DB.Preload("Channel.Cards").Preload("Channel.Groups.Cards").Where("account_id = ? AND channel_slot_id = ?", account.ID, channelId).First(&slot).Error; err != nil { if err := store.DB.Preload("Channel.Cards").Preload("Channel.Groups.Cards").Where("account_id = ? AND channel_slot_id = ?", account.ID, channelID).First(&slot).Error; err != nil {
if !errors.Is(err, gorm.ErrRecordNotFound) { if !errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusInternalServerError, err) ErrResponse(w, http.StatusInternalServerError, err)
} else { } else {
@ -44,11 +44,11 @@ func SetChannelSubject(w http.ResponseWriter, r *http.Request) {
// determine affected contact list // determine affected contact list
cards := make(map[string]store.Card) cards := make(map[string]store.Card)
for _, card := range slot.Channel.Cards { for _, card := range slot.Channel.Cards {
cards[card.Guid] = card cards[card.GUID] = card
} }
for _, group := range slot.Channel.Groups { for _, group := range slot.Channel.Groups {
for _, card := range group.Cards { for _, card := range group.Cards {
cards[card.Guid] = card cards[card.GUID] = card
} }
} }

View File

@ -12,7 +12,7 @@ func SetChannelTopicConfirmed(w http.ResponseWriter, r *http.Request) {
// scan parameters // scan parameters
params := mux.Vars(r) params := mux.Vars(r)
topicId := params["topicId"] topicID := params["topicID"]
var status string var status string
if err := ParseRequest(r, w, &status); err != nil { if err := ParseRequest(r, w, &status); err != nil {
@ -33,7 +33,7 @@ func SetChannelTopicConfirmed(w http.ResponseWriter, r *http.Request) {
// load topic // load topic
var topicSlot store.TopicSlot var topicSlot store.TopicSlot
if err = store.DB.Preload("Topic").Where("channel_id = ? AND topic_slot_id = ?", channelSlot.Channel.ID, topicId).First(&topicSlot).Error; err != nil { if err = store.DB.Preload("Topic").Where("channel_id = ? AND topic_slot_id = ?", channelSlot.Channel.ID, topicID).First(&topicSlot).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) { if errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusNotFound, err) ErrResponse(w, http.StatusNotFound, err)
} else { } else {
@ -75,11 +75,11 @@ func SetChannelTopicConfirmed(w http.ResponseWriter, r *http.Request) {
// determine affected contact list // determine affected contact list
cards := make(map[string]store.Card) cards := make(map[string]store.Card)
for _, card := range channelSlot.Channel.Cards { for _, card := range channelSlot.Channel.Cards {
cards[card.Guid] = card cards[card.GUID] = card
} }
for _, group := range channelSlot.Channel.Groups { for _, group := range channelSlot.Channel.Groups {
for _, card := range group.Cards { for _, card := range group.Cards {
cards[card.Guid] = card cards[card.GUID] = card
} }
} }

View File

@ -12,7 +12,7 @@ func SetChannelTopicSubject(w http.ResponseWriter, r *http.Request) {
// scan parameters // scan parameters
params := mux.Vars(r) params := mux.Vars(r)
topicId := params["topicId"] topicID := params["topicID"]
confirm := r.FormValue("confirm"); confirm := r.FormValue("confirm");
var subject Subject var subject Subject
@ -30,7 +30,7 @@ func SetChannelTopicSubject(w http.ResponseWriter, r *http.Request) {
// load topic // load topic
var topicSlot store.TopicSlot var topicSlot store.TopicSlot
if err = store.DB.Preload("Topic").Where("channel_id = ? AND topic_slot_id = ?", channelSlot.Channel.ID, topicId).First(&topicSlot).Error; err != nil { if err = store.DB.Preload("Topic").Where("channel_id = ? AND topic_slot_id = ?", channelSlot.Channel.ID, topicID).First(&topicSlot).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) { if errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusNotFound, err) ErrResponse(w, http.StatusNotFound, err)
} else { } else {
@ -40,7 +40,7 @@ func SetChannelTopicSubject(w http.ResponseWriter, r *http.Request) {
} }
// can only update subject if creator // can only update subject if creator
if topicSlot.Topic.Guid != guid { if topicSlot.Topic.GUID != guid {
ErrResponse(w, http.StatusUnauthorized, errors.New("topic not created by you")) ErrResponse(w, http.StatusUnauthorized, errors.New("topic not created by you"))
return return
} }
@ -88,11 +88,11 @@ func SetChannelTopicSubject(w http.ResponseWriter, r *http.Request) {
// determine affected contact list // determine affected contact list
cards := make(map[string]store.Card) cards := make(map[string]store.Card)
for _, card := range channelSlot.Channel.Cards { for _, card := range channelSlot.Channel.Cards {
cards[card.Guid] = card cards[card.GUID] = card
} }
for _, group := range channelSlot.Channel.Groups { for _, group := range channelSlot.Channel.Groups {
for _, card := range group.Cards { for _, card := range group.Cards {
cards[card.Guid] = card cards[card.GUID] = card
} }
} }

View File

@ -12,9 +12,9 @@ func SetChannelTopicTagSubject(w http.ResponseWriter, r *http.Request) {
// scan parameters // scan parameters
params := mux.Vars(r) params := mux.Vars(r)
channelId := params["channelId"] channelID := params["channelID"]
topicId := params["topicId"] topicID := params["topicID"]
tagId := params["tagId"] tagID := params["tagID"]
var subject Subject var subject Subject
if err := ParseRequest(r, w, &subject); err != nil { if err := ParseRequest(r, w, &subject); err != nil {
@ -31,7 +31,7 @@ func SetChannelTopicTagSubject(w http.ResponseWriter, r *http.Request) {
// load topic // load topic
var tagSlot store.TagSlot var tagSlot store.TagSlot
if err = store.DB.Preload("Tag.Channel.ChannelSlot").Preload("Tag.Topic.TopicSlot").Where("account_id = ? AND tag_slot_id = ?", act.ID, tagId).First(&tagSlot).Error; err != nil { if err = store.DB.Preload("Tag.Channel.ChannelSlot").Preload("Tag.Topic.TopicSlot").Where("account_id = ? AND tag_slot_id = ?", act.ID, tagID).First(&tagSlot).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) { if errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusNotFound, err) ErrResponse(w, http.StatusNotFound, err)
} else { } else {
@ -43,15 +43,15 @@ func SetChannelTopicTagSubject(w http.ResponseWriter, r *http.Request) {
ErrResponse(w, http.StatusNotFound, errors.New("referenced empty tag")) ErrResponse(w, http.StatusNotFound, errors.New("referenced empty tag"))
return return
} }
if tagSlot.Tag.Channel.ChannelSlot.ChannelSlotId != channelId { if tagSlot.Tag.Channel.ChannelSlot.ChannelSlotID != channelID {
ErrResponse(w, http.StatusNotFound, errors.New("channel tag not found")) ErrResponse(w, http.StatusNotFound, errors.New("channel tag not found"))
return return
} }
if tagSlot.Tag.Topic.TopicSlot.TopicSlotId != topicId { if tagSlot.Tag.Topic.TopicSlot.TopicSlotID != topicID {
ErrResponse(w, http.StatusNotFound, errors.New("topic tag not found")) ErrResponse(w, http.StatusNotFound, errors.New("topic tag not found"))
return return
} }
if tagSlot.Tag.Guid != guid { if tagSlot.Tag.GUID != guid {
ErrResponse(w, http.StatusUnauthorized, errors.New("not creator of tag")) ErrResponse(w, http.StatusUnauthorized, errors.New("not creator of tag"))
return return
} }
@ -92,11 +92,11 @@ func SetChannelTopicTagSubject(w http.ResponseWriter, r *http.Request) {
// determine affected contact list // determine affected contact list
cards := make(map[string]store.Card) cards := make(map[string]store.Card)
for _, card := range channelSlot.Channel.Cards { for _, card := range channelSlot.Channel.Cards {
cards[card.Guid] = card cards[card.GUID] = card
} }
for _, group := range channelSlot.Channel.Groups { for _, group := range channelSlot.Channel.Groups {
for _, card := range group.Cards { for _, card := range group.Cards {
cards[card.Guid] = card cards[card.GUID] = card
} }
} }

View File

@ -40,7 +40,7 @@ func SetCloseMessage(w http.ResponseWriter, r *http.Request) {
// see if card exists // see if card exists
var card store.Card var card store.Card
if err := store.DB.Preload("CardSlot").Where("account_id = ? AND guid = ?", account.Guid, guid).First(&card).Error; err != nil { if err := store.DB.Preload("CardSlot").Where("account_id = ? AND guid = ?", account.GUID, guid).First(&card).Error; err != nil {
if !errors.Is(err, gorm.ErrRecordNotFound) { if !errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusInternalServerError, err) ErrResponse(w, http.StatusInternalServerError, err)
} else { } else {

View File

@ -18,7 +18,7 @@ func SetGroupSubject(w http.ResponseWriter, r *http.Request) {
// scan parameters // scan parameters
params := mux.Vars(r) params := mux.Vars(r)
groupId := params["groupId"] groupID := params["groupID"]
var subject Subject var subject Subject
if err := ParseRequest(r, w, &subject); err != nil { if err := ParseRequest(r, w, &subject); err != nil {
@ -28,7 +28,7 @@ func SetGroupSubject(w http.ResponseWriter, r *http.Request) {
// load referenced group // load referenced group
var slot store.GroupSlot var slot store.GroupSlot
if err := store.DB.Preload("Group.GroupData").Where("account_id = ? AND group_slot_id = ?", account.ID, groupId).First(&slot).Error; err != nil { if err := store.DB.Preload("Group.GroupData").Where("account_id = ? AND group_slot_id = ?", account.ID, groupID).First(&slot).Error; err != nil {
if !errors.Is(err, gorm.ErrRecordNotFound) { if !errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusInternalServerError, err) ErrResponse(w, http.StatusInternalServerError, err)
} else { } else {

View File

@ -14,7 +14,7 @@ func SetNodeAccount(w http.ResponseWriter, r *http.Request) {
// get referenced account id // get referenced account id
params := mux.Vars(r) params := mux.Vars(r)
accountId, res := strconv.ParseUint(params["accountId"], 10, 32) accountID, res := strconv.ParseUint(params["accountID"], 10, 32)
if res != nil { if res != nil {
ErrResponse(w, http.StatusBadRequest, res) ErrResponse(w, http.StatusBadRequest, res)
return return
@ -35,7 +35,7 @@ func SetNodeAccount(w http.ResponseWriter, r *http.Request) {
accountToken := store.AccountToken{ accountToken := store.AccountToken{
TokenType: APP_TOKENRESET, TokenType: APP_TOKENRESET,
Token: token, Token: token,
AccountID: uint(accountId), AccountID: uint(accountID),
Expires: time.Now().Unix() + APP_CREATEEXPIRE, Expires: time.Now().Unix() + APP_CREATEEXPIRE,
}; };

View File

@ -11,7 +11,7 @@ func SetNodeAccountStatus(w http.ResponseWriter, r *http.Request) {
// get referenced account id // get referenced account id
params := mux.Vars(r) params := mux.Vars(r)
accountId, res := strconv.ParseUint(params["accountId"], 10, 32) accountID, res := strconv.ParseUint(params["accountID"], 10, 32)
if res != nil { if res != nil {
ErrResponse(w, http.StatusBadRequest, res) ErrResponse(w, http.StatusBadRequest, res)
return return
@ -28,7 +28,7 @@ func SetNodeAccountStatus(w http.ResponseWriter, r *http.Request) {
return return
} }
if err := store.DB.Model(store.Account{}).Where("id = ?", accountId).Update("disabled", flag).Error; err != nil { if err := store.DB.Model(store.Account{}).Where("id = ?", accountID).Update("disabled", flag).Error; err != nil {
ErrResponse(w, http.StatusInternalServerError, err) ErrResponse(w, http.StatusInternalServerError, err)
return return
} }

View File

@ -29,7 +29,7 @@ func SetNodeConfig(w http.ResponseWriter, r *http.Request) {
if res := tx.Clauses(clause.OnConflict{ if res := tx.Clauses(clause.OnConflict{
Columns: []clause.Column{{Name: "config_id"}}, Columns: []clause.Column{{Name: "config_id"}},
DoUpdates: clause.AssignmentColumns([]string{"str_value"}), DoUpdates: clause.AssignmentColumns([]string{"str_value"}),
}).Create(&store.Config{ConfigId: CONFIG_DOMAIN, StrValue: config.Domain}).Error; res != nil { }).Create(&store.Config{ConfigID: CONFIG_DOMAIN, StrValue: config.Domain}).Error; res != nil {
return res return res
} }
@ -37,7 +37,7 @@ func SetNodeConfig(w http.ResponseWriter, r *http.Request) {
if res := tx.Clauses(clause.OnConflict{ if res := tx.Clauses(clause.OnConflict{
Columns: []clause.Column{{Name: "config_id"}}, Columns: []clause.Column{{Name: "config_id"}},
DoUpdates: clause.AssignmentColumns([]string{"num_value"}), DoUpdates: clause.AssignmentColumns([]string{"num_value"}),
}).Create(&store.Config{ConfigId: CONFIG_ACCOUNTLIMIT, NumValue: config.AccountLimit}).Error; res != nil { }).Create(&store.Config{ConfigID: CONFIG_ACCOUNTLIMIT, NumValue: config.AccountLimit}).Error; res != nil {
return res return res
} }
@ -45,7 +45,7 @@ func SetNodeConfig(w http.ResponseWriter, r *http.Request) {
if res := tx.Clauses(clause.OnConflict{ if res := tx.Clauses(clause.OnConflict{
Columns: []clause.Column{{Name: "config_id"}}, Columns: []clause.Column{{Name: "config_id"}},
DoUpdates: clause.AssignmentColumns([]string{"bool_value"}), DoUpdates: clause.AssignmentColumns([]string{"bool_value"}),
}).Create(&store.Config{ConfigId: CONFIG_ACCOUNTLIMIT, BoolValue: config.OpenAccess}).Error; res != nil { }).Create(&store.Config{ConfigID: CONFIG_ACCOUNTLIMIT, BoolValue: config.OpenAccess}).Error; res != nil {
return res return res
} }
@ -53,7 +53,7 @@ func SetNodeConfig(w http.ResponseWriter, r *http.Request) {
if res := tx.Clauses(clause.OnConflict{ if res := tx.Clauses(clause.OnConflict{
Columns: []clause.Column{{Name: "config_id"}}, Columns: []clause.Column{{Name: "config_id"}},
DoUpdates: clause.AssignmentColumns([]string{"num_value"}), DoUpdates: clause.AssignmentColumns([]string{"num_value"}),
}).Create(&store.Config{ConfigId: CONFIG_STORAGE, NumValue: config.AccountStorage}).Error; res != nil { }).Create(&store.Config{ConfigID: CONFIG_STORAGE, NumValue: config.AccountStorage}).Error; res != nil {
return res return res
} }

View File

@ -27,10 +27,10 @@ func SetNodeStatus(w http.ResponseWriter, r *http.Request) {
} }
err = store.DB.Transaction(func(tx *gorm.DB) error { err = store.DB.Transaction(func(tx *gorm.DB) error {
if res := tx.Create(&store.Config{ConfigId: CONFIG_TOKEN, StrValue: token}).Error; res != nil { if res := tx.Create(&store.Config{ConfigID: CONFIG_TOKEN, StrValue: token}).Error; res != nil {
return res return res
} }
if res := tx.Create(&store.Config{ConfigId: CONFIG_CONFIGURED, BoolValue: true}).Error; res != nil { if res := tx.Create(&store.Config{ConfigID: CONFIG_CONFIGURED, BoolValue: true}).Error; res != nil {
return res return res
} }
return nil; return nil;

View File

@ -44,7 +44,7 @@ func SetOpenMessage(w http.ResponseWriter, r *http.Request) {
// see if card exists // see if card exists
slot := &store.CardSlot{} slot := &store.CardSlot{}
card := &store.Card{} card := &store.Card{}
if err := store.DB.Preload("CardSlot").Where("account_id = ? AND guid = ?", account.Guid, guid).First(card).Error; err != nil { if err := store.DB.Preload("CardSlot").Where("account_id = ? AND guid = ?", account.GUID, guid).First(card).Error; err != nil {
if !errors.Is(err, gorm.ErrRecordNotFound) { if !errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusInternalServerError, err) ErrResponse(w, http.StatusInternalServerError, err)
return return
@ -56,7 +56,7 @@ func SetOpenMessage(w http.ResponseWriter, r *http.Request) {
ErrResponse(w, http.StatusInternalServerError, res) ErrResponse(w, http.StatusInternalServerError, res)
return return
} }
card.Guid = guid card.GUID = guid
card.Username = connect.Handle card.Username = connect.Handle
card.Name = connect.Name card.Name = connect.Name
card.Description = connect.Description card.Description = connect.Description
@ -72,14 +72,14 @@ func SetOpenMessage(w http.ResponseWriter, r *http.Request) {
card.NotifiedChannel = connect.ChannelRevision card.NotifiedChannel = connect.ChannelRevision
card.OutToken = connect.Token card.OutToken = connect.Token
card.InToken = hex.EncodeToString(data) card.InToken = hex.EncodeToString(data)
card.AccountID = account.Guid card.AccountID = account.GUID
// create slot // create slot
err = store.DB.Transaction(func(tx *gorm.DB) error { err = store.DB.Transaction(func(tx *gorm.DB) error {
if res := tx.Save(card).Error; res != nil { if res := tx.Save(card).Error; res != nil {
return res return res
} }
slot.CardSlotId = uuid.New().String() slot.CardSlotID = uuid.New().String()
slot.AccountID = account.ID slot.AccountID = account.ID
slot.Revision = account.CardRevision + 1 slot.Revision = account.CardRevision + 1
slot.CardID = card.ID slot.CardID = card.ID

View File

@ -15,36 +15,36 @@ const CONFIG_STORAGE = "storage"
const CONFIG_ASSETPATH = "asset_path" const CONFIG_ASSETPATH = "asset_path"
const CONFIG_SCRIPTPATH = "script_path" const CONFIG_SCRIPTPATH = "script_path"
func getStrConfigValue(configId string, empty string) string { func getStrConfigValue(configID string, empty string) string {
var config store.Config var config store.Config
err := store.DB.Where("config_id = ?", configId).First(&config).Error err := store.DB.Where("config_id = ?", configID).First(&config).Error
if errors.Is(err, gorm.ErrRecordNotFound) { if errors.Is(err, gorm.ErrRecordNotFound) {
return empty return empty
} }
return config.StrValue return config.StrValue
} }
func getNumConfigValue(configId string, empty int64) int64 { func getNumConfigValue(configID string, empty int64) int64 {
var config store.Config var config store.Config
err := store.DB.Where("config_id = ?", configId).First(&config).Error err := store.DB.Where("config_id = ?", configID).First(&config).Error
if errors.Is(err, gorm.ErrRecordNotFound) { if errors.Is(err, gorm.ErrRecordNotFound) {
return empty return empty
} }
return config.NumValue return config.NumValue
} }
func getBoolConfigValue(configId string, empty bool) bool { func getBoolConfigValue(configID string, empty bool) bool {
var config store.Config var config store.Config
err := store.DB.Where("config_id = ?", configId).First(&config).Error err := store.DB.Where("config_id = ?", configID).First(&config).Error
if errors.Is(err, gorm.ErrRecordNotFound) { if errors.Is(err, gorm.ErrRecordNotFound) {
return empty return empty
} }
return config.BoolValue return config.BoolValue
} }
func getBinConfigValue(configId string, empty []byte) []byte { func getBinConfigValue(configID string, empty []byte) []byte {
var config store.Config var config store.Config
err := store.DB.Where("config_id = ?", configId).First(&config).Error err := store.DB.Where("config_id = ?", configID).First(&config).Error
if errors.Is(err, gorm.ErrRecordNotFound) { if errors.Is(err, gorm.ErrRecordNotFound) {
return empty return empty
} }

View File

@ -13,7 +13,7 @@ func garbageCollect(act *store.Account) {
defer garbageSync.Unlock() defer garbageSync.Unlock()
// get all asset files // get all asset files
dir := getStrConfigValue(CONFIG_ASSETPATH, APP_DEFAULTPATH) + "/" + act.Guid dir := getStrConfigValue(CONFIG_ASSETPATH, APP_DEFAULTPATH) + "/" + act.GUID
files, err := os.ReadDir(dir) files, err := os.ReadDir(dir)
if err != nil { if err != nil {
ErrMsg(err) ErrMsg(err)
@ -35,13 +35,13 @@ func garbageCollect(act *store.Account) {
// mark all referenced files // mark all referenced files
for _, asset := range assets { for _, asset := range assets {
list[asset.AssetId] = true list[asset.AssetID] = true
} }
// delete any unreferenced file // delete any unreferenced file
for id, set := range list { for id, set := range list {
if !set { if !set {
LogMsg("removing file asset " + act.Guid + "/" + id) LogMsg("removing file asset " + act.GUID + "/" + id)
if err := os.Remove(dir + "/" + id); err != nil { if err := os.Remove(dir + "/" + id); err != nil {
ErrMsg(err) ErrMsg(err)
} }

View File

@ -41,13 +41,13 @@ func TestMain(m *testing.M) {
} }
// config data path // config data path
scripts := &store.Config{ ConfigId: CONFIG_SCRIPTPATH, StrValue: "./testscripts" } scripts := &store.Config{ ConfigID: CONFIG_SCRIPTPATH, StrValue: "./testscripts" }
if err := store.DB.Save(scripts).Error; err != nil { if err := store.DB.Save(scripts).Error; err != nil {
panic("failed to configure scripts path") panic("failed to configure scripts path")
} }
// config data path // config data path
path := &store.Config{ ConfigId: CONFIG_ASSETPATH, StrValue: "./testdata" } path := &store.Config{ ConfigID: CONFIG_ASSETPATH, StrValue: "./testdata" }
if err := store.DB.Save(path).Error; err != nil { if err := store.DB.Save(path).Error; err != nil {
panic("failed to configure data path") panic("failed to configure data path")
} }

View File

@ -72,7 +72,7 @@ func ReadDataMessage(msg *DataMessage, obj interface{}) (string, string, int64,
} }
// validate signer // validate signer
if signedData.Guid != guid { if signedData.GUID != guid {
return "", "", 0, errors.New("invalid message source") return "", "", 0, errors.New("invalid message source")
} }
@ -99,7 +99,7 @@ func WriteDataMessage(privateKey string, publicKey string, keyType string,
return nil, err return nil, err
} }
var signedData SignedData var signedData SignedData
signedData.Guid = guid signedData.GUID = guid
signedData.Timestamp = time.Now().Unix() signedData.Timestamp = time.Now().Unix()
signedData.MessageType = messageType signedData.MessageType = messageType
signedData.Value = string(data) signedData.Value = string(data)

View File

@ -7,7 +7,7 @@ import (
func getProfileModel(account *store.Account) *Profile { func getProfileModel(account *store.Account) *Profile {
return &Profile{ return &Profile{
Guid: account.Guid, GUID: account.GUID,
Handle: account.Username, Handle: account.Username,
Name: account.AccountDetail.Name, Name: account.AccountDetail.Name,
Description: account.AccountDetail.Description, Description: account.AccountDetail.Description,
@ -23,13 +23,13 @@ func getCardModel(slot *store.CardSlot) *Card {
if slot.Card == nil { if slot.Card == nil {
return &Card{ return &Card{
Id: slot.CardSlotId, ID: slot.CardSlotID,
Revision: slot.Revision, Revision: slot.Revision,
} }
} }
return &Card{ return &Card{
Id: slot.CardSlotId, ID: slot.CardSlotID,
Revision: slot.Revision, Revision: slot.Revision,
Data: &CardData { Data: &CardData {
NotifiedProfile: slot.Card.NotifiedProfile, NotifiedProfile: slot.Card.NotifiedProfile,
@ -48,13 +48,13 @@ func getCardRevisionModel(slot *store.CardSlot) *Card {
if slot.Card == nil { if slot.Card == nil {
return &Card{ return &Card{
Id: slot.CardSlotId, ID: slot.CardSlotID,
Revision: slot.Revision, Revision: slot.Revision,
} }
} }
return &Card{ return &Card{
Id: slot.CardSlotId, ID: slot.CardSlotID,
Revision: slot.Revision, Revision: slot.Revision,
Data: &CardData { Data: &CardData {
NotifiedProfile: slot.Card.NotifiedProfile, NotifiedProfile: slot.Card.NotifiedProfile,
@ -71,7 +71,7 @@ func getCardDetailModel(slot *store.CardSlot) *CardDetail {
var groups []string; var groups []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{
@ -85,7 +85,7 @@ func getCardDetailModel(slot *store.CardSlot) *CardDetail {
func getCardProfileModel(slot *store.CardSlot) *CardProfile { func getCardProfileModel(slot *store.CardSlot) *CardProfile {
return &CardProfile{ return &CardProfile{
Guid: slot.Card.Guid, GUID: slot.Card.GUID,
Handle: slot.Card.Username, Handle: slot.Card.Username,
Name: slot.Card.Name, Name: slot.Card.Name,
Description: slot.Card.Description, Description: slot.Card.Description,
@ -99,13 +99,13 @@ func getCardProfileModel(slot *store.CardSlot) *CardProfile {
func getGroupModel(slot *store.GroupSlot) *Group { func getGroupModel(slot *store.GroupSlot) *Group {
if slot.Group == nil { if slot.Group == nil {
return &Group{ return &Group{
Id: slot.GroupSlotId, ID: slot.GroupSlotID,
Revision: slot.Revision, Revision: slot.Revision,
} }
} }
return &Group{ return &Group{
Id: slot.GroupSlotId, ID: slot.GroupSlotID,
Revision: slot.Revision, Revision: slot.Revision,
Data: &GroupData { Data: &GroupData {
DataType: slot.Group.DataType, DataType: slot.Group.DataType,
@ -119,22 +119,22 @@ func getGroupModel(slot *store.GroupSlot) *Group {
func getArticleModel(slot *store.ArticleSlot, showData bool, showList bool) *Article { func getArticleModel(slot *store.ArticleSlot, showData bool, showList bool) *Article {
if !showData || slot.Article == nil { if !showData || slot.Article == nil {
return &Article{ return &Article{
Id: slot.ArticleSlotId, ID: slot.ArticleSlotID,
Revision: slot.Revision, Revision: slot.Revision,
} }
} }
var articleGroups *IdList var articleGroups *IDList
if showList { if showList {
var groups []string; var groups []string;
for _, group := range slot.Article.Groups { for _, group := range slot.Article.Groups {
groups = append(groups, group.GroupSlot.GroupSlotId) groups = append(groups, group.GroupSlot.GroupSlotID)
} }
articleGroups = &IdList{ Ids: groups } articleGroups = &IDList{ IDs: groups }
} }
return &Article{ return &Article{
Id: slot.ArticleSlotId, ID: slot.ArticleSlotID,
Revision: slot.Revision, Revision: slot.Revision,
Data: &ArticleData { Data: &ArticleData {
DataType: slot.Article.DataType, DataType: slot.Article.DataType,
@ -150,13 +150,13 @@ func getChannelRevisionModel(slot *store.ChannelSlot, showData bool) *Channel {
if !showData || slot.Channel == nil { if !showData || slot.Channel == nil {
return &Channel{ return &Channel{
Id: slot.ChannelSlotId, ID: slot.ChannelSlotID,
Revision: slot.Revision, Revision: slot.Revision,
} }
} }
return &Channel{ return &Channel{
Id: slot.ChannelSlotId, ID: slot.ChannelSlotID,
Revision: slot.Revision, Revision: slot.Revision,
Data: &ChannelData { Data: &ChannelData {
DetailRevision: slot.Channel.DetailRevision, DetailRevision: slot.Channel.DetailRevision,
@ -175,18 +175,18 @@ func getChannelDetailModel(slot *store.ChannelSlot, showList bool) *ChannelDetai
if showList { if showList {
var groups []string; var groups []string;
for _, group := range slot.Channel.Groups { for _, group := range slot.Channel.Groups {
groups = append(groups, group.GroupSlot.GroupSlotId) groups = append(groups, group.GroupSlot.GroupSlotID)
} }
var cards []string; var cards []string;
for _, card := range slot.Channel.Cards { for _, card := range slot.Channel.Cards {
cards = append(cards, card.CardSlot.CardSlotId) cards = append(cards, card.CardSlot.CardSlotID)
} }
contacts = &ChannelContacts{ Groups: groups, Cards: cards } contacts = &ChannelContacts{ Groups: groups, Cards: cards }
} }
members := []string{} members := []string{}
for _, card := range slot.Channel.Cards { for _, card := range slot.Channel.Cards {
members = append(members, card.Guid) members = append(members, card.GUID)
} }
return &ChannelDetail{ return &ChannelDetail{
@ -207,7 +207,7 @@ func getChannelSummaryModel(slot *store.ChannelSlot) *ChannelSummary {
topicDetail := TopicDetail{}; topicDetail := TopicDetail{};
if len(slot.Channel.Topics) > 0 { if len(slot.Channel.Topics) > 0 {
topicDetail.Guid = slot.Channel.Topics[0].Guid; topicDetail.GUID = slot.Channel.Topics[0].GUID;
topicDetail.DataType = slot.Channel.Topics[0].DataType; topicDetail.DataType = slot.Channel.Topics[0].DataType;
topicDetail.Data = slot.Channel.Topics[0].Data; topicDetail.Data = slot.Channel.Topics[0].Data;
topicDetail.Created = slot.Channel.Topics[0].Created; topicDetail.Created = slot.Channel.Topics[0].Created;
@ -224,13 +224,13 @@ func getChannelModel(slot *store.ChannelSlot, showData bool, showList bool) *Cha
if !showData || slot.Channel == nil { if !showData || slot.Channel == nil {
return &Channel{ return &Channel{
Id: slot.ChannelSlotId, ID: slot.ChannelSlotID,
Revision: slot.Revision, Revision: slot.Revision,
} }
} }
return &Channel{ return &Channel{
Id: slot.ChannelSlotId, ID: slot.ChannelSlotID,
Revision: slot.Revision, Revision: slot.Revision,
Data: &ChannelData { Data: &ChannelData {
DetailRevision: slot.Channel.DetailRevision, DetailRevision: slot.Channel.DetailRevision,
@ -245,13 +245,13 @@ func getTopicRevisionModel(slot *store.TopicSlot) *Topic {
if slot.Topic == nil { if slot.Topic == nil {
return &Topic{ return &Topic{
Id: slot.TopicSlotId, ID: slot.TopicSlotID,
Revision: slot.Revision, Revision: slot.Revision,
} }
} }
return &Topic{ return &Topic{
Id: slot.TopicSlotId, ID: slot.TopicSlotID,
Revision: slot.Revision, Revision: slot.Revision,
Data: &TopicData { Data: &TopicData {
DetailRevision: slot.Topic.DetailRevision, DetailRevision: slot.Topic.DetailRevision,
@ -276,7 +276,7 @@ func getTopicDetailModel(slot *store.TopicSlot) *TopicDetail {
} }
return &TopicDetail{ return &TopicDetail{
Guid: slot.Topic.Guid, GUID: slot.Topic.GUID,
DataType: slot.Topic.DataType, DataType: slot.Topic.DataType,
Data: slot.Topic.Data, Data: slot.Topic.Data,
Created: slot.Topic.Created, Created: slot.Topic.Created,
@ -290,13 +290,13 @@ func getTopicModel(slot *store.TopicSlot) *Topic {
if slot.Topic == nil { if slot.Topic == nil {
return &Topic{ return &Topic{
Id: slot.TopicSlotId, ID: slot.TopicSlotID,
Revision: slot.Revision, Revision: slot.Revision,
} }
} }
return &Topic{ return &Topic{
Id: slot.TopicSlotId, ID: slot.TopicSlotID,
Revision: slot.Revision, Revision: slot.Revision,
Data: &TopicData { Data: &TopicData {
DetailRevision: slot.Topic.DetailRevision, DetailRevision: slot.Topic.DetailRevision,
@ -310,16 +310,16 @@ func getTagModel(slot *store.TagSlot) *Tag {
if slot.Tag == nil { if slot.Tag == nil {
return &Tag{ return &Tag{
Id: slot.TagSlotId, ID: slot.TagSlotID,
Revision: slot.Revision, Revision: slot.Revision,
} }
} }
return &Tag{ return &Tag{
Id: slot.TagSlotId, ID: slot.TagSlotID,
Revision: slot.Revision, Revision: slot.Revision,
Data: &TagData{ Data: &TagData{
Guid: slot.Tag.Guid, GUID: slot.Tag.GUID,
DataType: slot.Tag.DataType, DataType: slot.Tag.DataType,
Data: slot.Tag.Data, Data: slot.Tag.Data,
Created: slot.Tag.Created, Created: slot.Tag.Created,

View File

@ -2,9 +2,9 @@ package databag
type AccountProfile struct { type AccountProfile struct {
AccountId uint32 `json:"accountId"` AccountID uint32 `json:"accountID"`
Guid string `json:"guid"` GUID string `json:"guid"`
Handle string `json:"handle,omitempty"` Handle string `json:"handle,omitempty"`
@ -39,7 +39,7 @@ type Announce struct {
type App struct { type App struct {
Id string `json:"id"` ID string `json:"id"`
Revision int64 `json:"revision"` Revision int64 `json:"revision"`
@ -61,7 +61,7 @@ type AppData struct {
type Article struct { type Article struct {
Id string `json:"id"` ID string `json:"id"`
Revision int64 `json:"revision"` Revision int64 `json:"revision"`
@ -78,7 +78,7 @@ type ArticleData struct {
Updated int64 `json:"updated"` Updated int64 `json:"updated"`
Groups *IdList `json:"groups,omitempty"` Groups *IDList `json:"groups,omitempty"`
} }
type ArticleGroups struct { type ArticleGroups struct {
@ -88,7 +88,7 @@ type ArticleGroups struct {
type Asset struct { type Asset struct {
AssetId string `json:"assetId"` AssetID string `json:"assetID"`
Transform string `json:"transform,omitempty"` Transform string `json:"transform,omitempty"`
@ -97,7 +97,7 @@ type Asset struct {
type Card struct { type Card struct {
Id string `json:"id"` ID string `json:"id"`
Revision int64 `json:"revision"` Revision int64 `json:"revision"`
@ -136,7 +136,7 @@ type CardDetail struct {
type CardProfile struct { type CardProfile struct {
Guid string `json:"guid"` GUID string `json:"guid"`
Handle string `json:"handle,omitempty"` Handle string `json:"handle,omitempty"`
@ -162,7 +162,7 @@ type ChannelContacts struct {
type Channel struct { type Channel struct {
Id string `json:"id"` ID string `json:"id"`
Revision int64 `json:"revision"` Revision int64 `json:"revision"`
@ -280,7 +280,7 @@ type Disconnect struct {
type Group struct { type Group struct {
Id string `json:"id"` ID string `json:"id"`
Revision int64 `json:"revision"` Revision int64 `json:"revision"`
@ -317,9 +317,9 @@ type Identity struct {
Node string `json:"node"` Node string `json:"node"`
} }
type IdList struct { type IDList struct {
Ids []string `json:"ids"` IDs []string `json:"ids"`
} }
type LoginAccess struct { type LoginAccess struct {
@ -342,7 +342,7 @@ type NodeConfig struct {
type Profile struct { type Profile struct {
Guid string `json:"guid"` GUID string `json:"guid"`
Handle string `json:"handle,omitempty"` Handle string `json:"handle,omitempty"`
@ -387,7 +387,7 @@ type Revision struct {
type SignedData struct { type SignedData struct {
Guid string `json:"guid"` GUID string `json:"guid"`
Timestamp int64 `json:"timestamp"` Timestamp int64 `json:"timestamp"`
@ -405,7 +405,7 @@ type Subject struct {
type Tag struct { type Tag struct {
Id string `json:"id"` ID string `json:"id"`
Revision int64 `json:"revision"` Revision int64 `json:"revision"`
@ -414,7 +414,7 @@ type Tag struct {
type TagData struct { type TagData struct {
Guid string `json:"guid"` GUID string `json:"guid"`
DataType string `json:"dataType"` DataType string `json:"dataType"`
@ -427,7 +427,7 @@ type TagData struct {
type Topic struct { type Topic struct {
Id string `json:"id"` ID string `json:"id"`
Revision int64 `json:"revision"` Revision int64 `json:"revision"`
@ -445,7 +445,7 @@ type TopicData struct {
type TopicDetail struct { type TopicDetail struct {
Guid string `json:"guid"` GUID string `json:"guid"`
DataType string `json:"dataType"` DataType string `json:"dataType"`

View File

@ -101,7 +101,7 @@ func SendRemoteNotification(notification *store.Notification) {
ErrMsg(err); ErrMsg(err);
return return
} }
url := "https://" + notification.Node + "/contact/" + module + "/revision?contact=" + notification.Guid + "." + notification.Token url := "https://" + notification.Node + "/contact/" + module + "/revision?contact=" + notification.GUID + "." + notification.Token
req, err := http.NewRequest(http.MethodPut, url, bytes.NewBuffer(body)) req, err := http.NewRequest(http.MethodPut, url, bytes.NewBuffer(body))
if err != nil { if err != nil {
ErrMsg(err) ErrMsg(err)
@ -123,7 +123,7 @@ func SetProfileNotification(account *store.Account) {
// select all connected cards // select all connected cards
var cards []store.Card var cards []store.Card
if err := store.DB.Where("account_id = ? AND status = ?", account.Guid, APP_CARDCONNECTED).Find(&cards).Error; err != nil { if err := store.DB.Where("account_id = ? AND status = ?", account.GUID, APP_CARDCONNECTED).Find(&cards).Error; err != nil {
ErrMsg(err) ErrMsg(err)
return return
} }
@ -134,7 +134,7 @@ func SetProfileNotification(account *store.Account) {
notification := &store.Notification{ notification := &store.Notification{
Node: card.Node, Node: card.Node,
Module: APP_NOTIFYPROFILE, Module: APP_NOTIFYPROFILE,
Guid: card.Guid, GUID: card.GUID,
Token: card.OutToken, Token: card.OutToken,
Revision: account.ProfileRevision, Revision: account.ProfileRevision,
} }
@ -163,7 +163,7 @@ func SetContactArticleNotification(account *store.Account, card *store.Card) {
notification := &store.Notification{ notification := &store.Notification{
Node: card.Node, Node: card.Node,
Module: APP_NOTIFYARTICLE, Module: APP_NOTIFYARTICLE,
Guid: card.Guid, GUID: card.GUID,
Token: card.OutToken, Token: card.OutToken,
Revision: account.ArticleRevision, Revision: account.ArticleRevision,
} }
@ -188,7 +188,7 @@ func SetContactViewNotification(account *store.Account, card *store.Card) {
notification := &store.Notification{ notification := &store.Notification{
Node: card.Node, Node: card.Node,
Module: APP_NOTIFYVIEW, Module: APP_NOTIFYVIEW,
Guid: card.Guid, GUID: card.GUID,
Token: card.OutToken, Token: card.OutToken,
Revision: card.ViewRevision, Revision: card.ViewRevision,
} }
@ -212,7 +212,7 @@ func SetContactChannelNotification(account *store.Account, card *store.Card) {
notification := &store.Notification{ notification := &store.Notification{
Node: card.Node, Node: card.Node,
Module: APP_NOTIFYCHANNEL, Module: APP_NOTIFYCHANNEL,
Guid: card.Guid, GUID: card.GUID,
Token: card.OutToken, Token: card.OutToken,
Revision: account.ChannelRevision, Revision: account.ChannelRevision,
} }

View File

@ -77,7 +77,7 @@ var routes = Routes{
Route{ Route{
"GetAccountAsset", "GetAccountAsset",
strings.ToUpper("Get"), strings.ToUpper("Get"),
"/account/assets/{assetId}", "/account/assets/{assetID}",
GetAccountAsset, GetAccountAsset,
}, },
@ -140,7 +140,7 @@ var routes = Routes{
Route{ Route{
"RemoveAccountApp", "RemoveAccountApp",
strings.ToUpper("Delete"), strings.ToUpper("Delete"),
"/account/apps/{appId}", "/account/apps/{appID}",
RemoveAccountApp, RemoveAccountApp,
}, },
@ -196,21 +196,21 @@ var routes = Routes{
Route{ Route{
"GetNodeAccountImage", "GetNodeAccountImage",
strings.ToUpper("Get"), strings.ToUpper("Get"),
"/admin/accounts/{accountId}/image", "/admin/accounts/{accountID}/image",
GetNodeAccountImage, GetNodeAccountImage,
}, },
Route{ Route{
"SetNodeAccountStatus", "SetNodeAccountStatus",
strings.ToUpper("Put"), strings.ToUpper("Put"),
"/admin/accounts/{accountId}/status", "/admin/accounts/{accountID}/status",
SetNodeAccountStatus, SetNodeAccountStatus,
}, },
Route{ Route{
"AddNodeAccountAccess", "AddNodeAccountAccess",
strings.ToUpper("Post"), strings.ToUpper("Post"),
"/admin/accounts/{accountId}/auth", "/admin/accounts/{accountID}/auth",
AddNodeAccountAccess, AddNodeAccountAccess,
}, },
@ -245,14 +245,14 @@ var routes = Routes{
Route{ Route{
"RemoveNodeAccount", "RemoveNodeAccount",
strings.ToUpper("Delete"), strings.ToUpper("Delete"),
"/admin/accounts/{accountId}", "/admin/accounts/{accountID}",
RemoveNodeAccount, RemoveNodeAccount,
}, },
Route{ Route{
"SetNodeAccount", "SetNodeAccount",
strings.ToUpper("Put"), strings.ToUpper("Put"),
"/admin/accounts/{accountId}/reset", "/admin/accounts/{accountID}/reset",
SetNodeAccount, SetNodeAccount,
}, },
@ -280,7 +280,7 @@ var routes = Routes{
Route{ Route{
"GetGroupSubjectField", "GetGroupSubjectField",
strings.ToUpper("Get"), strings.ToUpper("Get"),
"/alias/groups/{groupId}/subject/{field}", "/alias/groups/{groupID}/subject/{field}",
GetGroupSubjectField, GetGroupSubjectField,
}, },
@ -294,14 +294,14 @@ var routes = Routes{
Route{ Route{
"RemoveGroup", "RemoveGroup",
strings.ToUpper("Delete"), strings.ToUpper("Delete"),
"/alias/groups/{groupId}", "/alias/groups/{groupID}",
RemoveGroup, RemoveGroup,
}, },
Route{ Route{
"SetGroupSubject", "SetGroupSubject",
strings.ToUpper("Put"), strings.ToUpper("Put"),
"/alias/groups/{groupId}/subject", "/alias/groups/{groupID}/subject",
SetGroupSubject, SetGroupSubject,
}, },
@ -315,14 +315,14 @@ var routes = Routes{
Route{ Route{
"ClearArticleGroup", "ClearArticleGroup",
strings.ToUpper("Delete"), strings.ToUpper("Delete"),
"/attribute/articles/{articleId}/groups/{groupId}", "/attribute/articles/{articleID}/groups/{groupID}",
ClearArticleGroup, ClearArticleGroup,
}, },
Route{ Route{
"GetArticleSubjectField", "GetArticleSubjectField",
strings.ToUpper("Get"), strings.ToUpper("Get"),
"/attribute/articles/{articleId}/subject/{field}", "/attribute/articles/{articleID}/subject/{field}",
GetArticleSubjectField, GetArticleSubjectField,
}, },
@ -336,21 +336,21 @@ var routes = Routes{
Route{ Route{
"RemoveArticle", "RemoveArticle",
strings.ToUpper("Delete"), strings.ToUpper("Delete"),
"/attribute/articles/{articleId}", "/attribute/articles/{articleID}",
RemoveArticle, RemoveArticle,
}, },
Route{ Route{
"SetArticleGroup", "SetArticleGroup",
strings.ToUpper("Put"), strings.ToUpper("Put"),
"/attribute/articles/{articleId}/groups/{groupId}", "/attribute/articles/{articleID}/groups/{groupID}",
SetArticleGroup, SetArticleGroup,
}, },
Route{ Route{
"SetArticleSubject", "SetArticleSubject",
strings.ToUpper("Put"), strings.ToUpper("Put"),
"/attribute/articles/{articleId}/subject", "/attribute/articles/{articleID}/subject",
SetArticleSubject, SetArticleSubject,
}, },
@ -371,35 +371,35 @@ var routes = Routes{
Route{ Route{
"ClearCardGroup", "ClearCardGroup",
strings.ToUpper("Delete"), strings.ToUpper("Delete"),
"/contact/cards/{cardId}/groups/{groupId}", "/contact/cards/{cardID}/groups/{groupID}",
ClearCardGroup, ClearCardGroup,
}, },
Route{ Route{
"ClearCardNotes", "ClearCardNotes",
strings.ToUpper("Delete"), strings.ToUpper("Delete"),
"/contact/cards/{cardId}/notes", "/contact/cards/{cardID}/notes",
ClearCardNotes, ClearCardNotes,
}, },
Route{ Route{
"GetCardDetail", "GetCardDetail",
strings.ToUpper("Get"), strings.ToUpper("Get"),
"/contact/cards/{cardId}/detail", "/contact/cards/{cardID}/detail",
GetCardDetail, GetCardDetail,
}, },
Route{ Route{
"GetCardProfile", "GetCardProfile",
strings.ToUpper("Get"), strings.ToUpper("Get"),
"/contact/cards/{cardId}/profile", "/contact/cards/{cardID}/profile",
GetCardProfile, GetCardProfile,
}, },
Route{ Route{
"GetCardProfileImage", "GetCardProfileImage",
strings.ToUpper("Get"), strings.ToUpper("Get"),
"/contact/cards/{cardId}/profile/image", "/contact/cards/{cardID}/profile/image",
GetCardProfileImage, GetCardProfileImage,
}, },
@ -413,21 +413,21 @@ var routes = Routes{
Route{ Route{
"GetCloseMessage", "GetCloseMessage",
strings.ToUpper("Get"), strings.ToUpper("Get"),
"/contact/cards/{cardId}/closeMessage", "/contact/cards/{cardID}/closeMessage",
GetCloseMessage, GetCloseMessage,
}, },
Route{ Route{
"GetOpenMessage", "GetOpenMessage",
strings.ToUpper("Get"), strings.ToUpper("Get"),
"/contact/cards/{cardId}/openMessage", "/contact/cards/{cardID}/openMessage",
GetOpenMessage, GetOpenMessage,
}, },
Route{ Route{
"RemoveCard", "RemoveCard",
strings.ToUpper("Delete"), strings.ToUpper("Delete"),
"/contact/cards/{cardId}", "/contact/cards/{cardID}",
RemoveCard, RemoveCard,
}, },
@ -441,28 +441,28 @@ var routes = Routes{
Route{ Route{
"SetCardGroup", "SetCardGroup",
strings.ToUpper("Put"), strings.ToUpper("Put"),
"/contact/cards/{cardId}/groups/{groupId}", "/contact/cards/{cardID}/groups/{groupID}",
SetCardGroup, SetCardGroup,
}, },
Route{ Route{
"SetCardNotes", "SetCardNotes",
strings.ToUpper("Put"), strings.ToUpper("Put"),
"/contact/cards/{cardId}/notes", "/contact/cards/{cardID}/notes",
SetCardNotes, SetCardNotes,
}, },
Route{ Route{
"SetCardProfile", "SetCardProfile",
strings.ToUpper("Put"), strings.ToUpper("Put"),
"/contact/cards/{cardId}/profile", "/contact/cards/{cardID}/profile",
SetCardProfile, SetCardProfile,
}, },
Route{ Route{
"SetCardStatus", "SetCardStatus",
strings.ToUpper("Put"), strings.ToUpper("Put"),
"/contact/cards/{cardId}/status", "/contact/cards/{cardID}/status",
SetCardStatus, SetCardStatus,
}, },
@ -511,112 +511,112 @@ var routes = Routes{
Route{ Route{
"AddChannelTopicAsset", "AddChannelTopicAsset",
strings.ToUpper("Post"), strings.ToUpper("Post"),
"/content/channels/{channelId}/topics/{topicId}/assets", "/content/channels/{channelID}/topics/{topicID}/assets",
AddChannelTopicAsset, AddChannelTopicAsset,
}, },
Route{ Route{
"AddChannelTopic", "AddChannelTopic",
strings.ToUpper("Post"), strings.ToUpper("Post"),
"/content/channels/{channelId}/topics", "/content/channels/{channelID}/topics",
AddChannelTopic, AddChannelTopic,
}, },
Route{ Route{
"AddChannelTopicTag", "AddChannelTopicTag",
strings.ToUpper("Post"), strings.ToUpper("Post"),
"/content/channels/{channelId}/topics/{topicId}/tags", "/content/channels/{channelID}/topics/{topicID}/tags",
AddChannelTopicTag, AddChannelTopicTag,
}, },
Route{ Route{
"ClearChannelCard", "ClearChannelCard",
strings.ToUpper("Delete"), strings.ToUpper("Delete"),
"/content/channels/{channelId}/cards/{cardId}", "/content/channels/{channelID}/cards/{cardID}",
ClearChannelCard, ClearChannelCard,
}, },
Route{ Route{
"ClearChannelGroup", "ClearChannelGroup",
strings.ToUpper("Delete"), strings.ToUpper("Delete"),
"/content/channels/{channelId}/groups/{groupId}", "/content/channels/{channelID}/groups/{groupID}",
ClearChannelGroup, ClearChannelGroup,
}, },
Route{ Route{
"GetChannelTopicAsset", "GetChannelTopicAsset",
strings.ToUpper("Get"), strings.ToUpper("Get"),
"/content/channels/{channelId}/topics/{topicId}/assets/{assetId}", "/content/channels/{channelID}/topics/{topicID}/assets/{assetID}",
GetChannelTopicAsset, GetChannelTopicAsset,
}, },
Route{ Route{
"GetChannelTopicAssets", "GetChannelTopicAssets",
strings.ToUpper("Get"), strings.ToUpper("Get"),
"/content/channels/{channelId}/topics/{topicId}/assets", "/content/channels/{channelID}/topics/{topicID}/assets",
GetChannelTopicAssets, GetChannelTopicAssets,
}, },
Route{ Route{
"GetChannelDetail", "GetChannelDetail",
strings.ToUpper("Get"), strings.ToUpper("Get"),
"/content/channels/{channelId}/detail", "/content/channels/{channelID}/detail",
GetChannelDetail, GetChannelDetail,
}, },
Route{ Route{
"GetChannelSummary", "GetChannelSummary",
strings.ToUpper("Get"), strings.ToUpper("Get"),
"/content/channels/{channelId}/summary", "/content/channels/{channelID}/summary",
GetChannelSummary, GetChannelSummary,
}, },
Route{ Route{
"GetChannelSubjectField", "GetChannelSubjectField",
strings.ToUpper("Get"), strings.ToUpper("Get"),
"/content/channels/{channelId}/subject/{field}", "/content/channels/{channelID}/subject/{field}",
GetChannelSubjectField, GetChannelSubjectField,
}, },
Route{ Route{
"GetChannelTopic", "GetChannelTopic",
strings.ToUpper("Get"), strings.ToUpper("Get"),
"/content/channels/{channelId}/topics/{topicId}/detail", "/content/channels/{channelID}/topics/{topicID}/detail",
GetChannelTopic, GetChannelTopic,
}, },
Route{ Route{
"GetChannelTopicDetail", "GetChannelTopicDetail",
strings.ToUpper("Get"), strings.ToUpper("Get"),
"/content/channels/{channelId}/topics/{topicId}/detail", "/content/channels/{channelID}/topics/{topicID}/detail",
GetChannelTopicDetail, GetChannelTopicDetail,
}, },
Route{ Route{
"GetChannelTopicSubjectField", "GetChannelTopicSubjectField",
strings.ToUpper("Get"), strings.ToUpper("Get"),
"/content/channels/{channelId}/topics/{topicId}/subject/{field}", "/content/channels/{channelID}/topics/{topicID}/subject/{field}",
GetChannelTopicSubjectField, GetChannelTopicSubjectField,
}, },
Route{ Route{
"GetChannelTopicTagSubjectField", "GetChannelTopicTagSubjectField",
strings.ToUpper("Get"), strings.ToUpper("Get"),
"/content/channels/{channelId}/topics/{topicId}/tags/{tagId}/subject/{field}", "/content/channels/{channelID}/topics/{topicID}/tags/{tagID}/subject/{field}",
GetChannelTopicTagSubjectField, GetChannelTopicTagSubjectField,
}, },
Route{ Route{
"GetChannelTopicTags", "GetChannelTopicTags",
strings.ToUpper("Get"), strings.ToUpper("Get"),
"/content/channels/{channelId}/topics/{topicId}/tags", "/content/channels/{channelID}/topics/{topicID}/tags",
GetChannelTopicTags, GetChannelTopicTags,
}, },
Route{ Route{
"GetChannelTopics", "GetChannelTopics",
strings.ToUpper("Get"), strings.ToUpper("Get"),
"/content/channels/{channelId}/topics", "/content/channels/{channelID}/topics",
GetChannelTopics, GetChannelTopics,
}, },
@ -630,70 +630,70 @@ var routes = Routes{
Route{ Route{
"RemoveChannel", "RemoveChannel",
strings.ToUpper("Delete"), strings.ToUpper("Delete"),
"/content/channels/{channelId}", "/content/channels/{channelID}",
RemoveChannel, RemoveChannel,
}, },
Route{ Route{
"RemoveChannelTopicAsset", "RemoveChannelTopicAsset",
strings.ToUpper("Delete"), strings.ToUpper("Delete"),
"/content/channels/{channelId}/topics/{topicId}/assets/{assetId}", "/content/channels/{channelID}/topics/{topicID}/assets/{assetID}",
RemoveChannelTopicAsset, RemoveChannelTopicAsset,
}, },
Route{ Route{
"RemoveChannelTopic", "RemoveChannelTopic",
strings.ToUpper("Delete"), strings.ToUpper("Delete"),
"/content/channels/{channelId}/topics/{topicId}", "/content/channels/{channelID}/topics/{topicID}",
RemoveChannelTopic, RemoveChannelTopic,
}, },
Route{ Route{
"RemoveChannelTopicTag", "RemoveChannelTopicTag",
strings.ToUpper("Delete"), strings.ToUpper("Delete"),
"/content/channels/{channelId}/topics/{topicId}/tags/{tagId}", "/content/channels/{channelID}/topics/{topicID}/tags/{tagID}",
RemoveChannelTopicTag, RemoveChannelTopicTag,
}, },
Route{ Route{
"SetChannelCard", "SetChannelCard",
strings.ToUpper("Put"), strings.ToUpper("Put"),
"/content/channels/{channelId}/cards/{cardId}", "/content/channels/{channelID}/cards/{cardID}",
SetChannelCard, SetChannelCard,
}, },
Route{ Route{
"SetChannelTopicConfirmed", "SetChannelTopicConfirmed",
strings.ToUpper("Put"), strings.ToUpper("Put"),
"/content/channels/{channelId}/topics/{topicId}/confirmed", "/content/channels/{channelID}/topics/{topicID}/confirmed",
SetChannelTopicConfirmed, SetChannelTopicConfirmed,
}, },
Route{ Route{
"SetChannelGroup", "SetChannelGroup",
strings.ToUpper("Put"), strings.ToUpper("Put"),
"/content/channels/{channelId}/groups/{groupId}", "/content/channels/{channelID}/groups/{groupID}",
SetChannelGroup, SetChannelGroup,
}, },
Route{ Route{
"SetChannelSubject", "SetChannelSubject",
strings.ToUpper("Put"), strings.ToUpper("Put"),
"/content/channels/{channelId}/subject", "/content/channels/{channelID}/subject",
SetChannelSubject, SetChannelSubject,
}, },
Route{ Route{
"SetChannelTopicSubject", "SetChannelTopicSubject",
strings.ToUpper("Put"), strings.ToUpper("Put"),
"/content/channels/{channelId}/topics/{topicId}/subject", "/content/channels/{channelID}/topics/{topicID}/subject",
SetChannelTopicSubject, SetChannelTopicSubject,
}, },
Route{ Route{
"SetChannelTopicTagSubject", "SetChannelTopicTagSubject",
strings.ToUpper("Put"), strings.ToUpper("Put"),
"/content/channels/{channelId}/topics/{topicId}/tags/{tagId}/subject", "/content/channels/{channelID}/topics/{topicID}/tags/{tagID}/subject",
SetChannelTopicTagSubject, SetChannelTopicTagSubject,
}, },

View File

@ -27,7 +27,7 @@ func AutoMigrate(db *gorm.DB) {
type Notification struct { type Notification struct {
ID uint `gorm:"primaryKey;not null;unique;autoIncrement"` ID uint `gorm:"primaryKey;not null;unique;autoIncrement"`
Node string `gorm:"not null"` Node string `gorm:"not null"`
Guid string `gorm:"not null"` GUID string `gorm:"not null"`
Module string `gorm:"not null"` Module string `gorm:"not null"`
Token string `gorm:"not null"` Token string `gorm:"not null"`
Revision int64 `gorm:"not null"` Revision int64 `gorm:"not null"`
@ -35,7 +35,7 @@ type Notification struct {
type Config struct { type Config struct {
ID uint `gorm:"primaryKey;not null;unique;autoIncrement"` ID uint `gorm:"primaryKey;not null;unique;autoIncrement"`
ConfigId string `gorm:"not null;uniqueIndex"` ConfigID string `gorm:"not null;uniqueIndex"`
StrValue string StrValue string
NumValue int64 NumValue int64
BoolValue bool BoolValue bool
@ -55,7 +55,7 @@ type AccountToken struct {
type Account struct { type Account struct {
ID uint `gorm:"primaryKey;not null;unique;autoIncrement"` ID uint `gorm:"primaryKey;not null;unique;autoIncrement"`
AccountDetailID uint `gorm:"not null"` AccountDetailID uint `gorm:"not null"`
Guid string `gorm:"not null;uniqueIndex"` GUID string `gorm:"not null;uniqueIndex"`
Username string `gorm:"not null;uniqueIndex"` Username string `gorm:"not null;uniqueIndex"`
Handle string `gorm:"uniqueIndex"` Handle string `gorm:"uniqueIndex"`
Password []byte `gorm:"not null"` Password []byte `gorm:"not null"`
@ -94,12 +94,12 @@ type App struct {
Url string Url string
Token string `gorm:"not null;index:appguid,unique"` Token string `gorm:"not null;index:appguid,unique"`
Created int64 `gorm:"autoCreateTime"` Created int64 `gorm:"autoCreateTime"`
Account Account `gorm:"references:Guid"` Account Account `gorm:"references:GUID"`
} }
type GroupSlot struct { type GroupSlot struct {
ID uint ID uint
GroupSlotId string `gorm:"not null;index:groupslot,unique"` GroupSlotID string `gorm:"not null;index:groupslot,unique"`
AccountID uint `gorm:"not null;index:groupslot,unique"` AccountID uint `gorm:"not null;index:groupslot,unique"`
Revision int64 `gorm:"not null"` Revision int64 `gorm:"not null"`
GroupID uint `gorm:"not null;default:0"` GroupID uint `gorm:"not null;default:0"`
@ -129,7 +129,7 @@ type GroupData struct {
type CardSlot struct { type CardSlot struct {
ID uint `gorm:"primaryKey;not null;unique;autoIncrement"` ID uint `gorm:"primaryKey;not null;unique;autoIncrement"`
CardSlotId string `gorm:"not null;index:cardslot,unique"` CardSlotID string `gorm:"not null;index:cardslot,unique"`
AccountID uint `gorm:"not null;index:cardslot,unique"` AccountID uint `gorm:"not null;index:cardslot,unique"`
Revision int64 `gorm:"not null"` Revision int64 `gorm:"not null"`
CardID uint `gorm:"not null;default:0"` CardID uint `gorm:"not null;default:0"`
@ -140,7 +140,7 @@ type CardSlot struct {
type Card struct { type Card struct {
ID uint `gorm:"primaryKey;not null;unique;autoIncrement"` ID uint `gorm:"primaryKey;not null;unique;autoIncrement"`
AccountID string `gorm:"not null;index:cardguid,unique"` AccountID string `gorm:"not null;index:cardguid,unique"`
Guid string `gorm:"not null;index:cardguid,unique"` GUID string `gorm:"not null;index:cardguid,unique"`
Username string Username string
Name string Name string
Description string Description string
@ -161,7 +161,7 @@ type Card struct {
NotifiedArticle int64 NotifiedArticle int64
NotifiedChannel int64 NotifiedChannel int64
NotifiedProfile int64 NotifiedProfile int64
Account Account `gorm:"references:Guid"` Account Account `gorm:"references:GUID"`
Groups []Group `gorm:"many2many:card_groups"` Groups []Group `gorm:"many2many:card_groups"`
Channels []Channel `gorm:"many2many:channel_cards"` Channels []Channel `gorm:"many2many:channel_cards"`
CardSlot CardSlot CardSlot CardSlot
@ -169,7 +169,7 @@ type Card struct {
type ArticleSlot struct { type ArticleSlot struct {
ID uint `gorm:"primaryKey;not null;unique;autoIncrement"` ID uint `gorm:"primaryKey;not null;unique;autoIncrement"`
ArticleSlotId string `gorm:"not null;index:articleslot,unique"` ArticleSlotID string `gorm:"not null;index:articleslot,unique"`
AccountID uint `gorm:"not null;index:articleslot,unique"` AccountID uint `gorm:"not null;index:articleslot,unique"`
Revision int64 `gorm:"not null"` Revision int64 `gorm:"not null"`
ArticleID uint `gorm:"not null;default:0"` ArticleID uint `gorm:"not null;default:0"`
@ -190,7 +190,7 @@ type Article struct {
type ChannelSlot struct { type ChannelSlot struct {
ID uint ID uint
ChannelSlotId string `gorm:"not null;index:channelslot,unique"` ChannelSlotID string `gorm:"not null;index:channelslot,unique"`
AccountID uint `gorm:"not null;index:channelslot,unique"` AccountID uint `gorm:"not null;index:channelslot,unique"`
Revision int64 `gorm:"not null"` Revision int64 `gorm:"not null"`
ChannelID uint `gorm:"not null;default:0"` ChannelID uint `gorm:"not null;default:0"`
@ -215,7 +215,7 @@ type Channel struct {
type TopicSlot struct { type TopicSlot struct {
ID uint ID uint
TopicSlotId string `gorm:"not null;index:topicaccount,unique;index:topicchannel,unique"` TopicSlotID string `gorm:"not null;index:topicaccount,unique;index:topicchannel,unique"`
AccountID uint `gorm:"not null;index:topicaccount,unique"` AccountID uint `gorm:"not null;index:topicaccount,unique"`
ChannelID uint `gorm:"not null;index:topicchannel,unique"` ChannelID uint `gorm:"not null;index:topicchannel,unique"`
Revision int64 `gorm:"not null"` Revision int64 `gorm:"not null"`
@ -230,7 +230,7 @@ type Topic struct {
AccountID uint AccountID uint
ChannelID uint ChannelID uint
TopicSlotID uint `gorm:"not null;index:topictopicslot,unique"` TopicSlotID uint `gorm:"not null;index:topictopicslot,unique"`
Guid string GUID string
DataType string `gorm:"index"` DataType string `gorm:"index"`
Data string Data string
Status string `gorm:"not null;index"` Status string `gorm:"not null;index"`
@ -246,7 +246,7 @@ type Topic struct {
type Asset struct { type Asset struct {
ID uint `gorm:"primaryKey;not null;unique;autoIncrement"` ID uint `gorm:"primaryKey;not null;unique;autoIncrement"`
AssetId string `gorm:"not null;index:asset,unique"` AssetID string `gorm:"not null;index:asset,unique"`
AccountID uint `gorm:"not null;index:asset,unique"` AccountID uint `gorm:"not null;index:asset,unique"`
ChannelID uint ChannelID uint
TopicID uint TopicID uint
@ -254,7 +254,7 @@ type Asset struct {
Size int64 Size int64
Crc uint32 Crc uint32
Transform string Transform string
TransformId string TransformID string
TransformParams string TransformParams string
TransformQueue string TransformQueue string
Created int64 `gorm:"autoCreateTime"` Created int64 `gorm:"autoCreateTime"`
@ -266,7 +266,7 @@ type Asset struct {
type TagSlot struct { type TagSlot struct {
ID uint ID uint
TagSlotId string `gorm:"not null;index:tagslot,unique"` TagSlotID string `gorm:"not null;index:tagslot,unique"`
AccountID uint `gorm:"not null;index:tagslot,unique"` AccountID uint `gorm:"not null;index:tagslot,unique"`
ChannelID uint `gorm:"not null"` ChannelID uint `gorm:"not null"`
TopicID uint `gorm:"not null;index:tagtopic"` TopicID uint `gorm:"not null;index:tagtopic"`
@ -283,7 +283,7 @@ type Tag struct {
AccountID uint AccountID uint
ChannelID uint `gorm:"not null;index:channeltag"` ChannelID uint `gorm:"not null;index:channeltag"`
TopicID uint `gorm:"not null;index:topictag"` TopicID uint `gorm:"not null;index:topictag"`
Guid string `gorm:"not null"` GUID string `gorm:"not null"`
DataType string `gorm:"index"` DataType string `gorm:"index"`
Data string Data string
Created int64 `gorm:"autoCreateTime"` Created int64 `gorm:"autoCreateTime"`

View File

@ -108,16 +108,16 @@ func (c *TestContactData) UpdateContact() (err error) {
func (c *TestContactData) UpdateContactProfile() (err error) { func (c *TestContactData) UpdateContactProfile() (err error) {
var msg DataMessage var msg DataMessage
token := c.card.Data.CardProfile.Guid + "." + c.card.Data.CardDetail.Token token := c.card.Data.CardProfile.GUID + "." + c.card.Data.CardDetail.Token
params := &TestApiParams{ query: "/profile/message", tokenType: APP_TOKENCONTACT, token: token } params := &TestAPIParams{ query: "/profile/message", tokenType: APP_TOKENCONTACT, token: token }
response := &TestApiResponse{ data: &msg } response := &TestAPIResponse{ data: &msg }
if err = TestApiRequest(GetProfileMessage, params, response); err != nil { if err = TestAPIRequest(GetProfileMessage, params, response); err != nil {
return return
} }
params = &TestApiParams{ restType: "PUT", query: "/contact/cards/{cardId}/profile", tokenType: APP_TOKENAGENT, token: c.token, params = &TestAPIParams{ restType: "PUT", query: "/contact/cards/{cardID}/profile", tokenType: APP_TOKENAGENT, token: c.token,
path: map[string]string{ "cardId": c.card.Id }, body: &msg } path: map[string]string{ "cardID": c.card.ID }, body: &msg }
response = &TestApiResponse{} response = &TestAPIResponse{}
if err = TestApiRequest(SetCardProfile, params, response); err != nil { if err = TestAPIRequest(SetCardProfile, params, response); err != nil {
return return
} }
return return
@ -126,29 +126,29 @@ func (c *TestContactData) UpdateContactProfile() (err error) {
func (c *TestContactData) UpdateContactArticle() (err error) { func (c *TestContactData) UpdateContactArticle() (err error) {
var articles []Article var articles []Article
if c.articleRevision == 0 || c.viewRevision != c.card.Data.NotifiedView { if c.articleRevision == 0 || c.viewRevision != c.card.Data.NotifiedView {
token := c.card.Data.CardProfile.Guid + "." + c.card.Data.CardDetail.Token token := c.card.Data.CardProfile.GUID + "." + c.card.Data.CardDetail.Token
params := &TestApiParams{ query: "/articles", tokenType: APP_TOKENCONTACT, token: token } params := &TestAPIParams{ query: "/articles", tokenType: APP_TOKENCONTACT, token: token }
response := &TestApiResponse{ data: &articles } response := &TestAPIResponse{ data: &articles }
if err = TestApiRequest(GetArticles, params, response); err != nil { if err = TestAPIRequest(GetArticles, params, response); err != nil {
return return
} }
c.articles = make(map[string]*Article) c.articles = make(map[string]*Article)
} else { } else {
token := c.card.Data.CardProfile.Guid + "." + c.card.Data.CardDetail.Token token := c.card.Data.CardProfile.GUID + "." + c.card.Data.CardDetail.Token
viewRevision := strconv.FormatInt(c.viewRevision, 10) viewRevision := strconv.FormatInt(c.viewRevision, 10)
articleRevision := strconv.FormatInt(c.articleRevision, 10) articleRevision := strconv.FormatInt(c.articleRevision, 10)
params := &TestApiParams{ query: "/articles?articleRevision=" + articleRevision + "&viewRevision=" + viewRevision, params := &TestAPIParams{ query: "/articles?articleRevision=" + articleRevision + "&viewRevision=" + viewRevision,
tokenType: APP_TOKENCONTACT, token: token } tokenType: APP_TOKENCONTACT, token: token }
response := &TestApiResponse{ data: &articles } response := &TestAPIResponse{ data: &articles }
if err = TestApiRequest(GetArticles, params, response); err != nil { if err = TestAPIRequest(GetArticles, params, response); err != nil {
return return
} }
} }
for _, article := range articles { for _, article := range articles {
if article.Data == nil { if article.Data == nil {
delete(c.articles, article.Id) delete(c.articles, article.ID)
} else { } else {
c.articles[article.Id] = &article c.articles[article.ID] = &article
} }
} }
return nil return nil
@ -157,29 +157,29 @@ func (c *TestContactData) UpdateContactArticle() (err error) {
func (c *TestContactData) UpdateContactChannels() (err error) { func (c *TestContactData) UpdateContactChannels() (err error) {
var channels []Channel var channels []Channel
if c.channelRevision == 0 || c.viewRevision != c.card.Data.NotifiedView { if c.channelRevision == 0 || c.viewRevision != c.card.Data.NotifiedView {
token := c.card.Data.CardProfile.Guid + "." + c.card.Data.CardDetail.Token token := c.card.Data.CardProfile.GUID + "." + c.card.Data.CardDetail.Token
params := &TestApiParams{ query: "/channels", tokenType: APP_TOKENCONTACT, token: token } params := &TestAPIParams{ query: "/channels", tokenType: APP_TOKENCONTACT, token: token }
response := &TestApiResponse{ data: &channels } response := &TestAPIResponse{ data: &channels }
if err = TestApiRequest(GetChannels, params, response); err != nil { if err = TestAPIRequest(GetChannels, params, response); err != nil {
return return
} }
} else { } else {
token := c.card.Data.CardProfile.Guid + "." + c.card.Data.CardDetail.Token token := c.card.Data.CardProfile.GUID + "." + c.card.Data.CardDetail.Token
viewRevision := strconv.FormatInt(c.viewRevision, 10) viewRevision := strconv.FormatInt(c.viewRevision, 10)
channelRevision := strconv.FormatInt(c.channelRevision, 10) channelRevision := strconv.FormatInt(c.channelRevision, 10)
params := &TestApiParams{ query: "/channels?channelRevision=" + channelRevision + "&viewRevision=" + viewRevision, params := &TestAPIParams{ query: "/channels?channelRevision=" + channelRevision + "&viewRevision=" + viewRevision,
tokenType: APP_TOKENCONTACT, token: token } tokenType: APP_TOKENCONTACT, token: token }
response := &TestApiResponse{ data: &channels } response := &TestAPIResponse{ data: &channels }
if err = TestApiRequest(GetChannels, params, response); err != nil { if err = TestAPIRequest(GetChannels, params, response); err != nil {
return return
} }
} }
for _, channel := range channels { for _, channel := range channels {
if channel.Data == nil { if channel.Data == nil {
delete(c.channels, channel.Id) delete(c.channels, channel.ID)
} else { } else {
tc, set := c.channels[channel.Id] tc, set := c.channels[channel.ID]
if set { if set {
if channel.Revision != tc.channel.Revision { if channel.Revision != tc.channel.Revision {
if err = c.UpdateContactChannel(tc, &channel); err != nil { if err = c.UpdateContactChannel(tc, &channel); err != nil {
@ -188,8 +188,8 @@ func (c *TestContactData) UpdateContactChannels() (err error) {
tc.channel.Revision = channel.Revision tc.channel.Revision = channel.Revision
} }
} else { } else {
tc := &TestChannel{ channel: Channel{ Id: channel.Id, Data: &ChannelData{} } } tc := &TestChannel{ channel: Channel{ ID: channel.ID, Data: &ChannelData{} } }
c.channels[channel.Id] = tc c.channels[channel.ID] = tc
if err = c.UpdateContactChannel(tc, &channel); err != nil { if err = c.UpdateContactChannel(tc, &channel); err != nil {
return return
} }
@ -212,12 +212,12 @@ func (c *TestContactData) UpdateContactChannel(storeChannel *TestChannel, channe
storeChannel.channel.Data.ChannelDetail = channel.Data.ChannelDetail storeChannel.channel.Data.ChannelDetail = channel.Data.ChannelDetail
storeChannel.channel.Data.DetailRevision = channel.Data.DetailRevision storeChannel.channel.Data.DetailRevision = channel.Data.DetailRevision
} else if storeChannel.channel.Data.DetailRevision != channel.Data.DetailRevision { } else if storeChannel.channel.Data.DetailRevision != channel.Data.DetailRevision {
token := c.card.Data.CardProfile.Guid + "." + c.card.Data.CardDetail.Token token := c.card.Data.CardProfile.GUID + "." + c.card.Data.CardDetail.Token
params := &TestApiParams{ query: "/channel/{channelId}", path: map[string]string{ "channelId": channel.Id }, params := &TestAPIParams{ query: "/channel/{channelID}", path: map[string]string{ "channelID": channel.ID },
tokenType: APP_TOKENCONTACT, token: token } tokenType: APP_TOKENCONTACT, token: token }
detail := &ChannelDetail{} detail := &ChannelDetail{}
response := &TestApiResponse{ data: &detail } response := &TestAPIResponse{ data: &detail }
if err = TestApiRequest(GetChannelDetail, params, response); err != nil { if err = TestAPIRequest(GetChannelDetail, params, response); err != nil {
return return
} }
if channel.Data == nil { if channel.Data == nil {
@ -234,30 +234,30 @@ func (c *TestContactData) UpdateContactChannel(storeChannel *TestChannel, channe
func (c *TestContactData) UpdateContactChannelTopics(storeChannel *TestChannel) (err error) { func (c *TestContactData) UpdateContactChannelTopics(storeChannel *TestChannel) (err error) {
var topics []Topic var topics []Topic
if storeChannel.channel.Revision == 0 { if storeChannel.channel.Revision == 0 {
token := c.card.Data.CardProfile.Guid + "." + c.card.Data.CardDetail.Token token := c.card.Data.CardProfile.GUID + "." + c.card.Data.CardDetail.Token
params := &TestApiParams{ query: "/channels/{channelId}/topics", params := &TestAPIParams{ query: "/channels/{channelID}/topics",
path: map[string]string{ "channelId": storeChannel.channel.Id }, tokenType: APP_TOKENCONTACT, token: token } path: map[string]string{ "channelID": storeChannel.channel.ID }, tokenType: APP_TOKENCONTACT, token: token }
response := &TestApiResponse{ data: &topics } response := &TestAPIResponse{ data: &topics }
if err = TestApiRequest(GetChannelTopics, params, response); err != nil { if err = TestAPIRequest(GetChannelTopics, params, response); err != nil {
return return
} }
storeChannel.topics = make(map[string]*TestTopic) storeChannel.topics = make(map[string]*TestTopic)
} else { } else {
token := c.card.Data.CardProfile.Guid + "." + c.card.Data.CardDetail.Token token := c.card.Data.CardProfile.GUID + "." + c.card.Data.CardDetail.Token
revision := strconv.FormatInt(storeChannel.channel.Revision, 10) revision := strconv.FormatInt(storeChannel.channel.Revision, 10)
params := &TestApiParams{ query: "/channels/{channelId}/topics?revision=" + revision, params := &TestAPIParams{ query: "/channels/{channelID}/topics?revision=" + revision,
path: map[string]string{ "channelId": storeChannel.channel.Id }, tokenType: APP_TOKENCONTACT, token: token } path: map[string]string{ "channelID": storeChannel.channel.ID }, tokenType: APP_TOKENCONTACT, token: token }
response := &TestApiResponse{ data: &topics } response := &TestAPIResponse{ data: &topics }
if err = TestApiRequest(GetChannelTopics, params, response); err != nil { if err = TestAPIRequest(GetChannelTopics, params, response); err != nil {
return return
} }
} }
for _, topic := range topics { for _, topic := range topics {
if topic.Data == nil { if topic.Data == nil {
delete(storeChannel.topics, topic.Id) delete(storeChannel.topics, topic.ID)
} else { } else {
storeTopic, set := storeChannel.topics[topic.Id] storeTopic, set := storeChannel.topics[topic.ID]
if set { if set {
if topic.Revision != storeTopic.topic.Revision { if topic.Revision != storeTopic.topic.Revision {
if err = c.UpdateContactChannelTopic(storeChannel, storeTopic, &topic); err != nil { if err = c.UpdateContactChannelTopic(storeChannel, storeTopic, &topic); err != nil {
@ -266,8 +266,8 @@ func (c *TestContactData) UpdateContactChannelTopics(storeChannel *TestChannel)
storeTopic.topic.Revision = topic.Revision storeTopic.topic.Revision = topic.Revision
} }
} else { } else {
storeTopic := &TestTopic{ topic: Topic{ Id: topic.Id, Data: &TopicData{} } } storeTopic := &TestTopic{ topic: Topic{ ID: topic.ID, Data: &TopicData{} } }
storeChannel.topics[topic.Id] = storeTopic storeChannel.topics[topic.ID] = storeTopic
if err = c.UpdateContactChannelTopic(storeChannel, storeTopic, &topic); err != nil { if err = c.UpdateContactChannelTopic(storeChannel, storeTopic, &topic); err != nil {
return return
} }
@ -290,13 +290,13 @@ func (c *TestContactData) UpdateContactChannelTopic(storeChannel *TestChannel, s
storeTopic.topic.Data.TopicDetail = topic.Data.TopicDetail storeTopic.topic.Data.TopicDetail = topic.Data.TopicDetail
storeTopic.topic.Data.DetailRevision = topic.Data.DetailRevision storeTopic.topic.Data.DetailRevision = topic.Data.DetailRevision
} else if storeTopic.topic.Data.DetailRevision != topic.Data.DetailRevision { } else if storeTopic.topic.Data.DetailRevision != topic.Data.DetailRevision {
token := c.card.Data.CardProfile.Guid + "." + c.card.Data.CardDetail.Token token := c.card.Data.CardProfile.GUID + "." + c.card.Data.CardDetail.Token
params := &TestApiParams{ query: "/channels/{channelId}/topics/{topicId}", params := &TestAPIParams{ query: "/channels/{channelID}/topics/{topicID}",
path: map[string]string{ "channelId": storeChannel.channel.Id, "topicId": topic.Id }, path: map[string]string{ "channelID": storeChannel.channel.ID, "topicID": topic.ID },
tokenType: APP_TOKENCONTACT, token: token } tokenType: APP_TOKENCONTACT, token: token }
topic := Topic{} topic := Topic{}
response := &TestApiResponse{ data: &topic } response := &TestAPIResponse{ data: &topic }
if err = TestApiRequest(GetChannelTopic, params, response); err != nil { if err = TestAPIRequest(GetChannelTopic, params, response); err != nil {
return return
} }
if topic.Data == nil { if topic.Data == nil {
@ -313,32 +313,32 @@ func (c *TestContactData) UpdateContactChannelTopic(storeChannel *TestChannel, s
func (c *TestContactData) UpdateContactChannelTopicTags(storeChannel *TestChannel, storeTopic *TestTopic) (err error) { func (c *TestContactData) UpdateContactChannelTopicTags(storeChannel *TestChannel, storeTopic *TestTopic) (err error) {
var tags []Tag var tags []Tag
if storeTopic.topic.Revision == 0 { if storeTopic.topic.Revision == 0 {
token := c.card.Data.CardProfile.Guid + "." + c.card.Data.CardDetail.Token token := c.card.Data.CardProfile.GUID + "." + c.card.Data.CardDetail.Token
params := &TestApiParams{ query: "/channels/{channelId}/topics/{topicId}/tags", params := &TestAPIParams{ query: "/channels/{channelID}/topics/{topicID}/tags",
path: map[string]string{ "channelId": storeChannel.channel.Id, "topicId": storeTopic.topic.Id }, path: map[string]string{ "channelID": storeChannel.channel.ID, "topicID": storeTopic.topic.ID },
tokenType: APP_TOKENCONTACT, token: token } tokenType: APP_TOKENCONTACT, token: token }
response := &TestApiResponse{ data: &tags } response := &TestAPIResponse{ data: &tags }
if err = TestApiRequest(GetChannelTopicTags, params, response); err != nil { if err = TestAPIRequest(GetChannelTopicTags, params, response); err != nil {
return return
} }
storeTopic.tags = make(map[string]*Tag) storeTopic.tags = make(map[string]*Tag)
} else { } else {
revision := strconv.FormatInt(storeTopic.topic.Revision, 10) revision := strconv.FormatInt(storeTopic.topic.Revision, 10)
token := c.card.Data.CardProfile.Guid + "." + c.card.Data.CardDetail.Token token := c.card.Data.CardProfile.GUID + "." + c.card.Data.CardDetail.Token
params := &TestApiParams{ query: "/channels/{channelId}/topics/{topicId}/tags?revision=" + revision, params := &TestAPIParams{ query: "/channels/{channelID}/topics/{topicID}/tags?revision=" + revision,
path: map[string]string{ "channelId": storeChannel.channel.Id, "topicId": storeTopic.topic.Id }, path: map[string]string{ "channelID": storeChannel.channel.ID, "topicID": storeTopic.topic.ID },
tokenType: APP_TOKENCONTACT, token: token } tokenType: APP_TOKENCONTACT, token: token }
response := &TestApiResponse{ data: &tags } response := &TestAPIResponse{ data: &tags }
if err = TestApiRequest(GetChannelTopicTags, params, response); err != nil { if err = TestAPIRequest(GetChannelTopicTags, params, response); err != nil {
return return
} }
} }
for _, tag := range tags { for _, tag := range tags {
if tag.Data == nil { if tag.Data == nil {
delete(storeTopic.tags, tag.Id) delete(storeTopic.tags, tag.ID)
} else { } else {
storeTopic.tags[tag.Id] = &tag storeTopic.tags[tag.ID] = &tag
} }
} }
return return
@ -346,10 +346,10 @@ func (c *TestContactData) UpdateContactChannelTopicTags(storeChannel *TestChanne
func (c *TestContactData) UpdateContactCardDetail() (err error) { func (c *TestContactData) UpdateContactCardDetail() (err error) {
var cardDetail CardDetail var cardDetail CardDetail
params := &TestApiParams{ query: "/contact/cards/{cardId}/detail", tokenType: APP_TOKENAGENT, token: c.token, params := &TestAPIParams{ query: "/contact/cards/{cardID}/detail", tokenType: APP_TOKENAGENT, token: c.token,
path: map[string]string{ "cardId": c.card.Id } } path: map[string]string{ "cardID": c.card.ID } }
response := &TestApiResponse{ data: &cardDetail } response := &TestAPIResponse{ data: &cardDetail }
if err = TestApiRequest(GetCardDetail, params, response); err != nil { if err = TestAPIRequest(GetCardDetail, params, response); err != nil {
return return
} }
c.card.Data.CardDetail = &cardDetail c.card.Data.CardDetail = &cardDetail
@ -358,10 +358,10 @@ func (c *TestContactData) UpdateContactCardDetail() (err error) {
func (c *TestContactData) UpdateContactCardProfile() (err error) { func (c *TestContactData) UpdateContactCardProfile() (err error) {
var cardProfile CardProfile var cardProfile CardProfile
params := &TestApiParams{ query: "/contact/cards/{cardId}/profile", tokenType: APP_TOKENAGENT, token: c.token, params := &TestAPIParams{ query: "/contact/cards/{cardID}/profile", tokenType: APP_TOKENAGENT, token: c.token,
path: map[string]string{ "cardId": c.card.Id } } path: map[string]string{ "cardID": c.card.ID } }
response := &TestApiResponse{ data: &cardProfile } response := &TestAPIResponse{ data: &cardProfile }
if err = TestApiRequest(GetCardProfile, params, response); err != nil { if err = TestAPIRequest(GetCardProfile, params, response); err != nil {
return return
} }
c.card.Data.CardProfile = &cardProfile c.card.Data.CardProfile = &cardProfile
@ -393,33 +393,33 @@ type TestApp struct {
} }
func (a *TestApp) UpdateProfile() (err error) { func (a *TestApp) UpdateProfile() (err error) {
params := &TestApiParams{ query: "/profile", tokenType: APP_TOKENAGENT, token: a.token } params := &TestAPIParams{ query: "/profile", tokenType: APP_TOKENAGENT, token: a.token }
response := &TestApiResponse{ data: &a.profile } response := &TestAPIResponse{ data: &a.profile }
err = TestApiRequest(GetProfile, params, response) err = TestAPIRequest(GetProfile, params, response)
return return
} }
func (a *TestApp) UpdateGroups() (err error) { func (a *TestApp) UpdateGroups() (err error) {
var groups []Group var groups []Group
if a.revision.Group == 0 { if a.revision.Group == 0 {
params := &TestApiParams{ query: "/groups", tokenType: APP_TOKENAGENT, token: a.token } params := &TestAPIParams{ query: "/groups", tokenType: APP_TOKENAGENT, token: a.token }
response := &TestApiResponse{ data: &groups } response := &TestAPIResponse{ data: &groups }
if err = TestApiRequest(GetGroups, params, response); err != nil { if err = TestAPIRequest(GetGroups, params, response); err != nil {
return return
} }
} else { } else {
revision := strconv.FormatInt(a.revision.Group, 10) revision := strconv.FormatInt(a.revision.Group, 10)
params := &TestApiParams{ query: "/groups?revision=" + revision, tokenType: APP_TOKENAGENT, token: a.token } params := &TestAPIParams{ query: "/groups?revision=" + revision, tokenType: APP_TOKENAGENT, token: a.token }
response := &TestApiResponse{ data: &groups } response := &TestAPIResponse{ data: &groups }
if err = TestApiRequest(GetGroups, params, response); err != nil { if err = TestAPIRequest(GetGroups, params, response); err != nil {
return return
} }
} }
for _, group := range groups { for _, group := range groups {
if group.Data == nil { if group.Data == nil {
delete(a.groups, group.Id) delete(a.groups, group.ID)
} else { } else {
a.groups[group.Id] = &group a.groups[group.ID] = &group
} }
} }
return return
@ -428,24 +428,24 @@ func (a *TestApp) UpdateGroups() (err error) {
func (a *TestApp) UpdateArticles() (err error) { func (a *TestApp) UpdateArticles() (err error) {
var articles []Article var articles []Article
if a.revision.Article == 0 { if a.revision.Article == 0 {
params := &TestApiParams{ query: "/articles", tokenType: APP_TOKENAGENT, token: a.token } params := &TestAPIParams{ query: "/articles", tokenType: APP_TOKENAGENT, token: a.token }
response := &TestApiResponse{ data: &articles } response := &TestAPIResponse{ data: &articles }
if err = TestApiRequest(GetArticles, params, response); err != nil { if err = TestAPIRequest(GetArticles, params, response); err != nil {
return return
} }
} else { } else {
revision := strconv.FormatInt(a.revision.Article, 10) revision := strconv.FormatInt(a.revision.Article, 10)
params := &TestApiParams{ query: "/articles?articleRevision=" + revision, tokenType: APP_TOKENAGENT, token: a.token } params := &TestAPIParams{ query: "/articles?articleRevision=" + revision, tokenType: APP_TOKENAGENT, token: a.token }
response := &TestApiResponse{ data: &articles } response := &TestAPIResponse{ data: &articles }
if err = TestApiRequest(GetArticles, params, response); err != nil { if err = TestAPIRequest(GetArticles, params, response); err != nil {
return return
} }
} }
for _, article := range articles { for _, article := range articles {
if article.Data == nil { if article.Data == nil {
delete(a.articles, article.Id) delete(a.articles, article.ID)
} else { } else {
a.articles[article.Id] = &article a.articles[article.ID] = &article
} }
} }
return return
@ -454,25 +454,25 @@ func (a *TestApp) UpdateArticles() (err error) {
func (a *TestApp) UpdateChannels() (err error) { func (a *TestApp) UpdateChannels() (err error) {
var channels []Channel var channels []Channel
if a.revision.Channel == 0 { if a.revision.Channel == 0 {
params := &TestApiParams{ query: "/channels", tokenType: APP_TOKENAGENT, token: a.token } params := &TestAPIParams{ query: "/channels", tokenType: APP_TOKENAGENT, token: a.token }
response := &TestApiResponse{ data: &channels } response := &TestAPIResponse{ data: &channels }
if err = TestApiRequest(GetChannels, params, response); err != nil { if err = TestAPIRequest(GetChannels, params, response); err != nil {
return return
} }
} else { } else {
revision := strconv.FormatInt(a.revision.Channel, 10) revision := strconv.FormatInt(a.revision.Channel, 10)
params := &TestApiParams{ query: "/channels?channelRevision=" + revision, tokenType: APP_TOKENAGENT, token: a.token } params := &TestAPIParams{ query: "/channels?channelRevision=" + revision, tokenType: APP_TOKENAGENT, token: a.token }
response := &TestApiResponse{ data: &channels } response := &TestAPIResponse{ data: &channels }
if err = TestApiRequest(GetChannels, params, response); err != nil { if err = TestAPIRequest(GetChannels, params, response); err != nil {
return return
} }
} }
for _, channel := range channels { for _, channel := range channels {
if channel.Data == nil { if channel.Data == nil {
delete(a.channels, channel.Id) delete(a.channels, channel.ID)
} else { } else {
storeChannel, set := a.channels[channel.Id] storeChannel, set := a.channels[channel.ID]
if set { if set {
if channel.Revision != storeChannel.channel.Revision { if channel.Revision != storeChannel.channel.Revision {
if err = a.UpdateChannel(storeChannel, &channel); err != nil { if err = a.UpdateChannel(storeChannel, &channel); err != nil {
@ -481,8 +481,8 @@ func (a *TestApp) UpdateChannels() (err error) {
storeChannel.channel.Revision = channel.Revision storeChannel.channel.Revision = channel.Revision
} }
} else { } else {
storeChannel := &TestChannel{ channel: Channel{ Id: channel.Id, Data: &ChannelData{} } } storeChannel := &TestChannel{ channel: Channel{ ID: channel.ID, Data: &ChannelData{} } }
a.channels[channel.Id] = storeChannel a.channels[channel.ID] = storeChannel
if err = a.UpdateChannel(storeChannel, &channel); err != nil { if err = a.UpdateChannel(storeChannel, &channel); err != nil {
return return
} }
@ -505,11 +505,11 @@ func (a *TestApp) UpdateChannel(storeChannel *TestChannel, channel *Channel) (er
storeChannel.channel.Data.ChannelDetail = channel.Data.ChannelDetail storeChannel.channel.Data.ChannelDetail = channel.Data.ChannelDetail
storeChannel.channel.Data.DetailRevision = channel.Data.DetailRevision storeChannel.channel.Data.DetailRevision = channel.Data.DetailRevision
} else if storeChannel.channel.Data.DetailRevision != channel.Data.DetailRevision { } else if storeChannel.channel.Data.DetailRevision != channel.Data.DetailRevision {
params := &TestApiParams{ query: "/channel/{channelId}", path: map[string]string{ "channelId": channel.Id }, params := &TestAPIParams{ query: "/channel/{channelID}", path: map[string]string{ "channelID": channel.ID },
tokenType: APP_TOKENAGENT, token: a.token } tokenType: APP_TOKENAGENT, token: a.token }
detail := &ChannelDetail{} detail := &ChannelDetail{}
response := &TestApiResponse{ data: &detail } response := &TestAPIResponse{ data: &detail }
if err = TestApiRequest(GetChannelDetail, params, response); err != nil { if err = TestAPIRequest(GetChannelDetail, params, response); err != nil {
return return
} }
if channel.Data == nil { if channel.Data == nil {
@ -526,28 +526,28 @@ func (a *TestApp) UpdateChannel(storeChannel *TestChannel, channel *Channel) (er
func (a *TestApp) UpdateChannelTopics(storeChannel *TestChannel) (err error) { func (a *TestApp) UpdateChannelTopics(storeChannel *TestChannel) (err error) {
var topics []Topic var topics []Topic
if storeChannel.channel.Revision == 0 { if storeChannel.channel.Revision == 0 {
params := &TestApiParams{ query: "/channels/{channelId}/topics", params := &TestAPIParams{ query: "/channels/{channelID}/topics",
path: map[string]string{ "channelId": storeChannel.channel.Id }, tokenType: APP_TOKENAGENT, token: a.token } path: map[string]string{ "channelID": storeChannel.channel.ID }, tokenType: APP_TOKENAGENT, token: a.token }
response := &TestApiResponse{ data: &topics } response := &TestAPIResponse{ data: &topics }
if err = TestApiRequest(GetChannelTopics, params, response); err != nil { if err = TestAPIRequest(GetChannelTopics, params, response); err != nil {
return return
} }
storeChannel.topics = make(map[string]*TestTopic) storeChannel.topics = make(map[string]*TestTopic)
} else { } else {
revision := strconv.FormatInt(storeChannel.channel.Revision, 10) revision := strconv.FormatInt(storeChannel.channel.Revision, 10)
params := &TestApiParams{ query: "/channels/{channelId}/topics?revision=" + revision, params := &TestAPIParams{ query: "/channels/{channelID}/topics?revision=" + revision,
path: map[string]string{ "channelId": storeChannel.channel.Id }, tokenType: APP_TOKENAGENT, token: a.token } path: map[string]string{ "channelID": storeChannel.channel.ID }, tokenType: APP_TOKENAGENT, token: a.token }
response := &TestApiResponse{ data: &topics } response := &TestAPIResponse{ data: &topics }
if err = TestApiRequest(GetChannelTopics, params, response); err != nil { if err = TestAPIRequest(GetChannelTopics, params, response); err != nil {
return return
} }
} }
for _, topic := range topics { for _, topic := range topics {
if topic.Data == nil { if topic.Data == nil {
delete(storeChannel.topics, topic.Id) delete(storeChannel.topics, topic.ID)
} else { } else {
storeTopic, set := storeChannel.topics[topic.Id] storeTopic, set := storeChannel.topics[topic.ID]
if set { if set {
if topic.Revision != storeTopic.topic.Revision { if topic.Revision != storeTopic.topic.Revision {
if err = a.UpdateChannelTopic(storeChannel, storeTopic, &topic); err != nil { if err = a.UpdateChannelTopic(storeChannel, storeTopic, &topic); err != nil {
@ -556,8 +556,8 @@ func (a *TestApp) UpdateChannelTopics(storeChannel *TestChannel) (err error) {
storeTopic.topic.Revision = topic.Revision storeTopic.topic.Revision = topic.Revision
} }
} else { } else {
storeTopic := &TestTopic{ topic: Topic{ Id: topic.Id, Data: &TopicData{} } } storeTopic := &TestTopic{ topic: Topic{ ID: topic.ID, Data: &TopicData{} } }
storeChannel.topics[topic.Id] = storeTopic storeChannel.topics[topic.ID] = storeTopic
if err = a.UpdateChannelTopic(storeChannel, storeTopic, &topic); err != nil { if err = a.UpdateChannelTopic(storeChannel, storeTopic, &topic); err != nil {
return return
} }
@ -580,12 +580,12 @@ func (a *TestApp) UpdateChannelTopic(storeChannel *TestChannel, storeTopic *Test
storeTopic.topic.Data.TopicDetail = topic.Data.TopicDetail storeTopic.topic.Data.TopicDetail = topic.Data.TopicDetail
storeTopic.topic.Data.DetailRevision = topic.Data.DetailRevision storeTopic.topic.Data.DetailRevision = topic.Data.DetailRevision
} else if storeTopic.topic.Data.DetailRevision != topic.Data.DetailRevision { } else if storeTopic.topic.Data.DetailRevision != topic.Data.DetailRevision {
params := &TestApiParams{ query: "/channels/{channelId}/topics/{topicId}", params := &TestAPIParams{ query: "/channels/{channelID}/topics/{topicID}",
path: map[string]string{ "channelId": storeChannel.channel.Id, "topicId": topic.Id }, path: map[string]string{ "channelID": storeChannel.channel.ID, "topicID": topic.ID },
tokenType: APP_TOKENAGENT, token: a.token } tokenType: APP_TOKENAGENT, token: a.token }
topic := Topic{} topic := Topic{}
response := &TestApiResponse{ data: &topic } response := &TestAPIResponse{ data: &topic }
if err = TestApiRequest(GetChannelTopic, params, response); err != nil { if err = TestAPIRequest(GetChannelTopic, params, response); err != nil {
return return
} }
if topic.Data == nil { if topic.Data == nil {
@ -602,30 +602,30 @@ func (a *TestApp) UpdateChannelTopic(storeChannel *TestChannel, storeTopic *Test
func (a *TestApp) UpdateChannelTopicTags(storeChannel *TestChannel, storeTopic *TestTopic) (err error) { func (a *TestApp) UpdateChannelTopicTags(storeChannel *TestChannel, storeTopic *TestTopic) (err error) {
var tags []Tag var tags []Tag
if storeTopic.topic.Revision == 0 { if storeTopic.topic.Revision == 0 {
params := &TestApiParams{ query: "/channels/{channelId}/topics/{topicId}/tags", params := &TestAPIParams{ query: "/channels/{channelID}/topics/{topicID}/tags",
path: map[string]string{ "channelId": storeChannel.channel.Id, "topicId": storeTopic.topic.Id }, path: map[string]string{ "channelID": storeChannel.channel.ID, "topicID": storeTopic.topic.ID },
tokenType: APP_TOKENAGENT, token: a.token } tokenType: APP_TOKENAGENT, token: a.token }
response := &TestApiResponse{ data: &tags } response := &TestAPIResponse{ data: &tags }
if err = TestApiRequest(GetChannelTopicTags, params, response); err != nil { if err = TestAPIRequest(GetChannelTopicTags, params, response); err != nil {
return return
} }
storeTopic.tags = make(map[string]*Tag) storeTopic.tags = make(map[string]*Tag)
} else { } else {
revision := strconv.FormatInt(storeTopic.topic.Revision, 10) revision := strconv.FormatInt(storeTopic.topic.Revision, 10)
params := &TestApiParams{ query: "/channels/{channelId}/topics/{topicId}/tags?revision=" + revision, params := &TestAPIParams{ query: "/channels/{channelID}/topics/{topicID}/tags?revision=" + revision,
path: map[string]string{ "channelId": storeChannel.channel.Id, "topicId": storeTopic.topic.Id }, path: map[string]string{ "channelID": storeChannel.channel.ID, "topicID": storeTopic.topic.ID },
tokenType: APP_TOKENAGENT, token: a.token } tokenType: APP_TOKENAGENT, token: a.token }
response := &TestApiResponse{ data: &tags } response := &TestAPIResponse{ data: &tags }
if err = TestApiRequest(GetChannelTopicTags, params, response); err != nil { if err = TestAPIRequest(GetChannelTopicTags, params, response); err != nil {
return return
} }
} }
for _, tag := range tags { for _, tag := range tags {
if tag.Data == nil { if tag.Data == nil {
delete(storeTopic.tags, tag.Id) delete(storeTopic.tags, tag.ID)
} else { } else {
storeTopic.tags[tag.Id] = &tag storeTopic.tags[tag.ID] = &tag
} }
} }
return return
@ -634,20 +634,20 @@ func (a *TestApp) UpdateChannelTopicTags(storeChannel *TestChannel, storeTopic *
func (a *TestApp) UpdateCards() (err error) { func (a *TestApp) UpdateCards() (err error) {
var cards []Card var cards []Card
if a.revision.Card == 0 { if a.revision.Card == 0 {
params := &TestApiParams{ query: "/cards", tokenType: APP_TOKENAGENT, token: a.token } params := &TestAPIParams{ query: "/cards", tokenType: APP_TOKENAGENT, token: a.token }
response := &TestApiResponse{ data: &cards } response := &TestAPIResponse{ data: &cards }
if err = TestApiRequest(GetCards, params, response); err != nil { if err = TestAPIRequest(GetCards, params, response); err != nil {
return return
} }
for _, card := range cards { for _, card := range cards {
if card.Data == nil { if card.Data == nil {
delete(a.contacts, card.Id) delete(a.contacts, card.ID)
} else { } else {
// set new card // set new card
contactData := &TestContactData{ card: card, articles: make(map[string]*Article), channels: make(map[string]*TestChannel), contactData := &TestContactData{ card: card, articles: make(map[string]*Article), channels: make(map[string]*TestChannel),
cardDetailRevision: card.Data.DetailRevision, cardProfileRevision: card.Data.ProfileRevision, cardDetailRevision: card.Data.DetailRevision, cardProfileRevision: card.Data.ProfileRevision,
profileRevision: card.Data.ProfileRevision, token: a.token } profileRevision: card.Data.ProfileRevision, token: a.token }
a.contacts[card.Id] = contactData a.contacts[card.ID] = contactData
if err = contactData.UpdateContact(); err != nil { if err = contactData.UpdateContact(); err != nil {
contactData.offsync = true contactData.offsync = true
PrintMsg(err) PrintMsg(err)
@ -656,28 +656,28 @@ func (a *TestApp) UpdateCards() (err error) {
} }
} else { } else {
revision := strconv.FormatInt(a.revision.Card, 10) revision := strconv.FormatInt(a.revision.Card, 10)
params := &TestApiParams{ query: "/cards?revision=" + revision, tokenType: APP_TOKENAGENT, token: a.token } params := &TestAPIParams{ query: "/cards?revision=" + revision, tokenType: APP_TOKENAGENT, token: a.token }
response := &TestApiResponse{ data: &cards } response := &TestAPIResponse{ data: &cards }
if err = TestApiRequest(GetCards, params, response); err != nil { if err = TestAPIRequest(GetCards, params, response); err != nil {
return return
} }
for _, card := range cards { for _, card := range cards {
if card.Data == nil { if card.Data == nil {
delete(a.contacts, card.Id) delete(a.contacts, card.ID)
} else { } else {
contactData, set := a.contacts[card.Id] contactData, set := a.contacts[card.ID]
if !set { if !set {
// download new card // download new card
params := &TestApiParams{ query: "/cards/{cardId}", path: map[string]string{ "cardId": card.Id }, params := &TestAPIParams{ query: "/cards/{cardID}", path: map[string]string{ "cardID": card.ID },
tokenType: APP_TOKENAGENT, token: a.token } tokenType: APP_TOKENAGENT, token: a.token }
response := &TestApiResponse{ data: &card } response := &TestAPIResponse{ data: &card }
if err = TestApiRequest(GetCard, params, response); err != nil { if err = TestAPIRequest(GetCard, params, response); err != nil {
return return
} }
contactData := &TestContactData{ card: card, articles: make(map[string]*Article), channels: make(map[string]*TestChannel), contactData := &TestContactData{ card: card, articles: make(map[string]*Article), channels: make(map[string]*TestChannel),
cardDetailRevision: card.Data.DetailRevision, cardProfileRevision: card.Data.ProfileRevision, cardDetailRevision: card.Data.DetailRevision, cardProfileRevision: card.Data.ProfileRevision,
profileRevision: card.Data.ProfileRevision, token: a.token } profileRevision: card.Data.ProfileRevision, token: a.token }
a.contacts[card.Id] = contactData a.contacts[card.ID] = contactData
if err = contactData.UpdateContact(); err != nil { if err = contactData.UpdateContact(); err != nil {
contactData.offsync = true contactData.offsync = true
PrintMsg(err) PrintMsg(err)
@ -825,7 +825,7 @@ func (a *TestApp) WaitFor(check func(*TestApp) bool) error {
/*** endpoint test function ***/ /*** endpoint test function ***/
type TestApiParams struct { type TestAPIParams struct {
restType string restType string
path map[string]string path map[string]string
query string query string
@ -836,13 +836,13 @@ type TestApiParams struct {
credentials string credentials string
} }
type TestApiResponse struct { type TestAPIResponse struct {
code int code int
data interface{} data interface{}
header map[string][]string header map[string][]string
} }
func TestApiRequest(endpoint func(http.ResponseWriter, *http.Request), params *TestApiParams, resp *TestApiResponse) (err error) { func TestAPIRequest(endpoint func(http.ResponseWriter, *http.Request), params *TestAPIParams, resp *TestAPIResponse) (err error) {
var r *http.Request var r *http.Request
var w *httptest.ResponseRecorder var w *httptest.ResponseRecorder

View File

@ -20,14 +20,14 @@ const test_ReadDeadline = 2
const test_RevisionWait = 100 const test_RevisionWait = 100
type TestCard struct { type TestCard struct {
Guid string GUID string
Token string Token string
CardId string CardID string
GroupId string GroupID string
} }
type TestContact struct { type TestContact struct {
Guid string GUID string
Token string Token string
Revisions chan *Revision Revisions chan *Revision
A TestCard A TestCard
@ -55,7 +55,7 @@ func GetTestRevision(status chan *Revision) (rev *Revision) {
} }
} }
func ApiTestData( func APITestData(
endpoint func(http.ResponseWriter, *http.Request), endpoint func(http.ResponseWriter, *http.Request),
requestType string, requestType string,
name string, name string,
@ -112,7 +112,7 @@ func ApiTestData(
return return
} }
func ApiTestMsg( func APITestMsg(
endpoint func(http.ResponseWriter, *http.Request), endpoint func(http.ResponseWriter, *http.Request),
requestType string, requestType string,
name string, name string,
@ -173,7 +173,7 @@ func ApiTestMsg(
return return
} }
func ApiTestUpload( func APITestUpload(
endpoint func(http.ResponseWriter, *http.Request), endpoint func(http.ResponseWriter, *http.Request),
requestType string, requestType string,
name string, name string,
@ -260,110 +260,110 @@ func AddTestGroup(prefix string) (*TestGroup, error) {
// allocate contacts // allocate contacts
g := &TestGroup{} g := &TestGroup{}
if g.A.Guid, g.A.Token, err = AddTestAccount(prefix+"A"); err != nil { if g.A.GUID, g.A.Token, err = AddTestAccount(prefix+"A"); err != nil {
return g, err return g, err
} }
if g.B.Guid, g.B.Token, err = AddTestAccount(prefix+"B"); err != nil { if g.B.GUID, g.B.Token, err = AddTestAccount(prefix+"B"); err != nil {
return g, err return g, err
} }
if g.C.Guid, g.C.Token, err = AddTestAccount(prefix+"C"); err != nil { if g.C.GUID, g.C.Token, err = AddTestAccount(prefix+"C"); err != nil {
return g, err return g, err
} }
if g.D.Guid, g.D.Token, err = AddTestAccount(prefix+"D"); err != nil { if g.D.GUID, g.D.Token, err = AddTestAccount(prefix+"D"); err != nil {
return g, err return g, err
} }
// setup A // setup A
if g.A.B.CardId, err = AddTestCard(g.A.Token, g.B.Token); err != nil { if g.A.B.CardID, err = AddTestCard(g.A.Token, g.B.Token); err != nil {
return g, err return g, err
} }
if err = OpenTestCard(g.A.Token, g.A.B.CardId); err != nil { if err = OpenTestCard(g.A.Token, g.A.B.CardID); err != nil {
return g, err return g, err
} }
if g.A.B.GroupId, err = GroupTestCard(g.A.Token, g.A.B.CardId); err != nil { if g.A.B.GroupID, err = GroupTestCard(g.A.Token, g.A.B.CardID); err != nil {
return g, err return g, err
} }
if g.A.C.CardId, err = AddTestCard(g.A.Token, g.C.Token); err != nil { if g.A.C.CardID, err = AddTestCard(g.A.Token, g.C.Token); err != nil {
return g, err return g, err
} }
if err = OpenTestCard(g.A.Token, g.A.C.CardId); err != nil { if err = OpenTestCard(g.A.Token, g.A.C.CardID); err != nil {
return g, err return g, err
} }
if g.A.C.GroupId, err = GroupTestCard(g.A.Token, g.A.C.CardId); err != nil { if g.A.C.GroupID, err = GroupTestCard(g.A.Token, g.A.C.CardID); err != nil {
return g, err return g, err
} }
if g.A.D.CardId, err = AddTestCard(g.A.Token, g.D.Token); err != nil { if g.A.D.CardID, err = AddTestCard(g.A.Token, g.D.Token); err != nil {
return g, err return g, err
} }
if err = OpenTestCard(g.A.Token, g.A.D.CardId); err != nil { if err = OpenTestCard(g.A.Token, g.A.D.CardID); err != nil {
return g, err return g, err
} }
// setup B // setup B
if g.B.A.CardId, err = AddTestCard(g.B.Token, g.A.Token); err != nil { if g.B.A.CardID, err = AddTestCard(g.B.Token, g.A.Token); err != nil {
return g, err return g, err
} }
if err = OpenTestCard(g.B.Token, g.B.A.CardId); err != nil { if err = OpenTestCard(g.B.Token, g.B.A.CardID); err != nil {
return g, err return g, err
} }
if g.B.A.GroupId, err = GroupTestCard(g.B.Token, g.B.A.CardId); err != nil { if g.B.A.GroupID, err = GroupTestCard(g.B.Token, g.B.A.CardID); err != nil {
return g, err return g, err
} }
if g.B.C.CardId, err = AddTestCard(g.B.Token, g.C.Token); err != nil { if g.B.C.CardID, err = AddTestCard(g.B.Token, g.C.Token); err != nil {
return g, err return g, err
} }
if g.B.C.GroupId, err = GroupTestCard(g.B.Token, g.B.C.CardId); err != nil { if g.B.C.GroupID, err = GroupTestCard(g.B.Token, g.B.C.CardID); err != nil {
return g, err return g, err
} }
// setup C // setup C
if g.C.D.CardId, err = AddTestCard(g.C.Token, g.D.Token); err != nil { if g.C.D.CardID, err = AddTestCard(g.C.Token, g.D.Token); err != nil {
return g, err return g, err
} }
if err = OpenTestCard(g.C.Token, g.C.D.CardId); err != nil { if err = OpenTestCard(g.C.Token, g.C.D.CardID); err != nil {
return g, err return g, err
} }
if g.C.D.GroupId, err = GroupTestCard(g.C.Token, g.C.D.CardId); err != nil { if g.C.D.GroupID, err = GroupTestCard(g.C.Token, g.C.D.CardID); err != nil {
return g, err return g, err
} }
if g.C.A.CardId, err = AddTestCard(g.C.Token, g.A.Token); err != nil { if g.C.A.CardID, err = AddTestCard(g.C.Token, g.A.Token); err != nil {
return g, err return g, err
} }
if err = OpenTestCard(g.C.Token, g.C.A.CardId); err != nil { if err = OpenTestCard(g.C.Token, g.C.A.CardID); err != nil {
return g, err return g, err
} }
if g.C.A.GroupId, err = GroupTestCard(g.C.Token, g.C.A.CardId); err != nil { if g.C.A.GroupID, err = GroupTestCard(g.C.Token, g.C.A.CardID); err != nil {
return g, err return g, err
} }
// setup D // setup D
if g.D.C.CardId, err = AddTestCard(g.D.Token, g.C.Token); err != nil { if g.D.C.CardID, err = AddTestCard(g.D.Token, g.C.Token); err != nil {
return g, err return g, err
} }
if err = OpenTestCard(g.D.Token, g.D.C.CardId); err != nil { if err = OpenTestCard(g.D.Token, g.D.C.CardID); err != nil {
return g, err return g, err
} }
if g.D.C.GroupId, err = GroupTestCard(g.D.Token, g.D.C.CardId); err != nil { if g.D.C.GroupID, err = GroupTestCard(g.D.Token, g.D.C.CardID); err != nil {
return g, err return g, err
} }
if g.D.A.CardId, err = GetCardId(g.D.Token, g.A.Guid); err != nil { if g.D.A.CardID, err = GetCardID(g.D.Token, g.A.GUID); err != nil {
return g, err return g, err
} }
// get contact tokens // get contact tokens
if g.A.B.Token, err = GetCardToken(g.A.Token, g.A.B.CardId); err != nil { if g.A.B.Token, err = GetCardToken(g.A.Token, g.A.B.CardID); err != nil {
return g, err return g, err
} }
if g.B.A.Token, err = GetCardToken(g.B.Token, g.B.A.CardId); err != nil { if g.B.A.Token, err = GetCardToken(g.B.Token, g.B.A.CardID); err != nil {
return g, err return g, err
} }
if g.C.A.Token, err = GetCardToken(g.C.Token, g.C.A.CardId); err != nil { if g.C.A.Token, err = GetCardToken(g.C.Token, g.C.A.CardID); err != nil {
return g, err return g, err
} }
if g.C.D.Token, err = GetCardToken(g.C.Token, g.C.D.CardId); err != nil { if g.C.D.Token, err = GetCardToken(g.C.Token, g.C.D.CardID); err != nil {
return g, err return g, err
} }
if g.D.C.Token, err = GetCardToken(g.D.Token, g.D.C.CardId); err != nil { if g.D.C.Token, err = GetCardToken(g.D.Token, g.D.C.CardID); err != nil {
return g, err return g, err
} }
@ -428,15 +428,15 @@ func MonitorStatus(ws *websocket.Conn, contact *TestContact) {
} }
} }
func GetCardToken(account string, cardId string) (token string, err error) { func GetCardToken(account string, cardID string) (token string, err error) {
var r *http.Request var r *http.Request
var w *httptest.ResponseRecorder var w *httptest.ResponseRecorder
var cardDetail CardDetail var cardDetail CardDetail
var cardProfile CardProfile var cardProfile CardProfile
vars := make(map[string]string) vars := make(map[string]string)
vars["cardId"] = cardId vars["cardID"] = cardID
if r, w, err = NewRequest("GET", "/contact/cards/{cardId}/detail?agent=" + account, nil); err != nil { if r, w, err = NewRequest("GET", "/contact/cards/{cardID}/detail?agent=" + account, nil); err != nil {
return return
} }
r = mux.SetURLVars(r, vars) r = mux.SetURLVars(r, vars)
@ -449,7 +449,7 @@ func GetCardToken(account string, cardId string) (token string, err error) {
return return
} }
if r, w, err = NewRequest("GET", "/contact/cards/{cardId}/profile?agent=" + account, nil); err != nil { if r, w, err = NewRequest("GET", "/contact/cards/{cardID}/profile?agent=" + account, nil); err != nil {
return return
} }
r = mux.SetURLVars(r, vars) r = mux.SetURLVars(r, vars)
@ -458,11 +458,11 @@ func GetCardToken(account string, cardId string) (token string, err error) {
return return
} }
token = cardProfile.Guid + "." + cardDetail.Token token = cardProfile.GUID + "." + cardDetail.Token
return return
} }
func GetCardId(account string, guid string) (cardId string, err error) { func GetCardID(account string, guid string) (cardID string, err error) {
var r *http.Request var r *http.Request
var w *httptest.ResponseRecorder var w *httptest.ResponseRecorder
var cards []Card var cards []Card
@ -476,8 +476,8 @@ func GetCardId(account string, guid string) (cardId string, err error) {
} }
for _, card := range cards { for _, card := range cards {
if card.Data.CardProfile.Guid == guid { if card.Data.CardProfile.GUID == guid {
cardId = card.Id cardID = card.ID
return return
} }
} }
@ -485,7 +485,7 @@ func GetCardId(account string, guid string) (cardId string, err error) {
return return
} }
func GroupTestCard(account string, cardId string) (groupId string, err error) { func GroupTestCard(account string, cardID string) (groupID string, err error) {
var r *http.Request var r *http.Request
var w *httptest.ResponseRecorder var w *httptest.ResponseRecorder
var subject *Subject var subject *Subject
@ -505,14 +505,14 @@ func GroupTestCard(account string, cardId string) (groupId string, err error) {
if err = ReadResponse(w, &group); err != nil { if err = ReadResponse(w, &group); err != nil {
return return
} }
groupId = group.Id groupID = group.ID
// set contact group // set contact group
if r, w, err = NewRequest("PUT", "/contact/cards/{cardId}/groups/{groupId}", nil); err != nil { if r, w, err = NewRequest("PUT", "/contact/cards/{cardID}/groups/{groupID}", nil); err != nil {
return return
} }
vars["groupId"] = group.Id vars["groupID"] = group.ID
vars["cardId"] = cardId vars["cardID"] = cardID
r = mux.SetURLVars(r, vars) r = mux.SetURLVars(r, vars)
SetBearerAuth(r, account) SetBearerAuth(r, account)
SetCardGroup(w, r) SetCardGroup(w, r)
@ -522,16 +522,16 @@ func GroupTestCard(account string, cardId string) (groupId string, err error) {
return return
} }
func OpenTestCard(account string, cardId string) (err error) { func OpenTestCard(account string, cardID string) (err error) {
var r *http.Request var r *http.Request
var w *httptest.ResponseRecorder var w *httptest.ResponseRecorder
var msg DataMessage var msg DataMessage
var card Card var card Card
var vars = map[string]string{ "cardId": cardId } var vars = map[string]string{ "cardID": cardID }
var contactStatus ContactStatus var contactStatus ContactStatus
// set to connecting state // set to connecting state
if r, w, err = NewRequest("PUT", "/contact/cards/{cardId}/status?agent=" + account, APP_CARDCONNECTING); err != nil { if r, w, err = NewRequest("PUT", "/contact/cards/{cardID}/status?agent=" + account, APP_CARDCONNECTING); err != nil {
return return
} }
r = mux.SetURLVars(r, vars) r = mux.SetURLVars(r, vars)
@ -541,7 +541,7 @@ func OpenTestCard(account string, cardId string) (err error) {
} }
// get open message // get open message
if r, w, err = NewRequest("GET", "/contact/cards/{cardId}/openMessage?agent=" + account, nil); err != nil { if r, w, err = NewRequest("GET", "/contact/cards/{cardID}/openMessage?agent=" + account, nil); err != nil {
return return
} }
r = mux.SetURLVars(r, vars) r = mux.SetURLVars(r, vars)
@ -565,7 +565,7 @@ func OpenTestCard(account string, cardId string) (err error) {
article := "articleRevision=" + strconv.FormatInt(contactStatus.ArticleRevision, 10) article := "articleRevision=" + strconv.FormatInt(contactStatus.ArticleRevision, 10)
channel := "channelRevision=" + strconv.FormatInt(contactStatus.ChannelRevision, 10) channel := "channelRevision=" + strconv.FormatInt(contactStatus.ChannelRevision, 10)
profile := "profileRevision=" + strconv.FormatInt(contactStatus.ProfileRevision, 10) profile := "profileRevision=" + strconv.FormatInt(contactStatus.ProfileRevision, 10)
if r, w, err = NewRequest("PUT", "/contact/cards/{cardId}/status?agent=" + account + "&token=" + contactStatus.Token + "&" + view + "&" + article + "&" + channel + "&" + profile, APP_CARDCONNECTED); err != nil { if r, w, err = NewRequest("PUT", "/contact/cards/{cardID}/status?agent=" + account + "&token=" + contactStatus.Token + "&" + view + "&" + article + "&" + channel + "&" + profile, APP_CARDCONNECTED); err != nil {
return return
} }
r = mux.SetURLVars(r, vars) r = mux.SetURLVars(r, vars)
@ -577,7 +577,7 @@ func OpenTestCard(account string, cardId string) (err error) {
return return
} }
func AddTestCard(account string, contact string) (cardId string, err error) { func AddTestCard(account string, contact string) (cardID string, err error) {
var r *http.Request var r *http.Request
var w *httptest.ResponseRecorder var w *httptest.ResponseRecorder
var msg DataMessage var msg DataMessage
@ -600,7 +600,7 @@ func AddTestCard(account string, contact string) (cardId string, err error) {
if err = ReadResponse(w, &card); err != nil { if err = ReadResponse(w, &card); err != nil {
return return
} }
cardId = card.Id cardID = card.ID
return return
} }
@ -638,7 +638,7 @@ func AddTestAccount(username string) (guid string, token string, err error) {
if err = ReadResponse(w, &profile); err != nil { if err = ReadResponse(w, &profile); err != nil {
return return
} }
guid = profile.Guid guid = profile.GUID
// acquire new token for attaching app // acquire new token for attaching app
if r, w, err = NewRequest("POST", "/account/apps", &app); err != nil { if r, w, err = NewRequest("POST", "/account/apps", &app); err != nil {

View File

@ -98,8 +98,8 @@ func transcodeAsset(asset *store.Asset) {
ErrMsg(err) ErrMsg(err)
} }
} else { } else {
input := data + "/" + asset.Account.Guid + "/" + asset.TransformId input := data + "/" + asset.Account.GUID + "/" + asset.TransformID
output := data + "/" + asset.Account.Guid + "/" + asset.AssetId output := data + "/" + asset.Account.GUID + "/" + asset.AssetID
cmd := exec.Command(script + "/transform_" + asset.Transform + ".sh", input, output, asset.TransformParams) cmd := exec.Command(script + "/transform_" + asset.Transform + ".sh", input, output, asset.TransformParams)
var stdout bytes.Buffer var stdout bytes.Buffer
cmd.Stdout = &stdout cmd.Stdout = &stdout
@ -174,11 +174,11 @@ func UpdateAsset(asset *store.Asset, status string, crc uint32, size int64) (err
// determine affected contact list // determine affected contact list
cards := make(map[string]store.Card) cards := make(map[string]store.Card)
for _, card := range topic.Channel.Cards { for _, card := range topic.Channel.Cards {
cards[card.Guid] = card cards[card.GUID] = card
} }
for _, group := range topic.Channel.Groups { for _, group := range topic.Channel.Groups {
for _, card := range group.Cards { for _, card := range group.Cards {
cards[card.Guid] = card cards[card.GUID] = card
} }
} }

View File

@ -9,8 +9,8 @@ import (
) )
func TestAccountConfig(t *testing.T) { func TestAccountConfig(t *testing.T) {
var params *TestApiParams var params *TestAPIParams
var response *TestApiResponse var response *TestAPIResponse
var channel *Channel var channel *Channel
var topic *Topic var topic *Topic
var assets *[]Asset var assets *[]Asset
@ -31,55 +31,55 @@ func TestAccountConfig(t *testing.T) {
// get reset token // get reset token
var token string var token string
params = &TestApiParams{ query: "/account/auth", authorization: "accountconfigA:pass" } params = &TestAPIParams{ query: "/account/auth", authorization: "accountconfigA:pass" }
response = &TestApiResponse{ data: &token } response = &TestAPIResponse{ data: &token }
assert.NoError(t, TestApiRequest(AddAccountAuthentication, params, response)) assert.NoError(t, TestAPIRequest(AddAccountAuthentication, params, response))
// set reset token // set reset token
params = &TestApiParams{ query: "/account/auth", tokenType: APP_TOKENRESET, token: token, credentials: "newguy:ssap" } params = &TestAPIParams{ query: "/account/auth", tokenType: APP_TOKENRESET, token: token, credentials: "newguy:ssap" }
assert.NoError(t, TestApiRequest(SetAccountAuthentication, params, nil)) assert.NoError(t, TestAPIRequest(SetAccountAuthentication, params, nil))
// fail getting reset token // fail getting reset token
params = &TestApiParams{ query: "/account/auth", authorization: "accountconfigA:pass" } params = &TestAPIParams{ query: "/account/auth", authorization: "accountconfigA:pass" }
response = &TestApiResponse{ data: &token } response = &TestAPIResponse{ data: &token }
assert.Error(t, TestApiRequest(AddAccountAuthentication, params, response)) assert.Error(t, TestAPIRequest(AddAccountAuthentication, params, response))
// create new channel // create new channel
channel = &Channel{} channel = &Channel{}
subject = &Subject{ Data: "channeldata", DataType: "channeldatatype" } subject = &Subject{ Data: "channeldata", DataType: "channeldatatype" }
params = &TestApiParams{ query: "/content/channels", tokenType: APP_TOKENAGENT, token: set.A.Token, body: subject } params = &TestAPIParams{ query: "/content/channels", tokenType: APP_TOKENAGENT, token: set.A.Token, body: subject }
response = &TestApiResponse{ data: channel } response = &TestAPIResponse{ data: channel }
assert.NoError(t, TestApiRequest(AddChannel, params, response)) assert.NoError(t, TestAPIRequest(AddChannel, params, response))
// create new topic // create new topic
topic = &Topic{} topic = &Topic{}
subject = &Subject{ DataType: "topicdatatype", Data: "topicdata" } subject = &Subject{ DataType: "topicdatatype", Data: "topicdata" }
params = &TestApiParams{ query: "/content/channels/{channelId}/topics", tokenType: APP_TOKENAGENT, token: set.A.Token, params = &TestAPIParams{ query: "/content/channels/{channelID}/topics", tokenType: APP_TOKENAGENT, token: set.A.Token,
path: map[string]string{ "channelId": channel.Id }, body: subject } path: map[string]string{ "channelID": channel.ID }, body: subject }
response = &TestApiResponse{ data: topic } response = &TestAPIResponse{ data: topic }
assert.NoError(t, TestApiRequest(AddChannelTopic, params, response)) assert.NoError(t, TestAPIRequest(AddChannelTopic, params, response))
// add asset to topic // add asset to topic
assets = &[]Asset{} assets = &[]Asset{}
pathParams = &map[string]string{ "channelId": channel.Id, "topicId": topic.Id } pathParams = &map[string]string{ "channelID": channel.ID, "topicID": topic.ID }
transforms, err := json.Marshal([]string{ "copy;photo", "copy;photo", }) transforms, err := json.Marshal([]string{ "copy;photo", "copy;photo", })
assert.NoError(t, err) assert.NoError(t, err)
assert.NoError(t, ApiTestUpload(AddChannelTopicAsset, "POST", assert.NoError(t, APITestUpload(AddChannelTopicAsset, "POST",
"/content/channels/{channelId}/topics/{topicId}/assets?transforms=" + url.QueryEscape(string(transforms)), "/content/channels/{channelID}/topics/{topicID}/assets?transforms=" + url.QueryEscape(string(transforms)),
pathParams, img, APP_TOKENAGENT, set.A.Token, assets, nil)) pathParams, img, APP_TOKENAGENT, set.A.Token, assets, nil))
// update topic // update topic
status := APP_TOPICCONFIRMED status := APP_TOPICCONFIRMED
params = &TestApiParams{ query: "/content/channels/{channelId}/topics/{topicId}", tokenType: APP_TOKENAGENT, token: set.A.Token, params = &TestAPIParams{ query: "/content/channels/{channelID}/topics/{topicID}", tokenType: APP_TOKENAGENT, token: set.A.Token,
path: map[string]string{ "channelId": channel.Id, "topicId": topic.Id }, body: &status } path: map[string]string{ "channelID": channel.ID, "topicID": topic.ID }, body: &status }
assert.NoError(t, TestApiRequest(SetChannelTopicConfirmed, params, nil)) assert.NoError(t, TestAPIRequest(SetChannelTopicConfirmed, params, nil))
// wait for assets // wait for assets
assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool { assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool {
for _, testChannel := range testApp.channels { for _, testChannel := range testApp.channels {
if testChannel.channel.Id == channel.Id { if testChannel.channel.ID == channel.ID {
for _, testTopic := range testChannel.topics { for _, testTopic := range testChannel.topics {
if testTopic.topic.Id == topic.Id { if testTopic.topic.ID == topic.ID {
detail := testTopic.topic.Data.TopicDetail detail := testTopic.topic.Data.TopicDetail
if detail.Status == APP_TOPICCONFIRMED && detail.Transform == APP_TRANSFORMCOMPLETE { if detail.Status == APP_TOPICCONFIRMED && detail.Transform == APP_TRANSFORMCOMPLETE {
return true return true
@ -94,35 +94,35 @@ func TestAccountConfig(t *testing.T) {
// set to searchable // set to searchable
searchable := true searchable := true
params = &TestApiParams{ query: "/account/searchable", tokenType: APP_TOKENAGENT, token: set.A.Token, body: &searchable } params = &TestAPIParams{ query: "/account/searchable", tokenType: APP_TOKENAGENT, token: set.A.Token, body: &searchable }
assert.NoError(t, TestApiRequest(SetAccountSearchable, params, nil)) assert.NoError(t, TestAPIRequest(SetAccountSearchable, params, nil))
// get account status // get account status
accountStatus := &AccountStatus{} accountStatus := &AccountStatus{}
params = &TestApiParams{ query: "/account/status", tokenType: APP_TOKENAGENT, token: set.A.Token } params = &TestAPIParams{ query: "/account/status", tokenType: APP_TOKENAGENT, token: set.A.Token }
response = &TestApiResponse{ data: accountStatus } response = &TestAPIResponse{ data: accountStatus }
assert.NoError(t, TestApiRequest(GetAccountStatus, params, response)) assert.NoError(t, TestAPIRequest(GetAccountStatus, params, response))
assert.True(t, accountStatus.Searchable) assert.True(t, accountStatus.Searchable)
// add asset to topic // add asset to topic
assets = &[]Asset{} assets = &[]Asset{}
pathParams = &map[string]string{ "channelId": channel.Id, "topicId": topic.Id } pathParams = &map[string]string{ "channelID": channel.ID, "topicID": topic.ID }
assert.Error(t, ApiTestUpload(AddChannelTopicAsset, "POST", assert.Error(t, APITestUpload(AddChannelTopicAsset, "POST",
"/content/channels/{channelId}/topics/{topicId}/assets?transforms=" + url.QueryEscape(string(transforms)), "/content/channels/{channelID}/topics/{topicID}/assets?transforms=" + url.QueryEscape(string(transforms)),
pathParams, img, APP_TOKENAGENT, set.A.Token, assets, nil)) pathParams, img, APP_TOKENAGENT, set.A.Token, assets, nil))
// get list of accounts // get list of accounts
profiles := []CardProfile{} profiles := []CardProfile{}
params = &TestApiParams{ query: "/account/listing" } params = &TestAPIParams{ query: "/account/listing" }
response = &TestApiResponse{ data: &profiles } response = &TestAPIResponse{ data: &profiles }
assert.NoError(t, TestApiRequest(GetAccountListing, params, response)) assert.NoError(t, TestAPIRequest(GetAccountListing, params, response))
assert.Equal(t, 1, len(profiles)) assert.Equal(t, 1, len(profiles))
assert.Equal(t, set.A.Guid, profiles[0].Guid); assert.Equal(t, set.A.GUID, profiles[0].GUID);
PrintMsg(set.A.Guid) PrintMsg(set.A.GUID)
// delete account // delete account
params = &TestApiParams{ query: "/account/profile", authorization: "newguy:ssap" } params = &TestAPIParams{ query: "/account/profile", authorization: "newguy:ssap" }
assert.NoError(t, TestApiRequest(RemoveAccount, params, nil)) assert.NoError(t, TestAPIRequest(RemoveAccount, params, nil))
} }

View File

@ -34,33 +34,33 @@ func TestAttributeShare(t *testing.T) {
// get latest // get latest
card = &Card{} card = &Card{}
param["cardId"] = set.B.A.CardId param["cardID"] = set.B.A.CardID
bRev = GetTestRevision(set.B.Revisions) bRev = GetTestRevision(set.B.Revisions)
assert.NoError(t, ApiTestMsg(GetCard, "GET", "/contact/cards/{cardId}", assert.NoError(t, APITestMsg(GetCard, "GET", "/contact/cards/{cardID}",
&param, nil, APP_TOKENAGENT, set.B.Token, card, nil)) &param, nil, APP_TOKENAGENT, set.B.Token, card, nil))
bViewRevision = card.Data.NotifiedView bViewRevision = card.Data.NotifiedView
bArticleRevision = card.Data.NotifiedArticle bArticleRevision = card.Data.NotifiedArticle
card = &Card{} card = &Card{}
param["cardId"] = set.C.A.CardId param["cardID"] = set.C.A.CardID
cRev = GetTestRevision(set.C.Revisions) cRev = GetTestRevision(set.C.Revisions)
assert.NoError(t, ApiTestMsg(GetCard, "GET", "/contact/cards/{cardId}", assert.NoError(t, APITestMsg(GetCard, "GET", "/contact/cards/{cardID}",
&param, nil, APP_TOKENAGENT, set.C.Token, card, nil)) &param, nil, APP_TOKENAGENT, set.C.Token, card, nil))
bViewRevision = card.Data.NotifiedView bViewRevision = card.Data.NotifiedView
bArticleRevision = card.Data.NotifiedArticle bArticleRevision = card.Data.NotifiedArticle
// add a new attribute // add a new attribute
articles = &[]Article{} articles = &[]Article{}
assert.NoError(t, ApiTestMsg(GetArticles, "GET", "/attribute/articles", assert.NoError(t, APITestMsg(GetArticles, "GET", "/attribute/articles",
nil, nil, APP_TOKENAGENT, set.A.Token, articles, nil)) nil, nil, APP_TOKENAGENT, set.A.Token, articles, nil))
assert.Equal(t, 0, len(*articles)) assert.Equal(t, 0, len(*articles))
article = &Article{} article = &Article{}
subject = &Subject{ Data: "subjectdata", DataType: "subjectdatatype" } subject = &Subject{ Data: "subjectdata", DataType: "subjectdatatype" }
assert.NoError(t, ApiTestMsg(AddArticle, "POST", "/attributes/articles", assert.NoError(t, APITestMsg(AddArticle, "POST", "/attributes/articles",
nil, subject, APP_TOKENAGENT, set.A.Token, article, nil)) nil, subject, APP_TOKENAGENT, set.A.Token, article, nil))
assert.Equal(t, "subjectdata", article.Data.Data) assert.Equal(t, "subjectdata", article.Data.Data)
assert.Equal(t, "subjectdatatype", article.Data.DataType) assert.Equal(t, "subjectdatatype", article.Data.DataType)
articles = &[]Article{} articles = &[]Article{}
assert.NoError(t, ApiTestMsg(GetArticles, "GET", "/attribute/articles", assert.NoError(t, APITestMsg(GetArticles, "GET", "/attribute/articles",
nil, nil, APP_TOKENAGENT, set.A.Token, articles, nil)) nil, nil, APP_TOKENAGENT, set.A.Token, articles, nil))
assert.Equal(t, 1, len(*articles)) assert.Equal(t, 1, len(*articles))
@ -69,10 +69,10 @@ func TestAttributeShare(t *testing.T) {
assert.Nil(t, GetTestRevision(set.C.Revisions)) assert.Nil(t, GetTestRevision(set.C.Revisions))
// share article with B // share article with B
param["articleId"] = article.Id param["articleID"] = article.ID
param["groupId"] = set.A.B.GroupId param["groupID"] = set.A.B.GroupID
article = &Article{} article = &Article{}
assert.NoError(t, ApiTestMsg(SetArticleGroup, "PUT", "/attribute/articles/{articleId}/groups/{groupId}", assert.NoError(t, APITestMsg(SetArticleGroup, "PUT", "/attribute/articles/{articleID}/groups/{groupID}",
&param, nil, APP_TOKENAGENT, set.A.Token, article, nil)) &param, nil, APP_TOKENAGENT, set.A.Token, article, nil))
// validate B & C view // validate B & C view
@ -81,7 +81,7 @@ func TestAttributeShare(t *testing.T) {
assert.NotEqual(t, bRev.Card, rev.Card) assert.NotEqual(t, bRev.Card, rev.Card)
assert.Nil(t, GetTestRevision(set.C.Revisions)) assert.Nil(t, GetTestRevision(set.C.Revisions))
revision = strconv.FormatInt(bRev.Card, 10) revision = strconv.FormatInt(bRev.Card, 10)
assert.NoError(t, ApiTestMsg(GetCards, "GET", "/contact/cards?revision=" + revision, assert.NoError(t, APITestMsg(GetCards, "GET", "/contact/cards?revision=" + revision,
nil, nil, APP_TOKENAGENT, set.B.Token, cards, nil)) nil, nil, APP_TOKENAGENT, set.B.Token, cards, nil))
assert.Equal(t, 1, len(*cards)) assert.Equal(t, 1, len(*cards))
assert.NotEqual(t, bArticleRevision, (*cards)[0].Data.NotifiedArticle) assert.NotEqual(t, bArticleRevision, (*cards)[0].Data.NotifiedArticle)
@ -89,12 +89,12 @@ func TestAttributeShare(t *testing.T) {
bRev = rev bRev = rev
bArticleRevision = (*cards)[0].Data.NotifiedArticle bArticleRevision = (*cards)[0].Data.NotifiedArticle
articles = &[]Article{} articles = &[]Article{}
assert.NoError(t, ApiTestMsg(GetArticles, "GET", "/attribute/articles", assert.NoError(t, APITestMsg(GetArticles, "GET", "/attribute/articles",
nil, nil, APP_TOKENCONTACT, set.B.A.Token, articles, nil)) nil, nil, APP_TOKENCONTACT, set.B.A.Token, articles, nil))
assert.Equal(t, 1, len(*articles)) assert.Equal(t, 1, len(*articles))
assert.NotNil(t, (*articles)[0].Data) assert.NotNil(t, (*articles)[0].Data)
articles = &[]Article{} articles = &[]Article{}
assert.NoError(t, ApiTestMsg(GetArticles, "GET", "/attribute/articles", assert.NoError(t, APITestMsg(GetArticles, "GET", "/attribute/articles",
nil, nil, APP_TOKENCONTACT, set.C.A.Token, articles, nil)) nil, nil, APP_TOKENCONTACT, set.C.A.Token, articles, nil))
assert.Equal(t, 0, len(*articles)) assert.Equal(t, 0, len(*articles))
@ -102,9 +102,9 @@ func TestAttributeShare(t *testing.T) {
image := "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" image := "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"
data := "{ \"nested\" : { \"image\" : \"" + image + "\" } }" data := "{ \"nested\" : { \"image\" : \"" + image + "\" } }"
subject = &Subject{ Data: data, DataType: "nestedimage" } subject = &Subject{ Data: data, DataType: "nestedimage" }
param["articleId"] = article.Id param["articleID"] = article.ID
article = &Article{} article = &Article{}
assert.NoError(t, ApiTestMsg(SetArticleSubject, "PUT", "/attribute/articles/{articleId}/subject", assert.NoError(t, APITestMsg(SetArticleSubject, "PUT", "/attribute/articles/{articleID}/subject",
&param, subject, APP_TOKENAGENT, set.A.Token, article, nil)) &param, subject, APP_TOKENAGENT, set.A.Token, article, nil))
// validate B & C view // validate B & C view
@ -113,7 +113,7 @@ func TestAttributeShare(t *testing.T) {
assert.NotEqual(t, bRev.Card, rev.Card) assert.NotEqual(t, bRev.Card, rev.Card)
assert.Nil(t, GetTestRevision(set.C.Revisions)) assert.Nil(t, GetTestRevision(set.C.Revisions))
revision = strconv.FormatInt(bRev.Card, 10) revision = strconv.FormatInt(bRev.Card, 10)
assert.NoError(t, ApiTestMsg(GetCards, "GET", "/contact/cards?revision=" + revision, assert.NoError(t, APITestMsg(GetCards, "GET", "/contact/cards?revision=" + revision,
nil, nil, APP_TOKENAGENT, set.B.Token, cards, nil)) nil, nil, APP_TOKENAGENT, set.B.Token, cards, nil))
assert.Equal(t, 1, len(*cards)) assert.Equal(t, 1, len(*cards))
assert.NotEqual(t, bArticleRevision, (*cards)[0].Data.NotifiedArticle) assert.NotEqual(t, bArticleRevision, (*cards)[0].Data.NotifiedArticle)
@ -122,7 +122,7 @@ func TestAttributeShare(t *testing.T) {
rView = strconv.FormatInt(bViewRevision, 10) rView = strconv.FormatInt(bViewRevision, 10)
rArticle = strconv.FormatInt(bArticleRevision, 10) rArticle = strconv.FormatInt(bArticleRevision, 10)
articles = &[]Article{} articles = &[]Article{}
assert.NoError(t, ApiTestMsg(GetArticles, "GET", "/attribute/articles?viewRevision=" + rView + "&articleRevision=" + rArticle, assert.NoError(t, APITestMsg(GetArticles, "GET", "/attribute/articles?viewRevision=" + rView + "&articleRevision=" + rArticle,
nil, nil, APP_TOKENCONTACT, set.B.A.Token, articles, nil)) nil, nil, APP_TOKENCONTACT, set.B.A.Token, articles, nil))
assert.Equal(t, 1, len(*articles)) assert.Equal(t, 1, len(*articles))
assert.Equal(t, "nestedimage", (*articles)[0].Data.DataType) assert.Equal(t, "nestedimage", (*articles)[0].Data.DataType)
@ -130,16 +130,16 @@ func TestAttributeShare(t *testing.T) {
bViewRevision = (*cards)[0].Data.NotifiedView bViewRevision = (*cards)[0].Data.NotifiedView
// share article with C // share article with C
param["articleId"] = article.Id param["articleID"] = article.ID
param["groupId"] = set.A.C.GroupId param["groupID"] = set.A.C.GroupID
article = &Article{} article = &Article{}
assert.NoError(t, ApiTestMsg(SetArticleGroup, "PUT", "/attribute/articles/{articleId}/groups/{groupId}", assert.NoError(t, APITestMsg(SetArticleGroup, "PUT", "/attribute/articles/{articleID}/groups/{groupID}",
&param, nil, APP_TOKENAGENT, set.A.Token, article, nil)) &param, nil, APP_TOKENAGENT, set.A.Token, article, nil))
// A retrieve image // A retrieve image
param["articleId"] = article.Id param["articleID"] = article.ID
param["field"] = "nested.image" param["field"] = "nested.image"
aData, aType, aErr := ApiTestData(GetArticleSubjectField, "GET", "/attributes/articles/{articleId}/subject/{field}", aData, aType, aErr := APITestData(GetArticleSubjectField, "GET", "/attributes/articles/{articleID}/subject/{field}",
&param, nil, APP_TOKENAGENT, set.A.Token, 0, 0) &param, nil, APP_TOKENAGENT, set.A.Token, 0, 0)
assert.NoError(t, aErr) assert.NoError(t, aErr)
assert.Equal(t, "image/png", aType["Content-Type"][0]) assert.Equal(t, "image/png", aType["Content-Type"][0])
@ -147,9 +147,9 @@ func TestAttributeShare(t *testing.T) {
assert.Zero(t, bytes.Compare(img, aData)) assert.Zero(t, bytes.Compare(img, aData))
// C retrieve image // C retrieve image
param["articleId"] = article.Id param["articleID"] = article.ID
param["field"] = "nested.image" param["field"] = "nested.image"
cData, cType, cErr := ApiTestData(GetArticleSubjectField, "GET", "/attributes/articles/{articleId}/subject/{field}", cData, cType, cErr := APITestData(GetArticleSubjectField, "GET", "/attributes/articles/{articleID}/subject/{field}",
&param, nil, APP_TOKENCONTACT, set.C.A.Token, 0, 0) &param, nil, APP_TOKENCONTACT, set.C.A.Token, 0, 0)
assert.NoError(t, cErr) assert.NoError(t, cErr)
assert.Equal(t, "image/png", cType["Content-Type"][0]) assert.Equal(t, "image/png", cType["Content-Type"][0])
@ -162,12 +162,12 @@ func TestAttributeShare(t *testing.T) {
assert.NotEqual(t, cRev.Card, rev.Card) assert.NotEqual(t, cRev.Card, rev.Card)
assert.Nil(t, GetTestRevision(set.B.Revisions)) assert.Nil(t, GetTestRevision(set.B.Revisions))
revision = strconv.FormatInt(cRev.Card, 10) revision = strconv.FormatInt(cRev.Card, 10)
assert.NoError(t, ApiTestMsg(GetCards, "GET", "/contact/cards?revision=" + revision, assert.NoError(t, APITestMsg(GetCards, "GET", "/contact/cards?revision=" + revision,
nil, nil, APP_TOKENAGENT, set.C.Token, cards, nil)) nil, nil, APP_TOKENAGENT, set.C.Token, cards, nil))
assert.Equal(t, 1, len(*cards)) assert.Equal(t, 1, len(*cards))
cRev = rev cRev = rev
articles = &[]Article{} articles = &[]Article{}
assert.NoError(t, ApiTestMsg(GetArticles, "GET", "/attribute/articles", assert.NoError(t, APITestMsg(GetArticles, "GET", "/attribute/articles",
nil, nil, APP_TOKENCONTACT, set.C.A.Token, articles, &hdr)) nil, nil, APP_TOKENCONTACT, set.C.A.Token, articles, &hdr))
assert.Equal(t, 1, len(*articles)) assert.Equal(t, 1, len(*articles))
assert.Equal(t, "nestedimage", (*articles)[0].Data.DataType) assert.Equal(t, "nestedimage", (*articles)[0].Data.DataType)
@ -175,10 +175,10 @@ func TestAttributeShare(t *testing.T) {
cViewRevision, _ = strconv.ParseInt(hdr["View-Revision"][0], 10, 64) cViewRevision, _ = strconv.ParseInt(hdr["View-Revision"][0], 10, 64)
// unshare article with B // unshare article with B
param["articleId"] = article.Id param["articleID"] = article.ID
param["groupId"] = set.A.B.GroupId param["groupID"] = set.A.B.GroupID
article = &Article{} article = &Article{}
assert.NoError(t, ApiTestMsg(ClearArticleGroup, "DELETE", "/attribute/articles/{articleId}/groups/{groupId}", assert.NoError(t, APITestMsg(ClearArticleGroup, "DELETE", "/attribute/articles/{articleID}/groups/{groupID}",
&param, nil, APP_TOKENAGENT, set.A.Token, article, nil)) &param, nil, APP_TOKENAGENT, set.A.Token, article, nil))
// validate B & C view // validate B & C view
@ -187,7 +187,7 @@ func TestAttributeShare(t *testing.T) {
assert.NotEqual(t, bRev.Card, rev.Card) assert.NotEqual(t, bRev.Card, rev.Card)
assert.Nil(t, GetTestRevision(set.C.Revisions)) assert.Nil(t, GetTestRevision(set.C.Revisions))
revision = strconv.FormatInt(bRev.Card, 10) revision = strconv.FormatInt(bRev.Card, 10)
assert.NoError(t, ApiTestMsg(GetCards, "GET", "/contact/cards?revision=" + revision, assert.NoError(t, APITestMsg(GetCards, "GET", "/contact/cards?revision=" + revision,
nil, nil, APP_TOKENAGENT, set.B.Token, cards, nil)) nil, nil, APP_TOKENAGENT, set.B.Token, cards, nil))
assert.Equal(t, 1, len(*cards)) assert.Equal(t, 1, len(*cards))
assert.NotEqual(t, bArticleRevision, (*cards)[0].Data.NotifiedArticle) assert.NotEqual(t, bArticleRevision, (*cards)[0].Data.NotifiedArticle)
@ -196,20 +196,20 @@ func TestAttributeShare(t *testing.T) {
rView = strconv.FormatInt(bViewRevision, 10) rView = strconv.FormatInt(bViewRevision, 10)
rArticle = strconv.FormatInt(bArticleRevision, 10) rArticle = strconv.FormatInt(bArticleRevision, 10)
articles = &[]Article{} articles = &[]Article{}
assert.NoError(t, ApiTestMsg(GetArticles, "GET", "/attribute/articles?viewRevision=" + rView + "&articleRevision=" + rArticle, assert.NoError(t, APITestMsg(GetArticles, "GET", "/attribute/articles?viewRevision=" + rView + "&articleRevision=" + rArticle,
nil, nil, APP_TOKENCONTACT, set.B.A.Token, articles, nil)) nil, nil, APP_TOKENCONTACT, set.B.A.Token, articles, nil))
assert.Equal(t, 1, len(*articles)) assert.Equal(t, 1, len(*articles))
assert.Nil(t, (*articles)[0].Data) assert.Nil(t, (*articles)[0].Data)
card = &Card{} card = &Card{}
param["cardId"] = set.C.A.CardId param["cardID"] = set.C.A.CardID
GetTestRevision(set.B.Revisions) GetTestRevision(set.B.Revisions)
// delete article // delete article
param["articleId"] = article.Id param["articleID"] = article.ID
assert.NoError(t, ApiTestMsg(RemoveArticle, "DELETE", "/attribute/articles/{articleId}", assert.NoError(t, APITestMsg(RemoveArticle, "DELETE", "/attribute/articles/{articleID}",
&param, nil, APP_TOKENAGENT, set.A.Token, nil, nil)) &param, nil, APP_TOKENAGENT, set.A.Token, nil, nil))
articles = &[]Article{} articles = &[]Article{}
assert.NoError(t, ApiTestMsg(GetArticles, "GET", "/attribute/articles", assert.NoError(t, APITestMsg(GetArticles, "GET", "/attribute/articles",
nil, nil, APP_TOKENAGENT, set.A.Token, articles, nil)) nil, nil, APP_TOKENAGENT, set.A.Token, articles, nil))
assert.Equal(t, 0, len(*articles)) assert.Equal(t, 0, len(*articles))
@ -219,13 +219,13 @@ func TestAttributeShare(t *testing.T) {
assert.NotEqual(t, cRev.Card, rev.Card) assert.NotEqual(t, cRev.Card, rev.Card)
assert.Nil(t, GetTestRevision(set.B.Revisions)) assert.Nil(t, GetTestRevision(set.B.Revisions))
revision = strconv.FormatInt(cRev.Card, 10) revision = strconv.FormatInt(cRev.Card, 10)
assert.NoError(t, ApiTestMsg(GetCards, "GET", "/contact/cards?revision=" + revision, assert.NoError(t, APITestMsg(GetCards, "GET", "/contact/cards?revision=" + revision,
nil, nil, APP_TOKENAGENT, set.C.Token, cards, nil)) nil, nil, APP_TOKENAGENT, set.C.Token, cards, nil))
assert.Equal(t, 1, len(*cards)) assert.Equal(t, 1, len(*cards))
rView = strconv.FormatInt(cViewRevision, 10) rView = strconv.FormatInt(cViewRevision, 10)
rArticle = strconv.FormatInt(cArticleRevision, 10) rArticle = strconv.FormatInt(cArticleRevision, 10)
articles = &[]Article{} articles = &[]Article{}
assert.NoError(t, ApiTestMsg(GetArticles, "GET", "/attribute/articles?viewRevision=" + rView + "&articleRevision=" + rArticle, assert.NoError(t, APITestMsg(GetArticles, "GET", "/attribute/articles?viewRevision=" + rView + "&articleRevision=" + rArticle,
nil, nil, APP_TOKENCONTACT, set.C.A.Token, articles, nil)) nil, nil, APP_TOKENCONTACT, set.C.A.Token, articles, nil))
assert.Equal(t, 1, len(*articles)) assert.Equal(t, 1, len(*articles))
assert.Nil(t, (*articles)[0].Data) assert.Nil(t, (*articles)[0].Data)
@ -234,38 +234,38 @@ func TestAttributeShare(t *testing.T) {
rView = strconv.FormatInt(cViewRevision - 1, 10) rView = strconv.FormatInt(cViewRevision - 1, 10)
rArticle = strconv.FormatInt(cArticleRevision - 1, 10) rArticle = strconv.FormatInt(cArticleRevision - 1, 10)
articles = &[]Article{} articles = &[]Article{}
assert.Error(t, ApiTestMsg(GetArticles, "GET", "/attribute/articles?viewRevision=" + rView + "&articleRevision=" + rArticle, assert.Error(t, APITestMsg(GetArticles, "GET", "/attribute/articles?viewRevision=" + rView + "&articleRevision=" + rArticle,
nil, nil, APP_TOKENCONTACT, set.C.A.Token, articles, &hdr)) nil, nil, APP_TOKENCONTACT, set.C.A.Token, articles, &hdr))
// reset B's view // reset B's view
articles = &[]Article{} articles = &[]Article{}
assert.NoError(t, ApiTestMsg(GetArticles, "GET", "/attribute/articles", assert.NoError(t, APITestMsg(GetArticles, "GET", "/attribute/articles",
nil, nil, APP_TOKENCONTACT, set.B.A.Token, articles, &hdr)) nil, nil, APP_TOKENCONTACT, set.B.A.Token, articles, &hdr))
bArticleRevision, _ = strconv.ParseInt(hdr["Article-Revision"][0], 10, 64) bArticleRevision, _ = strconv.ParseInt(hdr["Article-Revision"][0], 10, 64)
bViewRevision, _ = strconv.ParseInt(hdr["View-Revision"][0], 10, 64) bViewRevision, _ = strconv.ParseInt(hdr["View-Revision"][0], 10, 64)
// add a new attribute // add a new attribute
articles = &[]Article{} articles = &[]Article{}
assert.NoError(t, ApiTestMsg(GetArticles, "GET", "/attribute/articles", assert.NoError(t, APITestMsg(GetArticles, "GET", "/attribute/articles",
nil, nil, APP_TOKENAGENT, set.A.Token, articles, nil)) nil, nil, APP_TOKENAGENT, set.A.Token, articles, nil))
assert.Equal(t, 0, len(*articles)) assert.Equal(t, 0, len(*articles))
article = &Article{} article = &Article{}
subject = &Subject{ Data: "subjectdata", DataType: "subjectdatatype" } subject = &Subject{ Data: "subjectdata", DataType: "subjectdatatype" }
assert.NoError(t, ApiTestMsg(AddArticle, "POST", "/attributes/articles", assert.NoError(t, APITestMsg(AddArticle, "POST", "/attributes/articles",
nil, subject, APP_TOKENAGENT, set.A.Token, article, nil)) nil, subject, APP_TOKENAGENT, set.A.Token, article, nil))
assert.Equal(t, "subjectdata", article.Data.Data) assert.Equal(t, "subjectdata", article.Data.Data)
assert.Equal(t, "subjectdatatype", article.Data.DataType) assert.Equal(t, "subjectdatatype", article.Data.DataType)
articles = &[]Article{} articles = &[]Article{}
// share article with B // share article with B
param["articleId"] = article.Id param["articleID"] = article.ID
param["groupId"] = set.A.B.GroupId param["groupID"] = set.A.B.GroupID
article = &Article{} article = &Article{}
assert.NoError(t, ApiTestMsg(SetArticleGroup, "PUT", "/attribute/articles/{articleId}/groups/{groupId}", assert.NoError(t, APITestMsg(SetArticleGroup, "PUT", "/attribute/articles/{articleID}/groups/{groupID}",
&param, nil, APP_TOKENAGENT, set.A.Token, article, nil)) &param, nil, APP_TOKENAGENT, set.A.Token, article, nil))
rView = strconv.FormatInt(bViewRevision, 10) rView = strconv.FormatInt(bViewRevision, 10)
rArticle = strconv.FormatInt(bArticleRevision, 10) rArticle = strconv.FormatInt(bArticleRevision, 10)
assert.NoError(t, ApiTestMsg(GetArticles, "GET", "/attribute/articles?viewRevision=" + rView + "&articleRevision=" + rArticle, assert.NoError(t, APITestMsg(GetArticles, "GET", "/attribute/articles?viewRevision=" + rView + "&articleRevision=" + rArticle,
nil, nil, APP_TOKENCONTACT, set.B.A.Token, articles, &hdr)) nil, nil, APP_TOKENCONTACT, set.B.A.Token, articles, &hdr))
assert.Equal(t, 1, len(*articles)) assert.Equal(t, 1, len(*articles))
assert.NotNil(t, (*articles)[0].Data) assert.NotNil(t, (*articles)[0].Data)
@ -273,12 +273,12 @@ func TestAttributeShare(t *testing.T) {
bViewRevision, _ = strconv.ParseInt(hdr["View-Revision"][0], 10, 64) bViewRevision, _ = strconv.ParseInt(hdr["View-Revision"][0], 10, 64)
// delete B's group // delete B's group
assert.NoError(t, ApiTestMsg(RemoveGroup, "DELETE", "/alias/groups/{groupId}", assert.NoError(t, APITestMsg(RemoveGroup, "DELETE", "/alias/groups/{groupID}",
&param, nil, APP_TOKENAGENT, set.A.Token, nil, nil)) &param, nil, APP_TOKENAGENT, set.A.Token, nil, nil))
assert.Error(t, ApiTestMsg(GetArticles, "GET", "/attribute/articles?viewRevision=" + rView + "&articleRevision=" + rArticle, assert.Error(t, APITestMsg(GetArticles, "GET", "/attribute/articles?viewRevision=" + rView + "&articleRevision=" + rArticle,
nil, nil, APP_TOKENCONTACT, set.B.A.Token, articles, &hdr)) nil, nil, APP_TOKENCONTACT, set.B.A.Token, articles, &hdr))
articles = &[]Article{} articles = &[]Article{}
assert.NoError(t, ApiTestMsg(GetArticles, "GET", "/attribute/articles", assert.NoError(t, APITestMsg(GetArticles, "GET", "/attribute/articles",
nil, nil, APP_TOKENCONTACT, set.B.A.Token, articles, &hdr)) nil, nil, APP_TOKENCONTACT, set.B.A.Token, articles, &hdr))
view, _ := strconv.ParseInt(hdr["View-Revision"][0], 10, 64) view, _ := strconv.ParseInt(hdr["View-Revision"][0], 10, 64)
assert.NotEqual(t, bViewRevision, view) assert.NotEqual(t, bViewRevision, view)

View File

@ -33,59 +33,59 @@ func TestChannelShare(t *testing.T) {
// add new channel // add new channel
channel = &Channel{} channel = &Channel{}
subject = &Subject{ Data: "channeldata", DataType: "channeldatatype" } subject = &Subject{ Data: "channeldata", DataType: "channeldatatype" }
assert.NoError(t, ApiTestMsg(AddChannel, "POST", "/content/channels", assert.NoError(t, APITestMsg(AddChannel, "POST", "/content/channels",
nil, subject, APP_TOKENAGENT, set.A.Token, channel, nil)) nil, subject, APP_TOKENAGENT, set.A.Token, channel, nil))
// retrieve channels // retrieve channels
channels = &[]Channel{} channels = &[]Channel{}
assert.NoError(t, ApiTestMsg(GetChannels, "GET", "/content/channels", assert.NoError(t, APITestMsg(GetChannels, "GET", "/content/channels",
nil, nil, APP_TOKENAGENT, set.A.Token, channels, &aRevision)) nil, nil, APP_TOKENAGENT, set.A.Token, channels, &aRevision))
assert.Equal(t, 1, len(*channels)) assert.Equal(t, 1, len(*channels))
assert.NotNil(t, (*channels)[0].Data) assert.NotNil(t, (*channels)[0].Data)
detailRevision = (*channels)[0].Data.DetailRevision detailRevision = (*channels)[0].Data.DetailRevision
channels = &[]Channel{} channels = &[]Channel{}
assert.NoError(t, ApiTestMsg(GetChannels, "GET", "/content/channels", assert.NoError(t, APITestMsg(GetChannels, "GET", "/content/channels",
nil, nil, APP_TOKENCONTACT, set.B.A.Token, channels, &bChannelRevision)) nil, nil, APP_TOKENCONTACT, set.B.A.Token, channels, &bChannelRevision))
assert.Equal(t, 0, len(*channels)) assert.Equal(t, 0, len(*channels))
channels = &[]Channel{} channels = &[]Channel{}
assert.NoError(t, ApiTestMsg(GetChannels, "GET", "/content/channels", assert.NoError(t, APITestMsg(GetChannels, "GET", "/content/channels",
nil, nil, APP_TOKENCONTACT, set.C.A.Token, channels, &cChannelRevision)) nil, nil, APP_TOKENCONTACT, set.C.A.Token, channels, &cChannelRevision))
assert.Equal(t, 0, len(*channels)) assert.Equal(t, 0, len(*channels))
// assign channel to B // assign channel to B
params["channelId"] = channel.Id params["channelID"] = channel.ID
params["cardId"] = set.A.B.CardId params["cardID"] = set.A.B.CardID
assert.NoError(t, ApiTestMsg(SetChannelCard, "PUT", "/content/channels/{channelId}/cards/{cardId}", assert.NoError(t, APITestMsg(SetChannelCard, "PUT", "/content/channels/{channelID}/cards/{cardID}",
&params, nil, APP_TOKENAGENT, set.A.Token, nil, nil)) &params, nil, APP_TOKENAGENT, set.A.Token, nil, nil))
// check shared channel // check shared channel
channels = &[]Channel{} channels = &[]Channel{}
revision = "?channelRevision=" + aRevision["Channel-Revision"][0] revision = "?channelRevision=" + aRevision["Channel-Revision"][0]
assert.NoError(t, ApiTestMsg(GetChannels, "GET", "/content/channels" + revision, assert.NoError(t, APITestMsg(GetChannels, "GET", "/content/channels" + revision,
nil, nil, APP_TOKENAGENT, set.A.Token, channels, &aRevision)) nil, nil, APP_TOKENAGENT, set.A.Token, channels, &aRevision))
assert.Equal(t, 1, len(*channels)) assert.Equal(t, 1, len(*channels))
assert.NotNil(t, (*channels)[0].Data) assert.NotNil(t, (*channels)[0].Data)
assert.NotEqual(t, detailRevision, (*channels)[0].Data.DetailRevision) assert.NotEqual(t, detailRevision, (*channels)[0].Data.DetailRevision)
channels = &[]Channel{} channels = &[]Channel{}
revision = "?channelRevision=" + bChannelRevision["Channel-Revision"][0] + "&viewRevision=" + bChannelRevision["View-Revision"][0] revision = "?channelRevision=" + bChannelRevision["Channel-Revision"][0] + "&viewRevision=" + bChannelRevision["View-Revision"][0]
assert.NoError(t, ApiTestMsg(GetChannels, "GET", "/content/channels" + revision, assert.NoError(t, APITestMsg(GetChannels, "GET", "/content/channels" + revision,
nil, nil, APP_TOKENCONTACT, set.B.A.Token, channels, &bChannelRevision)) nil, nil, APP_TOKENCONTACT, set.B.A.Token, channels, &bChannelRevision))
assert.Equal(t, 1, len(*channels)) assert.Equal(t, 1, len(*channels))
assert.NotNil(t, (*channels)[0].Data) assert.NotNil(t, (*channels)[0].Data)
channels = &[]Channel{} channels = &[]Channel{}
revision = "?channelRevision=" + cChannelRevision["Channel-Revision"][0] + "&viewRevision=" + cChannelRevision["View-Revision"][0] revision = "?channelRevision=" + cChannelRevision["Channel-Revision"][0] + "&viewRevision=" + cChannelRevision["View-Revision"][0]
assert.NoError(t, ApiTestMsg(GetChannels, "GET", "/content/channels" + revision, assert.NoError(t, APITestMsg(GetChannels, "GET", "/content/channels" + revision,
nil, nil, APP_TOKENCONTACT, set.C.A.Token, channels, &cChannelRevision)) nil, nil, APP_TOKENCONTACT, set.C.A.Token, channels, &cChannelRevision))
assert.Equal(t, 1, len(*channels)) assert.Equal(t, 1, len(*channels))
assert.Nil(t, (*channels)[0].Data) assert.Nil(t, (*channels)[0].Data)
// get discovered channel // get discovered channel
detail = &ChannelDetail{} detail = &ChannelDetail{}
assert.NoError(t, ApiTestMsg(GetChannelDetail, "GET", "/content/channels/{channelId}/detail", assert.NoError(t, APITestMsg(GetChannelDetail, "GET", "/content/channels/{channelID}/detail",
&params, nil, APP_TOKENCONTACT, set.B.A.Token, detail, nil)) &params, nil, APP_TOKENCONTACT, set.B.A.Token, detail, nil))
assert.Equal(t, "channeldatatype", detail.DataType) assert.Equal(t, "channeldatatype", detail.DataType)
assert.Equal(t, 1, len(detail.Members)) assert.Equal(t, 1, len(detail.Members))
assert.Equal(t, set.B.Guid, detail.Members[0]) assert.Equal(t, set.B.GUID, detail.Members[0])
assert.Nil(t, detail.Contacts) assert.Nil(t, detail.Contacts)
// get revision // get revision
@ -93,22 +93,22 @@ func TestChannelShare(t *testing.T) {
bRev = GetTestRevision(set.B.Revisions) bRev = GetTestRevision(set.B.Revisions)
cRev = GetTestRevision(set.C.Revisions) cRev = GetTestRevision(set.C.Revisions)
cards = &[]Card{} cards = &[]Card{}
assert.NoError(t, ApiTestMsg(GetCards, "GET", "/contact/cards", assert.NoError(t, APITestMsg(GetCards, "GET", "/contact/cards",
nil, nil, APP_TOKENAGENT, set.B.Token, cards, &bCardRevision)) nil, nil, APP_TOKENAGENT, set.B.Token, cards, &bCardRevision))
channels = &[]Channel{} channels = &[]Channel{}
assert.NoError(t, ApiTestMsg(GetChannels, "GET", "/content/channels", assert.NoError(t, APITestMsg(GetChannels, "GET", "/content/channels",
nil, nil, APP_TOKENCONTACT, set.B.A.Token, channels, &bChannelRevision)) nil, nil, APP_TOKENCONTACT, set.B.A.Token, channels, &bChannelRevision))
cards = &[]Card{} cards = &[]Card{}
assert.NoError(t, ApiTestMsg(GetCards, "GET", "/contact/cards", assert.NoError(t, APITestMsg(GetCards, "GET", "/contact/cards",
nil, nil, APP_TOKENAGENT, set.C.Token, cards, &cCardRevision)) nil, nil, APP_TOKENAGENT, set.C.Token, cards, &cCardRevision))
channels = &[]Channel{} channels = &[]Channel{}
assert.NoError(t, ApiTestMsg(GetChannels, "GET", "/content/channels", assert.NoError(t, APITestMsg(GetChannels, "GET", "/content/channels",
nil, nil, APP_TOKENCONTACT, set.C.A.Token, channels, &cChannelRevision)) nil, nil, APP_TOKENCONTACT, set.C.A.Token, channels, &cChannelRevision))
// assign channel to C // assign channel to C
params["channelId"] = channel.Id params["channelID"] = channel.ID
params["cardId"] = set.A.C.CardId params["cardID"] = set.A.C.CardID
assert.NoError(t, ApiTestMsg(SetChannelCard, "PUT", "/content/channels/{channelId}/cards/{cardId}", assert.NoError(t, APITestMsg(SetChannelCard, "PUT", "/content/channels/{channelID}/cards/{cardID}",
&params, nil, APP_TOKENAGENT, set.A.Token, nil, nil)) &params, nil, APP_TOKENAGENT, set.A.Token, nil, nil))
// check revision change // check revision change
@ -118,7 +118,7 @@ func TestChannelShare(t *testing.T) {
rev = GetTestRevision(set.B.Revisions) rev = GetTestRevision(set.B.Revisions)
assert.NotEqual(t, rev.Card, bRev.Card) assert.NotEqual(t, rev.Card, bRev.Card)
cards = &[]Card{} cards = &[]Card{}
assert.NoError(t, ApiTestMsg(GetCards, "GET", "/contact/cards?revision=" + bCardRevision["Card-Revision"][0], assert.NoError(t, APITestMsg(GetCards, "GET", "/contact/cards?revision=" + bCardRevision["Card-Revision"][0],
nil, nil, APP_TOKENAGENT, set.B.Token, cards, &bCardRevision)) nil, nil, APP_TOKENAGENT, set.B.Token, cards, &bCardRevision))
assert.Equal(t, 1, len(*cards)) assert.Equal(t, 1, len(*cards))
r, _ = strconv.ParseInt(bChannelRevision["Channel-Revision"][0], 10, 64) r, _ = strconv.ParseInt(bChannelRevision["Channel-Revision"][0], 10, 64)
@ -130,7 +130,7 @@ func TestChannelShare(t *testing.T) {
rev = GetTestRevision(set.C.Revisions) rev = GetTestRevision(set.C.Revisions)
assert.NotEqual(t, rev.Card, cRev.Card) assert.NotEqual(t, rev.Card, cRev.Card)
cards = &[]Card{} cards = &[]Card{}
assert.NoError(t, ApiTestMsg(GetCards, "GET", "/contact/cards?revision=" + cCardRevision["Card-Revision"][0], assert.NoError(t, APITestMsg(GetCards, "GET", "/contact/cards?revision=" + cCardRevision["Card-Revision"][0],
nil, nil, APP_TOKENAGENT, set.C.Token, cards, &cCardRevision)) nil, nil, APP_TOKENAGENT, set.C.Token, cards, &cCardRevision))
assert.Equal(t, 1, len(*cards)) assert.Equal(t, 1, len(*cards))
r, _ = strconv.ParseInt(cChannelRevision["Channel-Revision"][0], 10, 64) r, _ = strconv.ParseInt(cChannelRevision["Channel-Revision"][0], 10, 64)
@ -141,18 +141,18 @@ func TestChannelShare(t *testing.T) {
channels = &[]Channel{} channels = &[]Channel{}
revision = "?channelRevision=" + bChannelRevision["Channel-Revision"][0] + "&viewRevision=" + bChannelRevision["View-Revision"][0] revision = "?channelRevision=" + bChannelRevision["Channel-Revision"][0] + "&viewRevision=" + bChannelRevision["View-Revision"][0]
assert.NoError(t, ApiTestMsg(GetChannels, "GET", "/content/channels" + revision, assert.NoError(t, APITestMsg(GetChannels, "GET", "/content/channels" + revision,
nil, nil, APP_TOKENCONTACT, set.B.A.Token, channels, &bChannelRevision)) nil, nil, APP_TOKENCONTACT, set.B.A.Token, channels, &bChannelRevision))
assert.Equal(t, 1, len(*channels)) assert.Equal(t, 1, len(*channels))
channels = &[]Channel{} channels = &[]Channel{}
revision = "?channelRevision=" + cChannelRevision["Channel-Revision"][0] + "&viewRevision=" + cChannelRevision["View-Revision"][0] revision = "?channelRevision=" + cChannelRevision["Channel-Revision"][0] + "&viewRevision=" + cChannelRevision["View-Revision"][0]
assert.NoError(t, ApiTestMsg(GetChannels, "GET", "/content/channels" + revision, assert.NoError(t, APITestMsg(GetChannels, "GET", "/content/channels" + revision,
nil, nil, APP_TOKENCONTACT, set.C.A.Token, channels, &cChannelRevision)) nil, nil, APP_TOKENCONTACT, set.C.A.Token, channels, &cChannelRevision))
assert.Equal(t, 1, len(*channels)) assert.Equal(t, 1, len(*channels))
// get discovered channel // get discovered channel
detail = &ChannelDetail{} detail = &ChannelDetail{}
assert.NoError(t, ApiTestMsg(GetChannelDetail, "GET", "/content/channels/{channelId}/detail", assert.NoError(t, APITestMsg(GetChannelDetail, "GET", "/content/channels/{channelID}/detail",
&params, nil, APP_TOKENCONTACT, set.C.A.Token, detail, nil)) &params, nil, APP_TOKENCONTACT, set.C.A.Token, detail, nil))
assert.Equal(t, "channeldatatype", detail.DataType) assert.Equal(t, "channeldatatype", detail.DataType)
assert.Equal(t, 2, len(detail.Members)) assert.Equal(t, 2, len(detail.Members))
@ -163,16 +163,16 @@ func TestChannelShare(t *testing.T) {
GetTestRevision(set.C.Revisions) GetTestRevision(set.C.Revisions)
// remove channel from C // remove channel from C
params["channelId"] = channel.Id params["channelID"] = channel.ID
params["cardId"] = set.A.C.CardId params["cardID"] = set.A.C.CardID
assert.NoError(t, ApiTestMsg(ClearChannelCard, "DELETE", "/content/channels/{channelId}/cards/{cardId}", assert.NoError(t, APITestMsg(ClearChannelCard, "DELETE", "/content/channels/{channelID}/cards/{cardID}",
&params, nil, APP_TOKENAGENT, set.A.Token, nil, nil)) &params, nil, APP_TOKENAGENT, set.A.Token, nil, nil))
// check channel view from C // check channel view from C
assert.NotNil(t, GetTestRevision(set.B.Revisions)) assert.NotNil(t, GetTestRevision(set.B.Revisions))
assert.NotNil(t, GetTestRevision(set.C.Revisions)) assert.NotNil(t, GetTestRevision(set.C.Revisions))
revision = "?channelRevision=" + cChannelRevision["Channel-Revision"][0] + "&viewRevision=" + cChannelRevision["View-Revision"][0] revision = "?channelRevision=" + cChannelRevision["Channel-Revision"][0] + "&viewRevision=" + cChannelRevision["View-Revision"][0]
assert.NoError(t, ApiTestMsg(GetChannels, "GET", "/content/channels" + revision, assert.NoError(t, APITestMsg(GetChannels, "GET", "/content/channels" + revision,
nil, nil, APP_TOKENCONTACT, set.C.A.Token, channels, &cChannelRevision)) nil, nil, APP_TOKENCONTACT, set.C.A.Token, channels, &cChannelRevision))
assert.Equal(t, 1, len(*channels)) assert.Equal(t, 1, len(*channels))
assert.Nil(t, (*channels)[0].Data) assert.Nil(t, (*channels)[0].Data)
@ -182,7 +182,7 @@ func TestChannelShare(t *testing.T) {
data := "{ \"nested\" : { \"image\" : \"" + image + "\" } }" data := "{ \"nested\" : { \"image\" : \"" + image + "\" } }"
subject = &Subject{ Data: data, DataType: "nestedimage" } subject = &Subject{ Data: data, DataType: "nestedimage" }
channel = &Channel{} channel = &Channel{}
assert.NoError(t, ApiTestMsg(SetChannelSubject, "PUT", "/content/channels/{channelId}/subject", assert.NoError(t, APITestMsg(SetChannelSubject, "PUT", "/content/channels/{channelID}/subject",
&params, subject, APP_TOKENAGENT, set.A.Token, channel, nil)) &params, subject, APP_TOKENAGENT, set.A.Token, channel, nil))
// check notifications // check notifications
@ -190,9 +190,9 @@ func TestChannelShare(t *testing.T) {
assert.Nil(t, GetTestRevision(set.C.Revisions)) assert.Nil(t, GetTestRevision(set.C.Revisions))
// add C group to channel // add C group to channel
params["groupId"] = set.A.C.GroupId params["groupID"] = set.A.C.GroupID
channel = &Channel{} channel = &Channel{}
assert.NoError(t, ApiTestMsg(SetChannelGroup, "PUT", "/content/channels/{channelId}/groups/{groupId}", assert.NoError(t, APITestMsg(SetChannelGroup, "PUT", "/content/channels/{channelID}/groups/{groupID}",
&params, nil, APP_TOKENAGENT, set.A.Token, channel, nil)) &params, nil, APP_TOKENAGENT, set.A.Token, channel, nil))
assert.Equal(t, 1, len(channel.Data.ChannelDetail.Contacts.Cards)) assert.Equal(t, 1, len(channel.Data.ChannelDetail.Contacts.Cards))
assert.Equal(t, 1, len(channel.Data.ChannelDetail.Contacts.Groups)) assert.Equal(t, 1, len(channel.Data.ChannelDetail.Contacts.Groups))
@ -202,9 +202,9 @@ func TestChannelShare(t *testing.T) {
GetTestRevision(set.C.Revisions) GetTestRevision(set.C.Revisions)
// remove channel from B // remove channel from B
params["channelId"] = channel.Id params["channelID"] = channel.ID
params["cardId"] = set.A.B.CardId params["cardID"] = set.A.B.CardID
assert.NoError(t, ApiTestMsg(ClearChannelCard, "DELETE", "/content/channels/{channelId}/cards/{cardId}", assert.NoError(t, APITestMsg(ClearChannelCard, "DELETE", "/content/channels/{channelID}/cards/{cardID}",
&params, nil, APP_TOKENAGENT, set.A.Token, channel, nil)) &params, nil, APP_TOKENAGENT, set.A.Token, channel, nil))
// check notifications // check notifications
@ -212,9 +212,9 @@ func TestChannelShare(t *testing.T) {
assert.NotNil(t, GetTestRevision(set.C.Revisions)) assert.NotNil(t, GetTestRevision(set.C.Revisions))
// remove C group from channel // remove C group from channel
params["groupId"] = set.A.C.GroupId params["groupID"] = set.A.C.GroupID
channel = &Channel{} channel = &Channel{}
assert.NoError(t, ApiTestMsg(ClearChannelGroup, "DELETE", "/content/channels/{channelId}/groups/{groupId}", assert.NoError(t, APITestMsg(ClearChannelGroup, "DELETE", "/content/channels/{channelID}/groups/{groupID}",
&params, nil, APP_TOKENAGENT, set.A.Token, channel, nil)) &params, nil, APP_TOKENAGENT, set.A.Token, channel, nil))
assert.Equal(t, 0, len(channel.Data.ChannelDetail.Contacts.Cards)) assert.Equal(t, 0, len(channel.Data.ChannelDetail.Contacts.Cards))
assert.Equal(t, 0, len(channel.Data.ChannelDetail.Contacts.Groups)) assert.Equal(t, 0, len(channel.Data.ChannelDetail.Contacts.Groups))

View File

@ -6,8 +6,8 @@ import (
) )
func TestContactApp(t *testing.T) { func TestContactApp(t *testing.T) {
var params *TestApiParams var params *TestAPIParams
var response *TestApiResponse var response *TestAPIResponse
// allocate test accounts // allocate test accounts
set, err := AddTestGroup("contactapp") set, err := AddTestGroup("contactapp")
@ -30,7 +30,7 @@ func TestContactApp(t *testing.T) {
Name: "Roland", Name: "Roland",
Location: "San Diago", Location: "San Diago",
}; };
assert.NoError(t, ApiTestMsg(SetProfile, "PUT", "/profile/data", nil, profileData, assert.NoError(t, APITestMsg(SetProfile, "PUT", "/profile/data", nil, profileData,
APP_TOKENAGENT, set.A.Token, nil, nil)) APP_TOKENAGENT, set.A.Token, nil, nil))
// wait for test // wait for test
@ -44,13 +44,13 @@ func TestContactApp(t *testing.T) {
// add a new article // add a new article
article := &Article{} article := &Article{}
subject := &Subject{ Data: "subjectdata", DataType: "subjectdatatype" } subject := &Subject{ Data: "subjectdata", DataType: "subjectdatatype" }
params = &TestApiParams{ restType: "POST", query: "/articles", tokenType: APP_TOKENAGENT, token: set.A.Token, body: subject } params = &TestAPIParams{ restType: "POST", query: "/articles", tokenType: APP_TOKENAGENT, token: set.A.Token, body: subject }
response = &TestApiResponse{ data: article } response = &TestAPIResponse{ data: article }
assert.NoError(t, TestApiRequest(AddArticle, params, response)) assert.NoError(t, TestAPIRequest(AddArticle, params, response))
// wait for a // wait for a
assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool { assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool {
a, set := testApp.articles[article.Id] a, set := testApp.articles[article.ID]
if set && a.Data.Data == "subjectdata" { if set && a.Data.Data == "subjectdata" {
return true return true
} }
@ -58,14 +58,14 @@ func TestContactApp(t *testing.T) {
})) }))
// remove a new article // remove a new article
params = &TestApiParams{ restType: "DELETE", query: "/articles/{articleId}", path: map[string]string{ "articleId": article.Id }, params = &TestAPIParams{ restType: "DELETE", query: "/articles/{articleID}", path: map[string]string{ "articleID": article.ID },
tokenType: APP_TOKENAGENT, token: set.A.Token, body: subject } tokenType: APP_TOKENAGENT, token: set.A.Token, body: subject }
response = &TestApiResponse{} response = &TestAPIResponse{}
assert.NoError(t, TestApiRequest(RemoveArticle, params, response)) assert.NoError(t, TestAPIRequest(RemoveArticle, params, response))
// wait for a to be removed // wait for a to be removed
assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool { assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool {
if _, set := testApp.articles[article.Id]; !set { if _, set := testApp.articles[article.ID]; !set {
return true return true
} }
return false return false
@ -74,23 +74,23 @@ func TestContactApp(t *testing.T) {
// add a new article in contact // add a new article in contact
article = &Article{} article = &Article{}
subject = &Subject{ Data: "subjectdataB", DataType: "subjectdatatypeB" } subject = &Subject{ Data: "subjectdataB", DataType: "subjectdatatypeB" }
params = &TestApiParams{ restType: "POST", query: "/articles", tokenType: APP_TOKENAGENT, token: set.B.Token, body: subject } params = &TestAPIParams{ restType: "POST", query: "/articles", tokenType: APP_TOKENAGENT, token: set.B.Token, body: subject }
response = &TestApiResponse{ data: article } response = &TestAPIResponse{ data: article }
assert.NoError(t, TestApiRequest(AddArticle, params, response)) assert.NoError(t, TestAPIRequest(AddArticle, params, response))
articleId := article.Id articleID := article.ID
// share article // share article
article = &Article{} article = &Article{}
params = &TestApiParams{ restType: "POST", query: "/articles/{articleId}/groups/{groupId}", tokenType: APP_TOKENAGENT, token: set.B.Token, params = &TestAPIParams{ restType: "POST", query: "/articles/{articleID}/groups/{groupID}", tokenType: APP_TOKENAGENT, token: set.B.Token,
path: map[string]string{ "articleId": articleId, "groupId": set.B.A.GroupId }} path: map[string]string{ "articleID": articleID, "groupID": set.B.A.GroupID }}
response = &TestApiResponse{ data: article } response = &TestAPIResponse{ data: article }
assert.NoError(t, TestApiRequest(SetArticleGroup, params, response)) assert.NoError(t, TestAPIRequest(SetArticleGroup, params, response))
// wait for // wait for
assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool { assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool {
contact, contactSet := testApp.contacts[set.A.B.CardId] contact, contactSet := testApp.contacts[set.A.B.CardID]
if contactSet { if contactSet {
_, articleSet := contact.articles[articleId] _, articleSet := contact.articles[articleID]
if articleSet { if articleSet {
return true return true
} }
@ -100,16 +100,16 @@ func TestContactApp(t *testing.T) {
// remove new article in contact // remove new article in contact
article = &Article{} article = &Article{}
params = &TestApiParams{ restType: "DELETE", query: "/articles/{articleId}", tokenType: APP_TOKENAGENT, token: set.B.Token, params = &TestAPIParams{ restType: "DELETE", query: "/articles/{articleID}", tokenType: APP_TOKENAGENT, token: set.B.Token,
path: map[string]string{ "articleId": articleId }} path: map[string]string{ "articleID": articleID }}
response = &TestApiResponse{ } response = &TestAPIResponse{ }
assert.NoError(t, TestApiRequest(RemoveArticle, params, response)) assert.NoError(t, TestAPIRequest(RemoveArticle, params, response))
// wait for // wait for
assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool { assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool {
contact, contactSet := testApp.contacts[set.A.B.CardId] contact, contactSet := testApp.contacts[set.A.B.CardID]
if contactSet { if contactSet {
_, articleSet := contact.articles[articleId] _, articleSet := contact.articles[articleID]
if !articleSet { if !articleSet {
return true return true
} }
@ -120,23 +120,23 @@ func TestContactApp(t *testing.T) {
// add a new article in contact // add a new article in contact
article = &Article{} article = &Article{}
subject = &Subject{ Data: "subjectdataB", DataType: "subjectdatatypeB" } subject = &Subject{ Data: "subjectdataB", DataType: "subjectdatatypeB" }
params = &TestApiParams{ restType: "POST", query: "/articles", tokenType: APP_TOKENAGENT, token: set.B.Token, body: subject } params = &TestAPIParams{ restType: "POST", query: "/articles", tokenType: APP_TOKENAGENT, token: set.B.Token, body: subject }
response = &TestApiResponse{ data: article } response = &TestAPIResponse{ data: article }
assert.NoError(t, TestApiRequest(AddArticle, params, response)) assert.NoError(t, TestAPIRequest(AddArticle, params, response))
articleId = article.Id articleID = article.ID
// share article // share article
article = &Article{} article = &Article{}
params = &TestApiParams{ restType: "POST", query: "/articles/{articleId}/groups/{groupId}", tokenType: APP_TOKENAGENT, token: set.B.Token, params = &TestAPIParams{ restType: "POST", query: "/articles/{articleID}/groups/{groupID}", tokenType: APP_TOKENAGENT, token: set.B.Token,
path: map[string]string{ "articleId": articleId, "groupId": set.B.A.GroupId }} path: map[string]string{ "articleID": articleID, "groupID": set.B.A.GroupID }}
response = &TestApiResponse{ data: article } response = &TestAPIResponse{ data: article }
assert.NoError(t, TestApiRequest(SetArticleGroup, params, response)) assert.NoError(t, TestAPIRequest(SetArticleGroup, params, response))
// wait for // wait for
assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool { assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool {
contact, contactSet := testApp.contacts[set.A.B.CardId] contact, contactSet := testApp.contacts[set.A.B.CardID]
if contactSet { if contactSet {
_, articleSet := contact.articles[articleId] _, articleSet := contact.articles[articleID]
if articleSet { if articleSet {
return true return true
} }
@ -146,16 +146,16 @@ func TestContactApp(t *testing.T) {
// remove group in contact // remove group in contact
article = &Article{} article = &Article{}
params = &TestApiParams{ restType: "DELETE", query: "/groups/{groupId}", tokenType: APP_TOKENAGENT, token: set.B.Token, params = &TestAPIParams{ restType: "DELETE", query: "/groups/{groupID}", tokenType: APP_TOKENAGENT, token: set.B.Token,
path: map[string]string{ "groupId": set.B.A.GroupId }} path: map[string]string{ "groupID": set.B.A.GroupID }}
response = &TestApiResponse{ } response = &TestAPIResponse{ }
assert.NoError(t, TestApiRequest(RemoveGroup, params, response)) assert.NoError(t, TestAPIRequest(RemoveGroup, params, response))
// wait for // wait for
assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool { assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool {
contact, contactSet := testApp.contacts[set.A.B.CardId] contact, contactSet := testApp.contacts[set.A.B.CardID]
if contactSet { if contactSet {
_, articleSet := contact.articles[articleId] _, articleSet := contact.articles[articleID]
if !articleSet { if !articleSet {
return true return true
} }
@ -165,9 +165,9 @@ func TestContactApp(t *testing.T) {
// update Bs profile // update Bs profile
profileData = &ProfileData{ Name: "contactappname" } profileData = &ProfileData{ Name: "contactappname" }
params = &TestApiParams{ restType: "PUT", query: "/profile/data", tokenType: APP_TOKENAGENT, token: set.B.Token, body: profileData } params = &TestAPIParams{ restType: "PUT", query: "/profile/data", tokenType: APP_TOKENAGENT, token: set.B.Token, body: profileData }
response = &TestApiResponse{} response = &TestAPIResponse{}
assert.NoError(t, TestApiRequest(SetProfile, params, response)) assert.NoError(t, TestAPIRequest(SetProfile, params, response))
// wait for // wait for
assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool { assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool {
@ -181,22 +181,22 @@ func TestContactApp(t *testing.T) {
// disconnect from B // disconnect from B
card := &Card{} card := &Card{}
params = &TestApiParams{ restType: "PUT", query: "/contact/cards/{cardId}/status", tokenType: APP_TOKENAGENT, token: set.B.Token, params = &TestAPIParams{ restType: "PUT", query: "/contact/cards/{cardID}/status", tokenType: APP_TOKENAGENT, token: set.B.Token,
path: map[string]string{ "cardId": set.B.A.CardId }, body: APP_CARDCONFIRMED } path: map[string]string{ "cardID": set.B.A.CardID }, body: APP_CARDCONFIRMED }
response = &TestApiResponse{ data: card } response = &TestAPIResponse{ data: card }
assert.NoError(t, TestApiRequest(SetCardStatus, params, response)) assert.NoError(t, TestAPIRequest(SetCardStatus, params, response))
msg := &DataMessage{} msg := &DataMessage{}
params = &TestApiParams { query: "/contact/cards/{cardId}/closeMessage", tokenType: APP_TOKENAGENT, token: set.B.Token, params = &TestAPIParams { query: "/contact/cards/{cardID}/closeMessage", tokenType: APP_TOKENAGENT, token: set.B.Token,
path: map[string]string{ "cardId": set.B.A.CardId } } path: map[string]string{ "cardID": set.B.A.CardID } }
response = &TestApiResponse{ data: msg } response = &TestAPIResponse{ data: msg }
assert.NoError(t, TestApiRequest(GetCloseMessage, params, response)) assert.NoError(t, TestAPIRequest(GetCloseMessage, params, response))
params = &TestApiParams { restType: "PUT", query: "/contact/closeMessage", body: msg } params = &TestAPIParams { restType: "PUT", query: "/contact/closeMessage", body: msg }
response = &TestApiResponse{} response = &TestAPIResponse{}
assert.NoError(t, TestApiRequest(SetCloseMessage, params, response)) assert.NoError(t, TestAPIRequest(SetCloseMessage, params, response))
// wait for // wait for
assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool { assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool {
contact, contactSet := testApp.contacts[set.A.B.CardId] contact, contactSet := testApp.contacts[set.A.B.CardID]
if contactSet && contact.card.Data.CardDetail.Status == APP_CARDCONFIRMED { if contactSet && contact.card.Data.CardDetail.Status == APP_CARDCONFIRMED {
return true return true
} }

View File

@ -30,17 +30,17 @@ func TestContactSync(t *testing.T) {
// set profile image // set profile image
image := "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" image := "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"
assert.NoError(t, ApiTestMsg(SetProfileImage, "PUT", "/profile/image", assert.NoError(t, APITestMsg(SetProfileImage, "PUT", "/profile/image",
nil, image, APP_TOKENAGENT, set.A.Token, &profile, nil)) nil, image, APP_TOKENAGENT, set.A.Token, &profile, nil))
// sync profile // sync profile
assert.NoError(t, ApiTestMsg(GetProfileMessage, "GET", "/profile/message", assert.NoError(t, APITestMsg(GetProfileMessage, "GET", "/profile/message",
nil, nil, APP_TOKENCONTACT, set.B.A.Token, &msg, nil)) nil, nil, APP_TOKENCONTACT, set.B.A.Token, &msg, nil))
param["cardId"] = set.B.A.CardId param["cardID"] = set.B.A.CardID
assert.NoError(t, ApiTestMsg(SetCardProfile, "PUT", "/contact/cards/{cardId}/profile", assert.NoError(t, APITestMsg(SetCardProfile, "PUT", "/contact/cards/{cardID}/profile",
&param, &msg, APP_TOKENAGENT, set.B.Token, &card, nil)) &param, &msg, APP_TOKENAGENT, set.B.Token, &card, nil))
assert.True(t, card.Data.CardProfile.ImageSet) assert.True(t, card.Data.CardProfile.ImageSet)
data, hdr, res = ApiTestData(GetCardProfileImage, "GET", "/contact/cards/{cardId}/profile/image", data, hdr, res = APITestData(GetCardProfileImage, "GET", "/contact/cards/{cardID}/profile/image",
&param, &data, APP_TOKENAGENT, set.B.Token, 0, 0) &param, &data, APP_TOKENAGENT, set.B.Token, 0, 0)
assert.NoError(t, res) assert.NoError(t, res)
@ -52,122 +52,122 @@ func TestContactSync(t *testing.T) {
// get full card list // get full card list
cards = &[]Card{} cards = &[]Card{}
assert.NoError(t, ApiTestMsg(GetCards, "GET", "/contact/cards", assert.NoError(t, APITestMsg(GetCards, "GET", "/contact/cards",
nil, nil, APP_TOKENAGENT, set.B.Token, cards, &hdr)) nil, nil, APP_TOKENAGENT, set.B.Token, cards, &hdr))
cardRevision = hdr["Card-Revision"][0] cardRevision = hdr["Card-Revision"][0]
cards = &[]Card{} cards = &[]Card{}
assert.NoError(t, ApiTestMsg(GetCards, "GET", "/contact/cards?revision=" + cardRevision, assert.NoError(t, APITestMsg(GetCards, "GET", "/contact/cards?revision=" + cardRevision,
nil, nil, APP_TOKENAGENT, set.B.Token, cards, &hdr)) nil, nil, APP_TOKENAGENT, set.B.Token, cards, &hdr))
cardRevision = hdr["Card-Revision"][0] cardRevision = hdr["Card-Revision"][0]
assert.Equal(t, 0, len(*cards)) // ?? actual 1 assert.Equal(t, 0, len(*cards)) // ?? actual 1
// set card notes // set card notes
GetTestRevision(set.B.Revisions) GetTestRevision(set.B.Revisions)
assert.NoError(t, ApiTestMsg(SetCardNotes, "PUT", "/conact/cards/{cardId}/notes", assert.NoError(t, APITestMsg(SetCardNotes, "PUT", "/conact/cards/{cardID}/notes",
&param, "CardA notes", APP_TOKENAGENT, set.B.Token, &detail, nil)) &param, "CardA notes", APP_TOKENAGENT, set.B.Token, &detail, nil))
rev = GetTestRevision(set.B.Revisions) rev = GetTestRevision(set.B.Revisions)
cards = &[]Card{} cards = &[]Card{}
assert.NoError(t, ApiTestMsg(GetCards, "GET", "/contact/cards?revision=" + cardRevision, assert.NoError(t, APITestMsg(GetCards, "GET", "/contact/cards?revision=" + cardRevision,
nil, nil, APP_TOKENAGENT, set.B.Token, cards, &hdr)) nil, nil, APP_TOKENAGENT, set.B.Token, cards, &hdr))
assert.Equal(t, 1, len(*cards)) assert.Equal(t, 1, len(*cards))
detailRevision = (*cards)[0].Data.DetailRevision detailRevision = (*cards)[0].Data.DetailRevision
// clear card notes // clear card notes
GetTestRevision(set.B.Revisions) GetTestRevision(set.B.Revisions)
assert.NoError(t, ApiTestMsg(ClearCardNotes, "DELETE", "/contact/cards/{cardId}/notes", assert.NoError(t, APITestMsg(ClearCardNotes, "DELETE", "/contact/cards/{cardID}/notes",
&param, nil, APP_TOKENAGENT, set.B.Token, &detail, nil)) &param, nil, APP_TOKENAGENT, set.B.Token, &detail, nil))
assert.NotEqual(t, rev.Card, GetTestRevision(set.B.Revisions).Card) assert.NotEqual(t, rev.Card, GetTestRevision(set.B.Revisions).Card)
cards = &[]Card{} cards = &[]Card{}
assert.NoError(t, ApiTestMsg(GetCards, "GET", "/contact/cards?revision=" + cardRevision, assert.NoError(t, APITestMsg(GetCards, "GET", "/contact/cards?revision=" + cardRevision,
nil, nil, APP_TOKENAGENT, set.B.Token, cards, &hdr)) nil, nil, APP_TOKENAGENT, set.B.Token, cards, &hdr))
assert.Equal(t, 1, len(*cards)) assert.Equal(t, 1, len(*cards))
assert.NotEqual(t, detailRevision, (*cards)[0].Data.DetailRevision) assert.NotEqual(t, detailRevision, (*cards)[0].Data.DetailRevision)
// remove card from group // remove card from group
card = &Card{} card = &Card{}
param["cardId"] = set.B.A.CardId param["cardID"] = set.B.A.CardID
assert.NoError(t, ApiTestMsg(GetCard, "GET", "/contact/cards/{cardId}", assert.NoError(t, APITestMsg(GetCard, "GET", "/contact/cards/{cardID}",
&param, nil, APP_TOKENAGENT, set.B.Token, card, nil)) &param, nil, APP_TOKENAGENT, set.B.Token, card, nil))
assert.Equal(t, "connected", card.Data.CardDetail.Status) assert.Equal(t, "connected", card.Data.CardDetail.Status)
viewRevision = card.Data.NotifiedView viewRevision = card.Data.NotifiedView
card = &Card{} card = &Card{}
param["cardId"] = set.A.B.CardId param["cardID"] = set.A.B.CardID
param["groupId"] = set.A.B.GroupId param["groupID"] = set.A.B.GroupID
assert.NoError(t, ApiTestMsg(ClearCardGroup, "DELETE", "/contact/cards/{cardId}/groups/{groupId}", assert.NoError(t, APITestMsg(ClearCardGroup, "DELETE", "/contact/cards/{cardID}/groups/{groupID}",
&param, nil, APP_TOKENAGENT, set.A.Token, card, nil)) &param, nil, APP_TOKENAGENT, set.A.Token, card, nil))
assert.Equal(t, 0, len(card.Data.CardDetail.Groups)) assert.Equal(t, 0, len(card.Data.CardDetail.Groups))
assert.NotEqual(t, rev.Card, GetTestRevision(set.B.Revisions).Card) assert.NotEqual(t, rev.Card, GetTestRevision(set.B.Revisions).Card)
card = &Card{} card = &Card{}
param["cardId"] = set.B.A.CardId param["cardID"] = set.B.A.CardID
assert.NoError(t, ApiTestMsg(GetCard, "GET", "/contact/cards/{cardId}", assert.NoError(t, APITestMsg(GetCard, "GET", "/contact/cards/{cardID}",
&param, nil, APP_TOKENAGENT, set.B.Token, card, nil)) &param, nil, APP_TOKENAGENT, set.B.Token, card, nil))
assert.NotEqual(t, viewRevision, card.Data.NotifiedView) assert.NotEqual(t, viewRevision, card.Data.NotifiedView)
// disconnect card // disconnect card
card = &Card{} card = &Card{}
param["cardId"] = set.A.B.CardId param["cardID"] = set.A.B.CardID
assert.NoError(t, ApiTestMsg(SetCardStatus, "PUT", "/contact/cards/{cardId}/status", assert.NoError(t, APITestMsg(SetCardStatus, "PUT", "/contact/cards/{cardID}/status",
&param, APP_CARDCONFIRMED, APP_TOKENAGENT, set.A.Token, card, nil)) &param, APP_CARDCONFIRMED, APP_TOKENAGENT, set.A.Token, card, nil))
assert.NoError(t, ApiTestMsg(GetCloseMessage, "GET", "/contact/cards/{cardId}/closeMessage", assert.NoError(t, APITestMsg(GetCloseMessage, "GET", "/contact/cards/{cardID}/closeMessage",
&param, nil, APP_TOKENAGENT, set.A.Token, &msg, nil)) &param, nil, APP_TOKENAGENT, set.A.Token, &msg, nil))
assert.NoError(t, ApiTestMsg(SetCloseMessage, "GET", "/contact/closeMessage", assert.NoError(t, APITestMsg(SetCloseMessage, "GET", "/contact/closeMessage",
nil, &msg, "", "", nil, nil)) nil, &msg, "", "", nil, nil))
assert.NotNil(t, GetTestRevision(set.B.Revisions)) assert.NotNil(t, GetTestRevision(set.B.Revisions))
card = &Card{} card = &Card{}
param["cardId"] = set.B.A.CardId param["cardID"] = set.B.A.CardID
assert.NoError(t, ApiTestMsg(GetCard, "GET", "/contact/cards/{cardId}", assert.NoError(t, APITestMsg(GetCard, "GET", "/contact/cards/{cardID}",
&param, nil, APP_TOKENAGENT, set.B.Token, card, nil)) &param, nil, APP_TOKENAGENT, set.B.Token, card, nil))
assert.Equal(t, "confirmed", card.Data.CardDetail.Status) assert.Equal(t, "confirmed", card.Data.CardDetail.Status)
// cancel request // cancel request
card = &Card{} card = &Card{}
param["cardId"] = set.D.A.CardId param["cardID"] = set.D.A.CardID
assert.NoError(t, ApiTestMsg(GetCard, "GET", "/contact/cards/{cardId}", assert.NoError(t, APITestMsg(GetCard, "GET", "/contact/cards/{cardID}",
&param, nil, APP_TOKENAGENT, set.D.Token, card, nil)) &param, nil, APP_TOKENAGENT, set.D.Token, card, nil))
param["cardId"] = set.A.D.CardId param["cardID"] = set.A.D.CardID
assert.NoError(t, ApiTestMsg(SetCardStatus, "PUT", "/contact/cards/{cardId}/status", assert.NoError(t, APITestMsg(SetCardStatus, "PUT", "/contact/cards/{cardID}/status",
&param, APP_CARDCONFIRMED, APP_TOKENAGENT, set.A.Token, card, nil)) &param, APP_CARDCONFIRMED, APP_TOKENAGENT, set.A.Token, card, nil))
assert.NoError(t, ApiTestMsg(GetCloseMessage, "GET", "/contact/cards/{cardId}/closeMessage", assert.NoError(t, APITestMsg(GetCloseMessage, "GET", "/contact/cards/{cardID}/closeMessage",
&param, nil, APP_TOKENAGENT, set.A.Token, &msg, nil)) &param, nil, APP_TOKENAGENT, set.A.Token, &msg, nil))
assert.NoError(t, ApiTestMsg(SetCloseMessage, "GET", "/contact/closeMessage", assert.NoError(t, APITestMsg(SetCloseMessage, "GET", "/contact/closeMessage",
nil, &msg, "", "", nil, nil)) nil, &msg, "", "", nil, nil))
// delete card // delete card
param["cardId"] = set.A.C.CardId param["cardID"] = set.A.C.CardID
assert.NoError(t, ApiTestMsg(RemoveCard, "DELETE", "/contact/cards/{cardId}", assert.NoError(t, APITestMsg(RemoveCard, "DELETE", "/contact/cards/{cardID}",
&param, nil, APP_TOKENAGENT, set.A.Token, nil, nil)) &param, nil, APP_TOKENAGENT, set.A.Token, nil, nil))
card = &Card{} card = &Card{}
assert.NoError(t, ApiTestMsg(GetCard, "GET", "/contact/cards/{cardId}", assert.NoError(t, APITestMsg(GetCard, "GET", "/contact/cards/{cardID}",
&param, nil, APP_TOKENAGENT, set.A.Token, card, nil)) &param, nil, APP_TOKENAGENT, set.A.Token, card, nil))
assert.Nil(t, card.Data) assert.Nil(t, card.Data)
// update and delete group // update and delete group
param["groupId"] = set.D.C.GroupId param["groupID"] = set.D.C.GroupID
subject := &Subject{ DataType: "contactsynctype", Data: "contactsyncdata" } subject := &Subject{ DataType: "contactsynctype", Data: "contactsyncdata" }
assert.NoError(t, ApiTestMsg(SetGroupSubject, "PUT", "/alias/groups/{groupId}", assert.NoError(t, APITestMsg(SetGroupSubject, "PUT", "/alias/groups/{groupID}",
&param, subject, APP_TOKENAGENT, set.D.Token, nil, nil)) &param, subject, APP_TOKENAGENT, set.D.Token, nil, nil))
groups = &[]Group{} groups = &[]Group{}
assert.NoError(t, ApiTestMsg(GetGroups, "GET", "/alias/groups", assert.NoError(t, APITestMsg(GetGroups, "GET", "/alias/groups",
nil, nil, APP_TOKENAGENT, set.D.Token, groups, nil)) nil, nil, APP_TOKENAGENT, set.D.Token, groups, nil))
assert.Equal(t, 1, len(*groups)) assert.Equal(t, 1, len(*groups))
assert.Equal(t, "contactsynctype", (*groups)[0].Data.DataType) assert.Equal(t, "contactsynctype", (*groups)[0].Data.DataType)
assert.Equal(t, "contactsyncdata", (*groups)[0].Data.Data) assert.Equal(t, "contactsyncdata", (*groups)[0].Data.Data)
rev = GetTestRevision(set.C.Revisions) rev = GetTestRevision(set.C.Revisions)
card = &Card{} card = &Card{}
param["cardId"] = set.C.D.CardId param["cardID"] = set.C.D.CardID
assert.NoError(t, ApiTestMsg(GetCard, "GET", "/contact/cards/{cardId}", assert.NoError(t, APITestMsg(GetCard, "GET", "/contact/cards/{cardID}",
&param, nil, APP_TOKENAGENT, set.C.Token, card, nil)) &param, nil, APP_TOKENAGENT, set.C.Token, card, nil))
viewRevision = card.Data.NotifiedView viewRevision = card.Data.NotifiedView
param["groupId"] = set.D.C.GroupId param["groupID"] = set.D.C.GroupID
assert.NoError(t, ApiTestMsg(RemoveGroup, "GET", "/alias/groups/{groupId}", assert.NoError(t, APITestMsg(RemoveGroup, "GET", "/alias/groups/{groupID}",
&param, nil, APP_TOKENAGENT, set.D.Token, nil, nil)) &param, nil, APP_TOKENAGENT, set.D.Token, nil, nil))
groups = &[]Group{} groups = &[]Group{}
assert.NoError(t, ApiTestMsg(GetGroups, "GET", "/alias/groups", assert.NoError(t, APITestMsg(GetGroups, "GET", "/alias/groups",
nil, nil, APP_TOKENAGENT, set.D.Token, groups, nil)) nil, nil, APP_TOKENAGENT, set.D.Token, groups, nil))
assert.Equal(t, 0, len(*groups)) assert.Equal(t, 0, len(*groups))
assert.NotEqual(t, rev.Card, GetTestRevision(set.C.Revisions).Card) assert.NotEqual(t, rev.Card, GetTestRevision(set.C.Revisions).Card)
card = &Card{} card = &Card{}
assert.NoError(t, ApiTestMsg(GetCard, "GET", "/contact/cards/{cardId}", assert.NoError(t, APITestMsg(GetCard, "GET", "/contact/cards/{cardID}",
&param, nil, APP_TOKENAGENT, set.C.Token, card, nil)) &param, nil, APP_TOKENAGENT, set.C.Token, card, nil))
assert.NotEqual(t, viewRevision, card.Data.NotifiedView) assert.NotEqual(t, viewRevision, card.Data.NotifiedView)
} }

View File

@ -6,8 +6,8 @@ import (
) )
func TestMessangerApp(t *testing.T) { func TestMessangerApp(t *testing.T) {
var params *TestApiParams var params *TestAPIParams
var response *TestApiResponse var response *TestAPIResponse
var channel *Channel var channel *Channel
var topic *Topic var topic *Topic
var tag *Tag var tag *Tag
@ -29,7 +29,7 @@ func TestMessangerApp(t *testing.T) {
})) }))
// set profile // set profile
params = &TestApiParams{ params = &TestAPIParams{
restType: "PUT", restType: "PUT",
query: "/profile/data", query: "/profile/data",
body: &ProfileData{ body: &ProfileData{
@ -39,8 +39,8 @@ func TestMessangerApp(t *testing.T) {
tokenType: APP_TOKENAGENT, tokenType: APP_TOKENAGENT,
token: set.A.Token, token: set.A.Token,
} }
response = &TestApiResponse{} response = &TestAPIResponse{}
assert.NoError(t, TestApiRequest(SetProfile, params, response)) assert.NoError(t, TestAPIRequest(SetProfile, params, response))
// wait for test // wait for test
assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool{ assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool{
@ -51,7 +51,7 @@ func TestMessangerApp(t *testing.T) {
})) }))
// add a channel // add a channel
params = &TestApiParams{ params = &TestAPIParams{
restType: "POST", restType: "POST",
query: "/content/channels", query: "/content/channels",
body: &Subject{ body: &Subject{
@ -62,13 +62,13 @@ func TestMessangerApp(t *testing.T) {
token: set.A.Token, token: set.A.Token,
} }
channel = &Channel{} channel = &Channel{}
response = &TestApiResponse{ data: channel } response = &TestAPIResponse{ data: channel }
assert.NoError(t, TestApiRequest(AddChannel, params, response)) assert.NoError(t, TestAPIRequest(AddChannel, params, response))
// wait for test // wait for test
assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool{ assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool{
for _, c := range testApp.channels { for _, c := range testApp.channels {
if c.channel.Id == channel.Id { if c.channel.ID == channel.ID {
return true return true
} }
} }
@ -76,10 +76,10 @@ func TestMessangerApp(t *testing.T) {
})) }))
// add a topic to channel // add a topic to channel
params = &TestApiParams{ params = &TestAPIParams{
restType: "POST", restType: "POST",
query: "/content/channels/{channelId}/topics", query: "/content/channels/{channelID}/topics",
path: map[string]string{ "channelId": channel.Id }, path: map[string]string{ "channelID": channel.ID },
body: &Subject{ body: &Subject{
Data: "channeltopicdataA", Data: "channeltopicdataA",
DataType: "channeltopicdatatypeA", DataType: "channeltopicdatatypeA",
@ -88,15 +88,15 @@ func TestMessangerApp(t *testing.T) {
token: set.A.Token, token: set.A.Token,
} }
topic = &Topic{} topic = &Topic{}
response = &TestApiResponse{ data: topic } response = &TestAPIResponse{ data: topic }
assert.NoError(t, TestApiRequest(AddChannelTopic, params, response)) assert.NoError(t, TestAPIRequest(AddChannelTopic, params, response))
// wait for test // wait for test
assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool{ assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool{
for _, c := range testApp.channels { for _, c := range testApp.channels {
if c.channel.Id == channel.Id { if c.channel.ID == channel.ID {
for _, t := range c.topics { for _, t := range c.topics {
if t.topic.Id == topic.Id { if t.topic.ID == topic.ID {
return true return true
} }
} }
@ -106,10 +106,10 @@ func TestMessangerApp(t *testing.T) {
})) }))
// add a tag to channel topic // add a tag to channel topic
params = &TestApiParams{ params = &TestAPIParams{
restType: "POST", restType: "POST",
query: "/content/channels/{channelId}/topics/{topicId}/tags", query: "/content/channels/{channelID}/topics/{topicID}/tags",
path: map[string]string{ "channelId": channel.Id, "topicId": topic.Id }, path: map[string]string{ "channelID": channel.ID, "topicID": topic.ID },
body: &Subject{ body: &Subject{
Data: "channeltopictagdataA", Data: "channeltopictagdataA",
DataType: "channeltopictagdatatypeA", DataType: "channeltopictagdatatypeA",
@ -118,17 +118,17 @@ func TestMessangerApp(t *testing.T) {
token: set.A.Token, token: set.A.Token,
} }
tag = &Tag{} tag = &Tag{}
response = &TestApiResponse{ data: tag } response = &TestAPIResponse{ data: tag }
assert.NoError(t, TestApiRequest(AddChannelTopicTag, params, response)) assert.NoError(t, TestAPIRequest(AddChannelTopicTag, params, response))
// wait for test // wait for test
assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool{ assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool{
for _, testChannel := range testApp.channels { for _, testChannel := range testApp.channels {
if testChannel.channel.Id == channel.Id { if testChannel.channel.ID == channel.ID {
for _, testTopic := range testChannel.topics { for _, testTopic := range testChannel.topics {
if testTopic.topic.Id == topic.Id { if testTopic.topic.ID == topic.ID {
for _, testTag := range testTopic.tags { for _, testTag := range testTopic.tags {
if testTag.Id == tag.Id { if testTag.ID == tag.ID {
return true return true
} }
} }
@ -141,7 +141,7 @@ func TestMessangerApp(t *testing.T) {
// add a channel // add a channel
params = &TestApiParams{ params = &TestAPIParams{
restType: "POST", restType: "POST",
query: "/content/channels", query: "/content/channels",
body: &Subject{ body: &Subject{
@ -152,26 +152,26 @@ func TestMessangerApp(t *testing.T) {
token: set.B.Token, token: set.B.Token,
} }
channel = &Channel{} channel = &Channel{}
response = &TestApiResponse{ data: channel } response = &TestAPIResponse{ data: channel }
assert.NoError(t, TestApiRequest(AddChannel, params, response)) assert.NoError(t, TestAPIRequest(AddChannel, params, response))
// share channel with A // share channel with A
params = &TestApiParams{ params = &TestAPIParams{
restType: "PUT", restType: "PUT",
query: "/content/channels/{channelId}/cards/{cardId}", query: "/content/channels/{channelID}/cards/{cardID}",
path: map[string]string{ "cardId": set.B.A.CardId, "channelId": channel.Id }, path: map[string]string{ "cardID": set.B.A.CardID, "channelID": channel.ID },
tokenType: APP_TOKENAGENT, tokenType: APP_TOKENAGENT,
token: set.B.Token, token: set.B.Token,
} }
response = &TestApiResponse{} response = &TestAPIResponse{}
assert.NoError(t, TestApiRequest(SetChannelCard, params, response)) assert.NoError(t, TestAPIRequest(SetChannelCard, params, response))
// wait for test // wait for test
assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool{ assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool{
for _, testContact := range testApp.contacts { for _, testContact := range testApp.contacts {
if testContact.card.Id == set.A.B.CardId { if testContact.card.ID == set.A.B.CardID {
for _, testChannel := range testContact.channels { for _, testChannel := range testContact.channels {
if testChannel.channel.Id == channel.Id { if testChannel.channel.ID == channel.ID {
return true return true
} }
} }
@ -181,10 +181,10 @@ func TestMessangerApp(t *testing.T) {
})) }))
// add a topic to channel // add a topic to channel
params = &TestApiParams{ params = &TestAPIParams{
restType: "POST", restType: "POST",
query: "/content/channels/{channelId}/topics", query: "/content/channels/{channelID}/topics",
path: map[string]string{ "channelId": channel.Id }, path: map[string]string{ "channelID": channel.ID },
body: &Subject{ body: &Subject{
Data: "channeltopicdataB", Data: "channeltopicdataB",
DataType: "channeltopicdatatypeB", DataType: "channeltopicdatatypeB",
@ -193,17 +193,17 @@ func TestMessangerApp(t *testing.T) {
token: set.A.B.Token, token: set.A.B.Token,
} }
topic = &Topic{} topic = &Topic{}
response = &TestApiResponse{ data: topic } response = &TestAPIResponse{ data: topic }
assert.NoError(t, TestApiRequest(AddChannelTopic, params, response)) assert.NoError(t, TestAPIRequest(AddChannelTopic, params, response))
// wait for test // wait for test
assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool{ assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool{
for _, testContact := range testApp.contacts { for _, testContact := range testApp.contacts {
if testContact.card.Id == set.A.B.CardId { if testContact.card.ID == set.A.B.CardID {
for _, testChannel := range testContact.channels { for _, testChannel := range testContact.channels {
if testChannel.channel.Id == channel.Id { if testChannel.channel.ID == channel.ID {
for _, t := range testChannel.topics { for _, t := range testChannel.topics {
if t.topic.Id == topic.Id { if t.topic.ID == topic.ID {
return true return true
} }
} }
@ -215,10 +215,10 @@ func TestMessangerApp(t *testing.T) {
})) }))
// add a tag to channel topic // add a tag to channel topic
params = &TestApiParams{ params = &TestAPIParams{
restType: "POST", restType: "POST",
query: "/content/channels/{channelId}/topics/{topicId}/tags", query: "/content/channels/{channelID}/topics/{topicID}/tags",
path: map[string]string{ "channelId": channel.Id, "topicId": topic.Id }, path: map[string]string{ "channelID": channel.ID, "topicID": topic.ID },
body: &Subject{ body: &Subject{
Data: "channeltopictagdataB", Data: "channeltopictagdataB",
DataType: "channeltopictagdatatypeB", DataType: "channeltopictagdatatypeB",
@ -227,19 +227,19 @@ func TestMessangerApp(t *testing.T) {
token: set.B.Token, token: set.B.Token,
} }
tag = &Tag{} tag = &Tag{}
response = &TestApiResponse{ data: tag } response = &TestAPIResponse{ data: tag }
assert.NoError(t, TestApiRequest(AddChannelTopicTag, params, response)) assert.NoError(t, TestAPIRequest(AddChannelTopicTag, params, response))
// wait for test // wait for test
assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool{ assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool{
for _, testContact := range testApp.contacts { for _, testContact := range testApp.contacts {
if testContact.card.Id == set.A.B.CardId { if testContact.card.ID == set.A.B.CardID {
for _, testChannel := range testContact.channels { for _, testChannel := range testContact.channels {
if testChannel.channel.Id == channel.Id { if testChannel.channel.ID == channel.ID {
for _, testTopic := range testChannel.topics { for _, testTopic := range testChannel.topics {
if testTopic.topic.Id == topic.Id { if testTopic.topic.ID == topic.ID {
for _, testTag := range testTopic.tags { for _, testTag := range testTopic.tags {
if testTag.Id == tag.Id { if testTag.ID == tag.ID {
return true return true
} }
} }
@ -253,21 +253,21 @@ func TestMessangerApp(t *testing.T) {
})) }))
// unshare channel with A // unshare channel with A
params = &TestApiParams{ params = &TestAPIParams{
restType: "DELETE", restType: "DELETE",
query: "/content/channels/{channelId}/cards/{cardId}", query: "/content/channels/{channelID}/cards/{cardID}",
path: map[string]string{ "cardId": set.B.A.CardId, "channelId": channel.Id }, path: map[string]string{ "cardID": set.B.A.CardID, "channelID": channel.ID },
tokenType: APP_TOKENAGENT, tokenType: APP_TOKENAGENT,
token: set.B.Token, token: set.B.Token,
} }
response = &TestApiResponse{} response = &TestAPIResponse{}
assert.NoError(t, TestApiRequest(ClearChannelCard, params, response)) assert.NoError(t, TestAPIRequest(ClearChannelCard, params, response))
// wait for test // wait for test
assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool { assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool {
contact, contactSet := testApp.contacts[set.A.B.CardId] contact, contactSet := testApp.contacts[set.A.B.CardID]
if contactSet { if contactSet {
_, channelSet := contact.channels[channel.Id] _, channelSet := contact.channels[channel.ID]
if !channelSet { if !channelSet {
return true return true
} }

View File

@ -31,13 +31,13 @@ func TestProfileUpdate(t *testing.T) {
// reset revision // reset revision
bCardRev = GetTestRevision(set.B.Revisions).Card bCardRev = GetTestRevision(set.B.Revisions).Card
cCardRev = GetTestRevision(set.C.Revisions).Card cCardRev = GetTestRevision(set.C.Revisions).Card
param["cardId"] = set.B.A.CardId param["cardID"] = set.B.A.CardID
assert.NoError(t, ApiTestMsg(GetCard, "GET", "/contact/cards/{cardId}", assert.NoError(t, APITestMsg(GetCard, "GET", "/contact/cards/{cardID}",
&param, nil, &param, nil,
APP_TOKENAGENT, set.B.Token, &card, nil)) APP_TOKENAGENT, set.B.Token, &card, nil))
bProfileRev = card.Data.NotifiedProfile bProfileRev = card.Data.NotifiedProfile
param["cardId"] = set.C.A.CardId param["cardID"] = set.C.A.CardID
assert.NoError(t, ApiTestMsg(GetCard, "GET", "/contact/cards/{cardId}", assert.NoError(t, APITestMsg(GetCard, "GET", "/contact/cards/{cardID}",
&param, nil, &param, nil,
APP_TOKENAGENT, set.C.Token, &card, nil)) APP_TOKENAGENT, set.C.Token, &card, nil))
cProfileRev = card.Data.NotifiedProfile cProfileRev = card.Data.NotifiedProfile
@ -48,7 +48,7 @@ func TestProfileUpdate(t *testing.T) {
Location: "San Diago", Location: "San Diago",
Description: "databaggerr", Description: "databaggerr",
}; };
assert.NoError(t, ApiTestMsg(SetProfile, "PUT", "/profile/data", assert.NoError(t, APITestMsg(SetProfile, "PUT", "/profile/data",
nil, profileData, nil, profileData,
APP_TOKENAGENT, set.A.Token, &profile, nil)) APP_TOKENAGENT, set.A.Token, &profile, nil))
assert.Equal(t, "databaggerr", profile.Description) assert.Equal(t, "databaggerr", profile.Description)
@ -58,51 +58,51 @@ func TestProfileUpdate(t *testing.T) {
assert.NotEqual(t, cCardRev, GetTestRevision(set.C.Revisions).Card) assert.NotEqual(t, cCardRev, GetTestRevision(set.C.Revisions).Card)
// check B notified // check B notified
param["cardId"] = set.B.A.CardId param["cardID"] = set.B.A.CardID
assert.NoError(t, ApiTestMsg(GetCard, "GET", "/contact/cards/{cardId}", assert.NoError(t, APITestMsg(GetCard, "GET", "/contact/cards/{cardID}",
&param, nil, &param, nil,
APP_TOKENAGENT, set.B.Token, &card, nil)) APP_TOKENAGENT, set.B.Token, &card, nil))
assert.NotEqual(t, bProfileRev, card.Data.NotifiedProfile) assert.NotEqual(t, bProfileRev, card.Data.NotifiedProfile)
assert.NotEqual(t, card.Data.ProfileRevision, card.Data.NotifiedProfile) assert.NotEqual(t, card.Data.ProfileRevision, card.Data.NotifiedProfile)
// check C notified // check C notified
param["cardId"] = set.C.A.CardId param["cardID"] = set.C.A.CardID
assert.NoError(t, ApiTestMsg(GetCard, "GET", "/contact/cards/{cardId}", assert.NoError(t, APITestMsg(GetCard, "GET", "/contact/cards/{cardID}",
&param, nil, &param, nil,
APP_TOKENAGENT, set.C.Token, &card, nil)) APP_TOKENAGENT, set.C.Token, &card, nil))
assert.NotEqual(t, cProfileRev, card.Data.NotifiedProfile) assert.NotEqual(t, cProfileRev, card.Data.NotifiedProfile)
assert.NotEqual(t, card.Data.ProfileRevision, card.Data.NotifiedProfile) assert.NotEqual(t, card.Data.ProfileRevision, card.Data.NotifiedProfile)
// sync profile // sync profile
assert.NoError(t, ApiTestMsg(GetProfileMessage, "GET", "/profile/message", assert.NoError(t, APITestMsg(GetProfileMessage, "GET", "/profile/message",
nil, nil, nil, nil,
APP_TOKENCONTACT, set.B.A.Token, &msg, nil)) APP_TOKENCONTACT, set.B.A.Token, &msg, nil))
assert.NoError(t, ApiTestMsg(AddCard, "POST", "/contact/cards", assert.NoError(t, APITestMsg(AddCard, "POST", "/contact/cards",
nil, &msg, nil, &msg,
APP_TOKENAGENT, set.B.Token, &card, nil)) APP_TOKENAGENT, set.B.Token, &card, nil))
assert.Equal(t, card.Id, set.B.A.CardId) assert.Equal(t, card.ID, set.B.A.CardID)
assert.Equal(t, card.Data.ProfileRevision, card.Data.NotifiedProfile) assert.Equal(t, card.Data.ProfileRevision, card.Data.NotifiedProfile)
assert.Equal(t, card.Data.CardProfile.Name, "Namer") assert.Equal(t, card.Data.CardProfile.Name, "Namer")
// sync profile // sync profile
assert.NoError(t, ApiTestMsg(GetProfileMessage, "GET", "/profile/message", assert.NoError(t, APITestMsg(GetProfileMessage, "GET", "/profile/message",
nil, nil, nil, nil,
APP_TOKENCONTACT, set.C.A.Token, &msg, nil)) APP_TOKENCONTACT, set.C.A.Token, &msg, nil))
assert.NoError(t, ApiTestMsg(AddCard, "POST", "/contact/cards", assert.NoError(t, APITestMsg(AddCard, "POST", "/contact/cards",
nil, &msg, nil, &msg,
APP_TOKENAGENT, set.C.Token, &card, nil)) APP_TOKENAGENT, set.C.Token, &card, nil))
assert.Equal(t, card.Id, set.C.A.CardId) assert.Equal(t, card.ID, set.C.A.CardID)
assert.Equal(t, card.Data.ProfileRevision, card.Data.NotifiedProfile) assert.Equal(t, card.Data.ProfileRevision, card.Data.NotifiedProfile)
assert.Equal(t, card.Data.CardProfile.Name, "Namer") assert.Equal(t, card.Data.CardProfile.Name, "Namer")
// set profile image // set profile image
image := "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" image := "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"
assert.NoError(t, ApiTestMsg(SetProfileImage, "PUT", "/profile/image", assert.NoError(t, APITestMsg(SetProfileImage, "PUT", "/profile/image",
nil, image, nil, image,
APP_TOKENAGENT, set.A.Token, &profile, nil)) APP_TOKENAGENT, set.A.Token, &profile, nil))
// retrieve profile image // retrieve profile image
data, hdr, err = ApiTestData(GetProfileImage, "GET", "/profile/image?agent=" + set.A.Token, nil, nil, data, hdr, err = APITestData(GetProfileImage, "GET", "/profile/image?agent=" + set.A.Token, nil, nil,
APP_TOKENAGENT, set.A.Token, 0, 0) APP_TOKENAGENT, set.A.Token, 0, 0)
assert.NoError(t, err) assert.NoError(t, err)

View File

@ -7,8 +7,8 @@ import (
) )
func TestStaggardLoad(t *testing.T) { func TestStaggardLoad(t *testing.T) {
var params *TestApiParams var params *TestAPIParams
var response *TestApiResponse var response *TestAPIResponse
var channel *Channel var channel *Channel
var topic *Topic var topic *Topic
var topics *[]Topic var topics *[]Topic
@ -30,7 +30,7 @@ func TestStaggardLoad(t *testing.T) {
})) }))
// add a channel // add a channel
params = &TestApiParams{ params = &TestAPIParams{
restType: "POST", restType: "POST",
query: "/content/channels", query: "/content/channels",
body: &Subject{ body: &Subject{
@ -41,13 +41,13 @@ func TestStaggardLoad(t *testing.T) {
token: set.A.Token, token: set.A.Token,
} }
channel = &Channel{} channel = &Channel{}
response = &TestApiResponse{ data: channel } response = &TestAPIResponse{ data: channel }
assert.NoError(t, TestApiRequest(AddChannel, params, response)) assert.NoError(t, TestAPIRequest(AddChannel, params, response))
// wait for test // wait for test
assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool{ assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool{
for _, c := range testApp.channels { for _, c := range testApp.channels {
if c.channel.Id == channel.Id { if c.channel.ID == channel.ID {
return true return true
} }
} }
@ -57,10 +57,10 @@ func TestStaggardLoad(t *testing.T) {
// add a topic to channel // add a topic to channel
ids := []string{} ids := []string{}
for i := 0; i < 128; i++ { for i := 0; i < 128; i++ {
params = &TestApiParams{ params = &TestAPIParams{
restType: "POST", restType: "POST",
query: "/content/channels/{channelId}/topics", query: "/content/channels/{channelID}/topics",
path: map[string]string{ "channelId": channel.Id }, path: map[string]string{ "channelID": channel.ID },
body: &Subject{ body: &Subject{
Data: strconv.Itoa(i), Data: strconv.Itoa(i),
DataType: "channeltopicdatatypeA", DataType: "channeltopicdatatypeA",
@ -69,15 +69,15 @@ func TestStaggardLoad(t *testing.T) {
token: set.A.Token, token: set.A.Token,
} }
topic = &Topic{} topic = &Topic{}
response = &TestApiResponse{ data: topic } response = &TestAPIResponse{ data: topic }
assert.NoError(t, TestApiRequest(AddChannelTopic, params, response)) assert.NoError(t, TestAPIRequest(AddChannelTopic, params, response))
ids = append(ids, topic.Id); ids = append(ids, topic.ID);
} }
// wait for test // wait for test
assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool{ assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool{
for _, c := range testApp.channels { for _, c := range testApp.channels {
if c.channel.Id == channel.Id { if c.channel.ID == channel.ID {
if len(c.topics) == 128 { if len(c.topics) == 128 {
return true return true
} }
@ -86,90 +86,90 @@ func TestStaggardLoad(t *testing.T) {
return false return false
})) }))
params = &TestApiParams { params = &TestAPIParams {
restType: "GET", restType: "GET",
query: "/content/channels/{channelId}/topics", query: "/content/channels/{channelID}/topics",
path: map[string]string{ "channelId": channel.Id, "topicId": topic.Id }, path: map[string]string{ "channelID": channel.ID, "topicID": topic.ID },
tokenType: APP_TOKENAGENT, tokenType: APP_TOKENAGENT,
token: set.A.Token, token: set.A.Token,
} }
topics = &[]Topic{} topics = &[]Topic{}
response = &TestApiResponse{ data: topics } response = &TestAPIResponse{ data: topics }
assert.NoError(t, TestApiRequest(GetChannelTopics, params, response)); assert.NoError(t, TestAPIRequest(GetChannelTopics, params, response));
assert.Equal(t, len(*topics), 128); assert.Equal(t, len(*topics), 128);
params = &TestApiParams { params = &TestAPIParams {
restType: "GET", restType: "GET",
query: "/content/channels/{channelId}/topics?count=13", query: "/content/channels/{channelID}/topics?count=13",
path: map[string]string{ "channelId": channel.Id, "topicId": topic.Id }, path: map[string]string{ "channelID": channel.ID, "topicID": topic.ID },
tokenType: APP_TOKENAGENT, tokenType: APP_TOKENAGENT,
token: set.A.Token, token: set.A.Token,
} }
topics = &[]Topic{} topics = &[]Topic{}
response = &TestApiResponse{ data: topics } response = &TestAPIResponse{ data: topics }
assert.NoError(t, TestApiRequest(GetChannelTopics, params, response)); assert.NoError(t, TestAPIRequest(GetChannelTopics, params, response));
assert.Equal(t, len(*topics), 13); assert.Equal(t, len(*topics), 13);
//marker, _ := strconv.Atoi(response.header["Topic-Marker"][0]) //marker, _ := strconv.Atoi(response.header["Topic-Marker"][0])
//revision, _ := strconv.Atoi(response.header["Topic-Revision"][0]) //revision, _ := strconv.Atoi(response.header["Topic-Revision"][0])
params = &TestApiParams { params = &TestAPIParams {
restType: "GET", restType: "GET",
query: "/content/channels/{channelId}/topics?count=13&end=" + response.header["Topic-Marker"][0], query: "/content/channels/{channelID}/topics?count=13&end=" + response.header["Topic-Marker"][0],
path: map[string]string{ "channelId": channel.Id, "topicId": topic.Id }, path: map[string]string{ "channelID": channel.ID, "topicID": topic.ID },
tokenType: APP_TOKENAGENT, tokenType: APP_TOKENAGENT,
token: set.A.Token, token: set.A.Token,
} }
topics = &[]Topic{} topics = &[]Topic{}
response = &TestApiResponse{ data: topics } response = &TestAPIResponse{ data: topics }
assert.NoError(t, TestApiRequest(GetChannelTopics, params, response)); assert.NoError(t, TestAPIRequest(GetChannelTopics, params, response));
assert.Equal(t, len(*topics), 13); assert.Equal(t, len(*topics), 13);
marker := response.header["Topic-Marker"][0] marker := response.header["Topic-Marker"][0]
revision := response.header["Topic-Revision"][0] revision := response.header["Topic-Revision"][0]
params = &TestApiParams { params = &TestAPIParams {
restType: "DELETE", restType: "DELETE",
query: "/content/channels/{channelId}/topics/{topicId}", query: "/content/channels/{channelID}/topics/{topicID}",
path: map[string]string{ "channelId": channel.Id, "topicId": ids[13] }, path: map[string]string{ "channelID": channel.ID, "topicID": ids[13] },
tokenType: APP_TOKENAGENT, tokenType: APP_TOKENAGENT,
token: set.A.Token, token: set.A.Token,
} }
response = &TestApiResponse{ } response = &TestAPIResponse{ }
assert.NoError(t, TestApiRequest(RemoveChannelTopic, params, response)); assert.NoError(t, TestAPIRequest(RemoveChannelTopic, params, response));
params = &TestApiParams { params = &TestAPIParams {
restType: "GET", restType: "GET",
query: "/content/channels/{channelId}/topics?begin=" + marker + "&revision=" + revision, query: "/content/channels/{channelID}/topics?begin=" + marker + "&revision=" + revision,
path: map[string]string{ "channelId": channel.Id, "topicId": topic.Id }, path: map[string]string{ "channelID": channel.ID, "topicID": topic.ID },
tokenType: APP_TOKENAGENT, tokenType: APP_TOKENAGENT,
token: set.A.Token, token: set.A.Token,
} }
topics = &[]Topic{} topics = &[]Topic{}
response = &TestApiResponse{ data: topics } response = &TestAPIResponse{ data: topics }
assert.NoError(t, TestApiRequest(GetChannelTopics, params, response)); assert.NoError(t, TestAPIRequest(GetChannelTopics, params, response));
assert.Equal(t, 0, len(*topics)); assert.Equal(t, 0, len(*topics));
params = &TestApiParams { params = &TestAPIParams {
restType: "DELETE", restType: "DELETE",
query: "/content/channels/{channelId}/topics/{topicId}", query: "/content/channels/{channelID}/topics/{topicID}",
path: map[string]string{ "channelId": channel.Id, "topicId": ids[108] }, path: map[string]string{ "channelID": channel.ID, "topicID": ids[108] },
tokenType: APP_TOKENAGENT, tokenType: APP_TOKENAGENT,
token: set.A.Token, token: set.A.Token,
} }
response = &TestApiResponse{ } response = &TestAPIResponse{ }
assert.NoError(t, TestApiRequest(RemoveChannelTopic, params, response)); assert.NoError(t, TestAPIRequest(RemoveChannelTopic, params, response));
params = &TestApiParams { params = &TestAPIParams {
restType: "GET", restType: "GET",
query: "/content/channels/{channelId}/topics?begin=" + marker + "&revision=" + revision, query: "/content/channels/{channelID}/topics?begin=" + marker + "&revision=" + revision,
path: map[string]string{ "channelId": channel.Id, "topicId": topic.Id }, path: map[string]string{ "channelID": channel.ID, "topicID": topic.ID },
tokenType: APP_TOKENAGENT, tokenType: APP_TOKENAGENT,
token: set.A.Token, token: set.A.Token,
} }
topics = &[]Topic{} topics = &[]Topic{}
response = &TestApiResponse{ data: topics } response = &TestAPIResponse{ data: topics }
assert.NoError(t, TestApiRequest(GetChannelTopics, params, response)); assert.NoError(t, TestAPIRequest(GetChannelTopics, params, response));
assert.Equal(t, 1, len(*topics)); assert.Equal(t, 1, len(*topics));
} }

View File

@ -28,46 +28,46 @@ func TestTopicShare(t *testing.T) {
// add new channel // add new channel
channel = &Channel{} channel = &Channel{}
subject = &Subject{ Data: "channeldata", DataType: "channeldatatype" } subject = &Subject{ Data: "channeldata", DataType: "channeldatatype" }
assert.NoError(t, ApiTestMsg(AddChannel, "POST", "/content/channels", assert.NoError(t, APITestMsg(AddChannel, "POST", "/content/channels",
nil, subject, APP_TOKENAGENT, set.A.Token, channel, nil)) nil, subject, APP_TOKENAGENT, set.A.Token, channel, nil))
image := "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" image := "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"
img, _ := base64.StdEncoding.DecodeString(image) img, _ := base64.StdEncoding.DecodeString(image)
subject = &Subject{ Data: "{ \"nested\" : { \"image\" : \"" + image + "\" } }", DataType: "nestedimage" } subject = &Subject{ Data: "{ \"nested\" : { \"image\" : \"" + image + "\" } }", DataType: "nestedimage" }
params["channelId"] = channel.Id params["channelID"] = channel.ID
assert.NoError(t, ApiTestMsg(SetChannelSubject, "PUT", "/content/channels/{channelId}/subject", assert.NoError(t, APITestMsg(SetChannelSubject, "PUT", "/content/channels/{channelID}/subject",
&params, subject, APP_TOKENAGENT, set.A.Token, channel, nil)) &params, subject, APP_TOKENAGENT, set.A.Token, channel, nil))
params["cardId"] = set.A.B.CardId params["cardID"] = set.A.B.CardID
assert.NoError(t, ApiTestMsg(SetChannelCard, "PUT", "/content/channels/{channelId}/cards/{cardId}", assert.NoError(t, APITestMsg(SetChannelCard, "PUT", "/content/channels/{channelID}/cards/{cardID}",
&params, nil, APP_TOKENAGENT, set.A.Token, nil, nil)) &params, nil, APP_TOKENAGENT, set.A.Token, nil, nil))
params["cardId"] = set.A.C.CardId params["cardID"] = set.A.C.CardID
assert.NoError(t, ApiTestMsg(SetChannelCard, "PUT", "/content/channels/{channelId}/cards/{cardId}", assert.NoError(t, APITestMsg(SetChannelCard, "PUT", "/content/channels/{channelID}/cards/{cardID}",
&params, nil, APP_TOKENAGENT, set.A.Token, nil, nil)) &params, nil, APP_TOKENAGENT, set.A.Token, nil, nil))
// view channel // view channel
detail = &ChannelDetail{} detail = &ChannelDetail{}
assert.NoError(t, ApiTestMsg(GetChannelDetail, "GET", "/content/channels/{channelId}/detail", assert.NoError(t, APITestMsg(GetChannelDetail, "GET", "/content/channels/{channelID}/detail",
&params, nil, APP_TOKENAGENT, set.A.Token, detail, nil)) &params, nil, APP_TOKENAGENT, set.A.Token, detail, nil))
assert.NotNil(t, detail); assert.NotNil(t, detail);
detail = &ChannelDetail{} detail = &ChannelDetail{}
assert.NoError(t, ApiTestMsg(GetChannelDetail, "GET", "/content/channels/{channelId}/detail", assert.NoError(t, APITestMsg(GetChannelDetail, "GET", "/content/channels/{channelID}/detail",
&params, nil, APP_TOKENCONTACT, set.B.A.Token, detail, nil)) &params, nil, APP_TOKENCONTACT, set.B.A.Token, detail, nil))
assert.NotNil(t, channel.Data.ChannelDetail); assert.NotNil(t, channel.Data.ChannelDetail);
detail = &ChannelDetail{} detail = &ChannelDetail{}
assert.NoError(t, ApiTestMsg(GetChannelDetail, "GET", "/content/channels/{channelId}/detail", assert.NoError(t, APITestMsg(GetChannelDetail, "GET", "/content/channels/{channelID}/detail",
&params, nil, APP_TOKENCONTACT, set.B.A.Token, detail, nil)) &params, nil, APP_TOKENCONTACT, set.B.A.Token, detail, nil))
assert.NotNil(t, channel.Data.ChannelDetail); assert.NotNil(t, channel.Data.ChannelDetail);
params["field"] = "nested.image" params["field"] = "nested.image"
data, header, err = ApiTestData(GetChannelSubjectField, "GET", "/content/channels/{channelId}/subject/{field}", data, header, err = APITestData(GetChannelSubjectField, "GET", "/content/channels/{channelID}/subject/{field}",
&params, nil, APP_TOKENAGENT, set.A.Token, 0, 0) &params, nil, APP_TOKENAGENT, set.A.Token, 0, 0)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, "image/png", header["Content-Type"][0]) assert.Equal(t, "image/png", header["Content-Type"][0])
assert.Zero(t, bytes.Compare(img, data)) assert.Zero(t, bytes.Compare(img, data))
data, header, err = ApiTestData(GetChannelSubjectField, "GET", "/content/channels/{channelId}/subject/{field}", data, header, err = APITestData(GetChannelSubjectField, "GET", "/content/channels/{channelID}/subject/{field}",
&params, nil, APP_TOKENCONTACT, set.B.A.Token, 0, 0) &params, nil, APP_TOKENCONTACT, set.B.A.Token, 0, 0)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, "image/png", header["Content-Type"][0]) assert.Equal(t, "image/png", header["Content-Type"][0])
assert.Zero(t, bytes.Compare(img, data)) assert.Zero(t, bytes.Compare(img, data))
data, header, err = ApiTestData(GetChannelSubjectField, "GET", "/content/channels/{channelId}/subject/{field}", data, header, err = APITestData(GetChannelSubjectField, "GET", "/content/channels/{channelID}/subject/{field}",
&params, nil, APP_TOKENCONTACT, set.C.A.Token, 0, 0) &params, nil, APP_TOKENCONTACT, set.C.A.Token, 0, 0)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, "image/png", header["Content-Type"][0]) assert.Equal(t, "image/png", header["Content-Type"][0])
@ -77,31 +77,31 @@ func TestTopicShare(t *testing.T) {
// add a topc // add a topc
topic = &Topic{} topic = &Topic{}
subject = &Subject{ DataType: "topicdatatype", Data: "subjectfromA" } subject = &Subject{ DataType: "topicdatatype", Data: "subjectfromA" }
assert.NoError(t, ApiTestMsg(AddChannelTopic, "POST", "/content/channels/{channelId}/topics", assert.NoError(t, APITestMsg(AddChannelTopic, "POST", "/content/channels/{channelID}/topics",
&params, subject, APP_TOKENAGENT, set.A.Token, topic, nil)) &params, subject, APP_TOKENAGENT, set.A.Token, topic, nil))
topic = &Topic{} topic = &Topic{}
subject = &Subject{ DataType: "topicdatatype", Data: "subjectfromB" } subject = &Subject{ DataType: "topicdatatype", Data: "subjectfromB" }
assert.NoError(t, ApiTestMsg(AddChannelTopic, "POST", "/content/channels/{channelId}/topics", assert.NoError(t, APITestMsg(AddChannelTopic, "POST", "/content/channels/{channelID}/topics",
&params, subject, APP_TOKENCONTACT, set.B.A.Token, topic, nil)) &params, subject, APP_TOKENCONTACT, set.B.A.Token, topic, nil))
params["topicId"] = topic.Id params["topicID"] = topic.ID
assert.NoError(t, ApiTestMsg(SetChannelTopicConfirmed, "PUT", "/content/channels/{channelId}/topics/{topicId}/confirmed", assert.NoError(t, APITestMsg(SetChannelTopicConfirmed, "PUT", "/content/channels/{channelID}/topics/{topicID}/confirmed",
&params, APP_TOPICCONFIRMED, APP_TOKENCONTACT, set.B.A.Token, nil, nil)) &params, APP_TOPICCONFIRMED, APP_TOKENCONTACT, set.B.A.Token, nil, nil))
topic = &Topic{} topic = &Topic{}
subject = &Subject{ DataType: "topicdatatype", Data: "subjectfromC" } subject = &Subject{ DataType: "topicdatatype", Data: "subjectfromC" }
assert.NoError(t, ApiTestMsg(AddChannelTopic, "POST", "/content/channels/{channelId}/topics", assert.NoError(t, APITestMsg(AddChannelTopic, "POST", "/content/channels/{channelID}/topics",
&params, subject, APP_TOKENCONTACT, set.C.A.Token, topic, nil)) &params, subject, APP_TOKENCONTACT, set.C.A.Token, topic, nil))
// add asset to topic // add asset to topic
assets := []Asset{} assets := []Asset{}
params["topicId"] = topic.Id params["topicID"] = topic.ID
transforms, err := json.Marshal([]string{ "copy;photo" }) transforms, err := json.Marshal([]string{ "copy;photo" })
assert.NoError(t, err) assert.NoError(t, err)
assert.NoError(t, ApiTestUpload(AddChannelTopicAsset, "POST", "/content/channels/{channelId}/topics/{topicId}/assets?transforms=" + url.QueryEscape(string(transforms)), assert.NoError(t, APITestUpload(AddChannelTopicAsset, "POST", "/content/channels/{channelID}/topics/{topicID}/assets?transforms=" + url.QueryEscape(string(transforms)),
&params, img, APP_TOKENCONTACT, set.C.A.Token, &assets, nil)) &params, img, APP_TOKENCONTACT, set.C.A.Token, &assets, nil))
// view topics // view topics
topics := &[]Topic{} topics := &[]Topic{}
assert.NoError(t, ApiTestMsg(GetChannelTopics, "GET", "/content/channels/{channelId}/topics", assert.NoError(t, APITestMsg(GetChannelTopics, "GET", "/content/channels/{channelID}/topics",
&params, nil, APP_TOKENAGENT, set.A.Token, topics, nil)) &params, nil, APP_TOKENAGENT, set.A.Token, topics, nil))
aRev = GetTestRevision(set.A.Revisions) aRev = GetTestRevision(set.A.Revisions)
@ -110,7 +110,7 @@ func TestTopicShare(t *testing.T) {
// add a tag to topic // add a tag to topic
tag := Tag{} tag := Tag{}
subject = &Subject{ DataType: "tagdatatype", Data: "subjectfromA" } subject = &Subject{ DataType: "tagdatatype", Data: "subjectfromA" }
assert.NoError(t, ApiTestMsg(AddChannelTopicTag, "POST", "/content/channels/{channelId}/topics/{topicId}", assert.NoError(t, APITestMsg(AddChannelTopicTag, "POST", "/content/channels/{channelID}/topics/{topicID}",
&params, subject, APP_TOKENAGENT, set.A.Token, &tag, nil)) &params, subject, APP_TOKENAGENT, set.A.Token, &tag, nil))
assert.NotEqual(t, aRev.Channel, GetTestRevision(set.A.Revisions).Channel) assert.NotEqual(t, aRev.Channel, GetTestRevision(set.A.Revisions).Channel)
@ -118,56 +118,56 @@ func TestTopicShare(t *testing.T) {
// get tags for topic // get tags for topic
tags := &[]Tag{} tags := &[]Tag{}
assert.NoError(t, ApiTestMsg(GetChannelTopicTags, "GET", "/content/channels/{channelId}/topics/{topicId}", assert.NoError(t, APITestMsg(GetChannelTopicTags, "GET", "/content/channels/{channelID}/topics/{topicID}",
&params, nil, APP_TOKENCONTACT, set.C.A.Token, tags, nil)) &params, nil, APP_TOKENCONTACT, set.C.A.Token, tags, nil))
assert.Equal(t, 1, len(*tags)) assert.Equal(t, 1, len(*tags))
// delete topic tag // delete topic tag
params["tagId"] = tag.Id params["tagID"] = tag.ID
assert.NoError(t, ApiTestMsg(RemoveChannelTopicTag, "DELETE", "/content/channels/{channelId}/topics/{topicId}/tags/{tagId}", assert.NoError(t, APITestMsg(RemoveChannelTopicTag, "DELETE", "/content/channels/{channelID}/topics/{topicID}/tags/{tagID}",
&params, nil, APP_TOKENAGENT, set.A.Token, nil, nil)) &params, nil, APP_TOKENAGENT, set.A.Token, nil, nil))
// get tags for topic // get tags for topic
tags = &[]Tag{} tags = &[]Tag{}
assert.NoError(t, ApiTestMsg(GetChannelTopicTags, "GET", "/content/channels/{channelId}/topics/{topicId}", assert.NoError(t, APITestMsg(GetChannelTopicTags, "GET", "/content/channels/{channelID}/topics/{topicID}",
&params, nil, APP_TOKENCONTACT, set.C.A.Token, tags, nil)) &params, nil, APP_TOKENCONTACT, set.C.A.Token, tags, nil))
assert.Equal(t, 0, len(*tags)) assert.Equal(t, 0, len(*tags))
// get list of assets // get list of assets
assets = []Asset{} assets = []Asset{}
assert.NoError(t, ApiTestMsg(GetChannelTopicAssets, "GET", "/content/channels/{channelId}/topics/{topicId}", assert.NoError(t, APITestMsg(GetChannelTopicAssets, "GET", "/content/channels/{channelID}/topics/{topicID}",
&params, nil, APP_TOKENCONTACT, set.C.A.Token, &assets, nil)) &params, nil, APP_TOKENCONTACT, set.C.A.Token, &assets, nil))
assert.Equal(t, 2, len(assets)) assert.Equal(t, 2, len(assets))
// delete each asset // delete each asset
for _, asset := range assets { for _, asset := range assets {
params["assetId"] = asset.AssetId params["assetID"] = asset.AssetID
assert.NoError(t, ApiTestMsg(RemoveChannelTopicAsset, "DELETE", "/content/channels/{channelId}/topics/{topicId}/assets/{assetId}", assert.NoError(t, APITestMsg(RemoveChannelTopicAsset, "DELETE", "/content/channels/{channelID}/topics/{topicID}/assets/{assetID}",
&params, nil, APP_TOKENCONTACT, set.C.A.Token, nil, nil)) &params, nil, APP_TOKENCONTACT, set.C.A.Token, nil, nil))
} }
// get list of assets // get list of assets
assets = []Asset{} assets = []Asset{}
assert.NoError(t, ApiTestMsg(GetChannelTopicAssets, "GET", "/content/channels/{channelId}/topics/{topicId}", assert.NoError(t, APITestMsg(GetChannelTopicAssets, "GET", "/content/channels/{channelID}/topics/{topicID}",
&params, nil, APP_TOKENCONTACT, set.C.A.Token, &assets, nil)) &params, nil, APP_TOKENCONTACT, set.C.A.Token, &assets, nil))
assert.Equal(t, 0, len(assets)) assert.Equal(t, 0, len(assets))
// add asset to topic // add asset to topic
assets = []Asset{} assets = []Asset{}
params["topicId"] = topic.Id params["topicID"] = topic.ID
transforms, err = json.Marshal([]string{ "copy;photo" }) transforms, err = json.Marshal([]string{ "copy;photo" })
assert.NoError(t, err) assert.NoError(t, err)
assert.NoError(t, ApiTestUpload(AddChannelTopicAsset, "POST", "/content/channels/{channelId}/topics/{topicId}/assets?transforms=" + url.QueryEscape(string(transforms)), assert.NoError(t, APITestUpload(AddChannelTopicAsset, "POST", "/content/channels/{channelID}/topics/{topicID}/assets?transforms=" + url.QueryEscape(string(transforms)),
&params, img, APP_TOKENCONTACT, set.C.A.Token, &assets, nil)) &params, img, APP_TOKENCONTACT, set.C.A.Token, &assets, nil))
// add a tag to topic // add a tag to topic
tag = Tag{} tag = Tag{}
subject = &Subject{ DataType: "tagdatatype", Data: "subjectfromA" } subject = &Subject{ DataType: "tagdatatype", Data: "subjectfromA" }
assert.NoError(t, ApiTestMsg(AddChannelTopicTag, "POST", "/content/channels/{channelId}/topics/{topicId}", assert.NoError(t, APITestMsg(AddChannelTopicTag, "POST", "/content/channels/{channelID}/topics/{topicID}",
&params, subject, APP_TOKENAGENT, set.A.Token, &tag, nil)) &params, subject, APP_TOKENAGENT, set.A.Token, &tag, nil))
// remove channel // remove channel
assert.NoError(t, ApiTestMsg(RemoveChannel, "DELETE", "/content/channels/{channelId}", assert.NoError(t, APITestMsg(RemoveChannel, "DELETE", "/content/channels/{channelID}",
&params, nil, APP_TOKENAGENT, set.A.Token, nil, nil)) &params, nil, APP_TOKENAGENT, set.A.Token, nil, nil))
} }