From 471646236845bce7027d48a2f053e3cc624c673c Mon Sep 17 00:00:00 2001 From: Roland Osborne Date: Fri, 22 Jul 2022 10:15:44 -0700 Subject: [PATCH] golint doesnt like my naming, fine whatever --- net/server/internal/api_addAccount.go | 4 +- net/server/internal/api_addAccountApp.go | 4 +- net/server/internal/api_addArticle.go | 2 +- net/server/internal/api_addCard.go | 10 +- net/server/internal/api_addChannel.go | 10 +- net/server/internal/api_addChannelTopic.go | 8 +- .../internal/api_addChannelTopicAsset.go | 22 +- net/server/internal/api_addChannelTopicTag.go | 12 +- net/server/internal/api_addGroup.go | 2 +- .../internal/api_addNodeAccountAccess.go | 4 +- net/server/internal/api_authorize.go | 2 +- net/server/internal/api_clearArticleGroup.go | 8 +- net/server/internal/api_clearCardGroup.go | 8 +- net/server/internal/api_clearCardNotes.go | 4 +- net/server/internal/api_clearChannelCard.go | 12 +- net/server/internal/api_clearChannelGroup.go | 10 +- net/server/internal/api_getAccountListing.go | 2 +- .../internal/api_getAccountListingMessage.go | 2 +- .../internal/api_getArticleSubjectField.go | 6 +- net/server/internal/api_getArticles.go | 4 +- net/server/internal/api_getCard.go | 4 +- net/server/internal/api_getCardDetail.go | 4 +- net/server/internal/api_getCardImage.go | 4 +- net/server/internal/api_getCardProfile.go | 4 +- net/server/internal/api_getChannelDetail.go | 6 +- net/server/internal/api_getChannelSummary.go | 6 +- net/server/internal/api_getChannelTopic.go | 16 +- .../internal/api_getChannelTopicAsset.go | 10 +- .../internal/api_getChannelTopicAssets.go | 8 +- .../internal/api_getChannelTopicDetail.go | 4 +- .../api_getChannelTopicSubjectField.go | 4 +- .../api_getChannelTopicTagSubjectField.go | 8 +- .../internal/api_getChannelTopicTags.go | 4 +- net/server/internal/api_getChannels.go | 6 +- net/server/internal/api_getCloseMessage.go | 8 +- .../internal/api_getGroupSubjectField.go | 4 +- .../internal/api_getNodeAccountImage.go | 4 +- net/server/internal/api_getNodeAccounts.go | 4 +- net/server/internal/api_getOpenMessage.go | 8 +- net/server/internal/api_getProfileMessage.go | 2 +- net/server/internal/api_removeAccount.go | 2 +- net/server/internal/api_removeArticle.go | 6 +- net/server/internal/api_removeCard.go | 6 +- net/server/internal/api_removeChannel.go | 10 +- net/server/internal/api_removeChannelTopic.go | 14 +- .../internal/api_removeChannelTopicAsset.go | 14 +- .../internal/api_removeChannelTopicTag.go | 18 +- net/server/internal/api_removeGroup.go | 4 +- net/server/internal/api_removeNodeAccount.go | 6 +- net/server/internal/api_setAccountAccess.go | 4 +- net/server/internal/api_setArticleGroup.go | 8 +- net/server/internal/api_setArticleSubject.go | 6 +- net/server/internal/api_setCardGroup.go | 8 +- net/server/internal/api_setCardNotes.go | 4 +- net/server/internal/api_setCardProfile.go | 6 +- net/server/internal/api_setCardStatus.go | 4 +- net/server/internal/api_setChannelCard.go | 14 +- net/server/internal/api_setChannelGroup.go | 10 +- net/server/internal/api_setChannelSubject.go | 8 +- .../internal/api_setChannelTopicConfirmed.go | 8 +- .../internal/api_setChannelTopicSubject.go | 10 +- .../internal/api_setChannelTopicTagSubject.go | 18 +- net/server/internal/api_setCloseMessage.go | 2 +- net/server/internal/api_setGroupSubject.go | 4 +- net/server/internal/api_setNodeAccount.go | 4 +- .../internal/api_setNodeAccountStatus.go | 4 +- net/server/internal/api_setNodeConfig.go | 8 +- net/server/internal/api_setNodeStatus.go | 4 +- net/server/internal/api_setOpenMessage.go | 8 +- net/server/internal/configUtil.go | 16 +- net/server/internal/garbageUtil.go | 6 +- net/server/internal/main_test.go | 4 +- net/server/internal/messageUtil.go | 4 +- net/server/internal/modelUtil.go | 60 ++-- net/server/internal/models.go | 36 +-- net/server/internal/notify.go | 12 +- net/server/internal/routers.go | 106 +++---- net/server/internal/store/schema.go | 32 +- net/server/internal/testApp.go | 296 +++++++++--------- net/server/internal/testUtil.go | 120 +++---- net/server/internal/transcodeUtil.go | 8 +- net/server/internal/ucAccountConfig_test.go | 80 ++--- net/server/internal/ucAttributeShare_test.go | 96 +++--- net/server/internal/ucChannelShare_test.go | 72 ++--- net/server/internal/ucContactApp_test.go | 116 +++---- net/server/internal/ucContactSync_test.go | 84 ++--- net/server/internal/ucMessangerApp_test.go | 116 +++---- net/server/internal/ucProfileUpdate_test.go | 34 +- net/server/internal/ucStaggardLoad_test.go | 96 +++--- net/server/internal/ucTopicShare_test.go | 68 ++-- 90 files changed, 969 insertions(+), 969 deletions(-) diff --git a/net/server/internal/api_addAccount.go b/net/server/internal/api_addAccount.go index e71238af..c708bec4 100644 --- a/net/server/internal/api_addAccount.go +++ b/net/server/internal/api_addAccount.go @@ -82,7 +82,7 @@ func AddAccount(w http.ResponseWriter, r *http.Request) { Username: username, Handle: strings.ToLower(username), Password: password, - Guid: fingerprint, + GUID: fingerprint, } detail := store.AccountDetail{ PublicKey: publicPem, @@ -113,7 +113,7 @@ func AddAccount(w http.ResponseWriter, r *http.Request) { // create response profile := Profile{ - Guid: account.Guid, + GUID: account.GUID, Handle: account.Username, Name: detail.Name, Description: detail.Description, diff --git a/net/server/internal/api_addAccountApp.go b/net/server/internal/api_addAccountApp.go index 938dc3cd..1589a5b1 100644 --- a/net/server/internal/api_addAccountApp.go +++ b/net/server/internal/api_addAccountApp.go @@ -33,7 +33,7 @@ func AddAccountApp(w http.ResponseWriter, r *http.Request) { // create app entry app := store.App { - AccountID: account.Guid, + AccountID: account.GUID, Name: appData.Name, Description: appData.Description, Image: appData.Image, @@ -54,7 +54,7 @@ func AddAccountApp(w http.ResponseWriter, r *http.Request) { } login := LoginAccess { - AppToken: account.Guid + "." + access, + AppToken: account.GUID + "." + access, Created: app.Created, } diff --git a/net/server/internal/api_addArticle.go b/net/server/internal/api_addArticle.go index b76d8421..609845d0 100644 --- a/net/server/internal/api_addArticle.go +++ b/net/server/internal/api_addArticle.go @@ -32,7 +32,7 @@ func AddArticle(w http.ResponseWriter, r *http.Request) { return res } - slot.ArticleSlotId = uuid.New().String() + slot.ArticleSlotID = uuid.New().String() slot.AccountID = account.ID slot.ArticleID = article.ID slot.Revision = account.ArticleRevision + 1 diff --git a/net/server/internal/api_addCard.go b/net/server/internal/api_addCard.go index 36b14ee0..da3405a2 100644 --- a/net/server/internal/api_addCard.go +++ b/net/server/internal/api_addCard.go @@ -33,7 +33,7 @@ func AddCard(w http.ResponseWriter, r *http.Request) { slot := &store.CardSlot{} 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) { ErrResponse(w, http.StatusInternalServerError, err) return @@ -46,7 +46,7 @@ func AddCard(w http.ResponseWriter, r *http.Request) { return } card := &store.Card{ - Guid: guid, + GUID: guid, Username: identity.Handle, Name: identity.Name, Description: identity.Description, @@ -58,7 +58,7 @@ func AddCard(w http.ResponseWriter, r *http.Request) { Status: APP_CARDCONFIRMED, ViewRevision: 0, InToken: hex.EncodeToString(data), - AccountID: account.Guid, + AccountID: account.GUID, } // save new card @@ -66,7 +66,7 @@ func AddCard(w http.ResponseWriter, r *http.Request) { if res := tx.Save(card).Error; res != nil { return res } - slot.CardSlotId = uuid.New().String() + slot.CardSlotID = uuid.New().String() slot.AccountID = account.ID slot.Revision = account.CardRevision + 1 slot.CardID = card.ID @@ -110,7 +110,7 @@ func AddCard(w http.ResponseWriter, r *http.Request) { slot = &card.CardSlot if slot == nil { slot = &store.CardSlot{ - CardSlotId: uuid.New().String(), + CardSlotID: uuid.New().String(), AccountID: account.ID, Revision: account.CardRevision + 1, CardID: card.ID, diff --git a/net/server/internal/api_addChannel.go b/net/server/internal/api_addChannel.go index f3c625f0..d8b1ae4c 100644 --- a/net/server/internal/api_addChannel.go +++ b/net/server/internal/api_addChannel.go @@ -35,7 +35,7 @@ func AddChannel(w http.ResponseWriter, r *http.Request) { return res } - slot.ChannelSlotId = uuid.New().String() + slot.ChannelSlotID = uuid.New().String() slot.AccountID = account.ID slot.ChannelID = channel.ID 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 { return res } - for _, cardId := range params.Cards { + for _, cardID := range params.Cards { 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 } 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); } - for _, groupId := range params.Groups { + for _, groupID := range params.Groups { 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 } if res := tx.Model(&slot.Channel).Association("Groups").Append(groupSlot.Group); res != nil { diff --git a/net/server/internal/api_addChannelTopic.go b/net/server/internal/api_addChannelTopic.go index 7771283b..b3c43c37 100644 --- a/net/server/internal/api_addChannelTopic.go +++ b/net/server/internal/api_addChannelTopic.go @@ -27,7 +27,7 @@ func AddChannelTopic(w http.ResponseWriter, r *http.Request) { topicSlot := &store.TopicSlot{} err = store.DB.Transaction(func(tx *gorm.DB) error { - topicSlot.TopicSlotId = uuid.New().String() + topicSlot.TopicSlotID = uuid.New().String() topicSlot.AccountID = act.ID topicSlot.ChannelID = channelSlot.Channel.ID topicSlot.Revision = act.ChannelRevision + 1 @@ -41,7 +41,7 @@ func AddChannelTopic(w http.ResponseWriter, r *http.Request) { topic.TopicSlotID = topicSlot.ID topic.Data = subject.Data topic.DataType = subject.DataType - topic.Guid = guid + topic.GUID = guid topic.DetailRevision = act.ChannelRevision + 1 topic.TagRevision = act.ChannelRevision + 1 if confirm == "true" { @@ -75,11 +75,11 @@ func AddChannelTopic(w http.ResponseWriter, r *http.Request) { // determine affected contact list cards := make(map[string]store.Card) for _, card := range channelSlot.Channel.Cards { - cards[card.Guid] = card + cards[card.GUID] = card } for _, group := range channelSlot.Channel.Groups { for _, card := range group.Cards { - cards[card.Guid] = card + cards[card.GUID] = card } } diff --git a/net/server/internal/api_addChannelTopicAsset.go b/net/server/internal/api_addChannelTopicAsset.go index 42220a33..14376d8d 100644 --- a/net/server/internal/api_addChannelTopicAsset.go +++ b/net/server/internal/api_addChannelTopicAsset.go @@ -18,7 +18,7 @@ func AddChannelTopicAsset(w http.ResponseWriter, r *http.Request) { // scan parameters params := mux.Vars(r) - topicId := params["topicId"] + topicID := params["topicID"] var transforms []string if r.FormValue("transforms") != "" { 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 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) { ErrResponse(w, http.StatusNotFound, err) } else { @@ -59,7 +59,7 @@ func AddChannelTopicAsset(w http.ResponseWriter, r *http.Request) { } // 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")) return } @@ -70,7 +70,7 @@ func AddChannelTopicAsset(w http.ResponseWriter, r *http.Request) { // save new file 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 { ErrResponse(w, http.StatusBadRequest, err) return @@ -90,7 +90,7 @@ func AddChannelTopicAsset(w http.ResponseWriter, r *http.Request) { assets := []Asset{} asset := &store.Asset{} - asset.AssetId = id + asset.AssetID = id asset.AccountID = channelSlot.Account.ID asset.ChannelID = channelSlot.Channel.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 { return res } - assets = append(assets, Asset{ AssetId: id, Status: APP_ASSETREADY}) + assets = append(assets, Asset{ AssetID: id, Status: APP_ASSETREADY}) for _, transform := range transforms { asset := &store.Asset{} - asset.AssetId = uuid.New().String() + asset.AssetID = uuid.New().String() asset.AccountID = channelSlot.Account.ID asset.ChannelID = channelSlot.Channel.ID asset.TopicID = topicSlot.Topic.ID asset.Status = APP_ASSETWAITING - asset.TransformId = id + asset.TransformID = id t := strings.Split(transform, ";") if len(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 { 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 { return res @@ -153,11 +153,11 @@ func AddChannelTopicAsset(w http.ResponseWriter, r *http.Request) { // determine affected contact list cards := make(map[string]store.Card) for _, card := range channelSlot.Channel.Cards { - cards[card.Guid] = card + cards[card.GUID] = card } for _, group := range channelSlot.Channel.Groups { for _, card := range group.Cards { - cards[card.Guid] = card + cards[card.GUID] = card } } diff --git a/net/server/internal/api_addChannelTopicTag.go b/net/server/internal/api_addChannelTopicTag.go index e6b1cc82..dceb84d4 100644 --- a/net/server/internal/api_addChannelTopicTag.go +++ b/net/server/internal/api_addChannelTopicTag.go @@ -13,7 +13,7 @@ func AddChannelTopicTag(w http.ResponseWriter, r *http.Request) { // scan parameters params := mux.Vars(r) - topicId := params["topicId"] + topicID := params["topicID"] var subject Subject if err := ParseRequest(r, w, &subject); err != nil { @@ -30,7 +30,7 @@ func AddChannelTopicTag(w http.ResponseWriter, r *http.Request) { // load topic 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) { ErrResponse(w, http.StatusNotFound, err) } else { @@ -47,7 +47,7 @@ func AddChannelTopicTag(w http.ResponseWriter, r *http.Request) { tagSlot := &store.TagSlot{} err = store.DB.Transaction(func(tx *gorm.DB) error { - tagSlot.TagSlotId = uuid.New().String() + tagSlot.TagSlotID = uuid.New().String() tagSlot.AccountID = act.ID tagSlot.Revision = act.ChannelRevision + 1 tagSlot.ChannelID = channelSlot.Channel.ID @@ -61,7 +61,7 @@ func AddChannelTopicTag(w http.ResponseWriter, r *http.Request) { tag.ChannelID = channelSlot.Channel.ID tag.TopicID = topicSlot.Topic.ID tag.TagSlotID = tagSlot.ID - tag.Guid = guid + tag.GUID = guid tag.DataType = subject.DataType tag.Data = subject.Data if res := tx.Save(tag).Error; res != nil { @@ -94,11 +94,11 @@ func AddChannelTopicTag(w http.ResponseWriter, r *http.Request) { // determine affected contact list cards := make(map[string]store.Card) for _, card := range channelSlot.Channel.Cards { - cards[card.Guid] = card + cards[card.GUID] = card } for _, group := range channelSlot.Channel.Groups { for _, card := range group.Cards { - cards[card.Guid] = card + cards[card.GUID] = card } } diff --git a/net/server/internal/api_addGroup.go b/net/server/internal/api_addGroup.go index 2e926fc1..0130ce96 100644 --- a/net/server/internal/api_addGroup.go +++ b/net/server/internal/api_addGroup.go @@ -40,7 +40,7 @@ func AddGroup(w http.ResponseWriter, r *http.Request) { return res } - slot.GroupSlotId = uuid.New().String() + slot.GroupSlotID = uuid.New().String() slot.AccountID = account.ID slot.GroupID = group.ID slot.Revision = account.GroupRevision + 1 diff --git a/net/server/internal/api_addNodeAccountAccess.go b/net/server/internal/api_addNodeAccountAccess.go index 3730c0cd..5ac21edb 100644 --- a/net/server/internal/api_addNodeAccountAccess.go +++ b/net/server/internal/api_addNodeAccountAccess.go @@ -13,7 +13,7 @@ import ( func AddNodeAccountAccess(w http.ResponseWriter, r *http.Request) { params := mux.Vars(r) - accountId, res := strconv.ParseUint(params["accountId"], 10, 32) + accountID, res := strconv.ParseUint(params["accountID"], 10, 32) if res != nil { ErrResponse(w, http.StatusBadRequest, res) return @@ -32,7 +32,7 @@ func AddNodeAccountAccess(w http.ResponseWriter, r *http.Request) { token := hex.EncodeToString(data) accountToken := store.AccountToken{ - AccountID: uint(accountId), + AccountID: uint(accountID), TokenType: APP_TOKENRESET, Token: token, Expires: time.Now().Unix() + APP_RESETEXPIRE, diff --git a/net/server/internal/api_authorize.go b/net/server/internal/api_authorize.go index 6639785e..1ebad71a 100644 --- a/net/server/internal/api_authorize.go +++ b/net/server/internal/api_authorize.go @@ -22,7 +22,7 @@ func Authorize(w http.ResponseWriter, r *http.Request) { claim := &Claim{ Token: token } 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 { ErrResponse(w, http.StatusInternalServerError, err) return diff --git a/net/server/internal/api_clearArticleGroup.go b/net/server/internal/api_clearArticleGroup.go index 1d95f2eb..5eb606d2 100644 --- a/net/server/internal/api_clearArticleGroup.go +++ b/net/server/internal/api_clearArticleGroup.go @@ -18,12 +18,12 @@ func ClearArticleGroup(w http.ResponseWriter, r *http.Request) { // scan parameters params := mux.Vars(r) - articleId := params["articleId"] - groupId := params["groupId"] + articleID := params["articleID"] + groupID := params["groupID"] // load referenced article 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) { ErrResponse(w, http.StatusInternalServerError, err) } else { @@ -38,7 +38,7 @@ func ClearArticleGroup(w http.ResponseWriter, r *http.Request) { // load referenced group 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) { ErrResponse(w, http.StatusInternalServerError, err) } else { diff --git a/net/server/internal/api_clearCardGroup.go b/net/server/internal/api_clearCardGroup.go index e83fd870..13227497 100644 --- a/net/server/internal/api_clearCardGroup.go +++ b/net/server/internal/api_clearCardGroup.go @@ -18,12 +18,12 @@ func ClearCardGroup(w http.ResponseWriter, r *http.Request) { // scan parameters params := mux.Vars(r) - cardId := params["cardId"] - groupId := params["groupId"] + cardID := params["cardID"] + groupID := params["groupID"] // load referenced card 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) { ErrResponse(w, http.StatusNotFound, err) } else { @@ -38,7 +38,7 @@ func ClearCardGroup(w http.ResponseWriter, r *http.Request) { // load referenced group 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) { ErrResponse(w, http.StatusInternalServerError, err) } else { diff --git a/net/server/internal/api_clearCardNotes.go b/net/server/internal/api_clearCardNotes.go index be80e8f8..1b7f3296 100644 --- a/net/server/internal/api_clearCardNotes.go +++ b/net/server/internal/api_clearCardNotes.go @@ -18,11 +18,11 @@ func ClearCardNotes(w http.ResponseWriter, r *http.Request) { // scan parameters params := mux.Vars(r) - cardId := params["cardId"] + cardID := params["cardID"] // load referenced card 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) { ErrResponse(w, http.StatusInternalServerError, err) } else { diff --git a/net/server/internal/api_clearChannelCard.go b/net/server/internal/api_clearChannelCard.go index 20fd0f7d..192a1a71 100644 --- a/net/server/internal/api_clearChannelCard.go +++ b/net/server/internal/api_clearChannelCard.go @@ -18,12 +18,12 @@ func ClearChannelCard(w http.ResponseWriter, r *http.Request) { // scan parameters params := mux.Vars(r) - channelId := params["channelId"] - cardId := params["cardId"] + channelID := params["channelID"] + cardID := params["cardID"] // load referenced channel 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) { ErrResponse(w, http.StatusInternalServerError, err) } else { @@ -38,7 +38,7 @@ func ClearChannelCard(w http.ResponseWriter, r *http.Request) { // load referenced card 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) { ErrResponse(w, http.StatusInternalServerError, err) } else { @@ -54,11 +54,11 @@ func ClearChannelCard(w http.ResponseWriter, r *http.Request) { // determine contact list cards := make(map[string]store.Card) for _, card := range channelSlot.Channel.Cards { - cards[card.Guid] = card + cards[card.GUID] = card } for _, group := range channelSlot.Channel.Groups { for _, card := range group.Cards { - cards[card.Guid] = card + cards[card.GUID] = card } } diff --git a/net/server/internal/api_clearChannelGroup.go b/net/server/internal/api_clearChannelGroup.go index 176e37b6..a33e7f9f 100644 --- a/net/server/internal/api_clearChannelGroup.go +++ b/net/server/internal/api_clearChannelGroup.go @@ -18,12 +18,12 @@ func ClearChannelGroup(w http.ResponseWriter, r *http.Request) { // scan parameters params := mux.Vars(r) - channelId := params["channelId"] - groupId := params["groupId"] + channelID := params["channelID"] + groupID := params["groupID"] // load referenced channel 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) { ErrResponse(w, http.StatusInternalServerError, err) } else { @@ -38,7 +38,7 @@ func ClearChannelGroup(w http.ResponseWriter, r *http.Request) { // load referenced group 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) { ErrResponse(w, http.StatusInternalServerError, err) } else { @@ -55,7 +55,7 @@ func ClearChannelGroup(w http.ResponseWriter, r *http.Request) { cards := make(map[string]store.Card) for _, group := range channelSlot.Channel.Groups { for _, card := range group.Cards { - cards[card.Guid] = card + cards[card.GUID] = card } } diff --git a/net/server/internal/api_getAccountListing.go b/net/server/internal/api_getAccountListing.go index f54eaf8a..6709cead 100644 --- a/net/server/internal/api_getAccountListing.go +++ b/net/server/internal/api_getAccountListing.go @@ -16,7 +16,7 @@ func GetAccountListing(w http.ResponseWriter, r *http.Request) { profiles := []CardProfile{} for _, account := range accounts { profiles = append(profiles, CardProfile{ - Guid: account.Guid, + GUID: account.GUID, Handle: account.Username, Name: account.AccountDetail.Name, Description: account.AccountDetail.Description, diff --git a/net/server/internal/api_getAccountListingMessage.go b/net/server/internal/api_getAccountListingMessage.go index d9800de9..22683086 100644 --- a/net/server/internal/api_getAccountListingMessage.go +++ b/net/server/internal/api_getAccountListingMessage.go @@ -37,7 +37,7 @@ func GetAccountListingMessage(w http.ResponseWriter, r *http.Request) { Node: getStrConfigValue(CONFIG_DOMAIN, ""), } 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 { ErrResponse(w, http.StatusInternalServerError, res) return diff --git a/net/server/internal/api_getArticleSubjectField.go b/net/server/internal/api_getArticleSubjectField.go index 17fe31ed..52cffc3b 100644 --- a/net/server/internal/api_getArticleSubjectField.go +++ b/net/server/internal/api_getArticleSubjectField.go @@ -17,7 +17,7 @@ func GetArticleSubjectField(w http.ResponseWriter, r *http.Request) { // scan parameters params := mux.Vars(r) - articleId := params["articleId"] + articleID := params["articleID"] field := params["field"] elements := strings.Split(field, ".") @@ -38,7 +38,7 @@ func GetArticleSubjectField(w http.ResponseWriter, r *http.Request) { return } act = &card.Account - guid = card.Guid + guid = card.GUID } else { ErrResponse(w, http.StatusBadRequest, errors.New("unknown token type")) return @@ -46,7 +46,7 @@ func GetArticleSubjectField(w http.ResponseWriter, r *http.Request) { // load article 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) { ErrResponse(w, http.StatusNotFound, err) } else { diff --git a/net/server/internal/api_getArticles.go b/net/server/internal/api_getArticles.go index e5c8cf4c..d995633e 100644 --- a/net/server/internal/api_getArticles.go +++ b/net/server/internal/api_getArticles.go @@ -110,7 +110,7 @@ func GetArticles(w http.ResponseWriter, r *http.Request) { for _, slot := range slots { if !typesSet || hasArticleType(types, slot.Article) { - shared := isArticleShared(card.Guid, slot.Article) + shared := isArticleShared(card.GUID, slot.Article) if articleRevisionSet { response = append(response, getArticleModel(&slot, shared, false)) } else if shared { @@ -136,7 +136,7 @@ func isArticleShared(guid string, article *store.Article) bool { } for _, group := range article.Groups { for _, card := range group.Cards { - if guid == card.Guid { + if guid == card.GUID { return true } } diff --git a/net/server/internal/api_getCard.go b/net/server/internal/api_getCard.go index 1945b34a..71a114a8 100644 --- a/net/server/internal/api_getCard.go +++ b/net/server/internal/api_getCard.go @@ -15,10 +15,10 @@ func GetCard(w http.ResponseWriter, r *http.Request) { ErrResponse(w, code, err) return } - cardId := mux.Vars(r)["cardId"] + cardID := mux.Vars(r)["cardID"] 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) { ErrResponse(w, http.StatusNotFound, err) } else { diff --git a/net/server/internal/api_getCardDetail.go b/net/server/internal/api_getCardDetail.go index e8f5f1d7..fb383a37 100644 --- a/net/server/internal/api_getCardDetail.go +++ b/net/server/internal/api_getCardDetail.go @@ -15,10 +15,10 @@ func GetCardDetail(w http.ResponseWriter, r *http.Request) { ErrResponse(w, code, err) return } - cardId := mux.Vars(r)["cardId"] + cardID := mux.Vars(r)["cardID"] 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) { ErrResponse(w, http.StatusNotFound, err) } else { diff --git a/net/server/internal/api_getCardImage.go b/net/server/internal/api_getCardImage.go index 5e181cb8..defe903b 100644 --- a/net/server/internal/api_getCardImage.go +++ b/net/server/internal/api_getCardImage.go @@ -19,10 +19,10 @@ func GetCardProfileImage(w http.ResponseWriter, r *http.Request) { ErrResponse(w, code, err) return } - cardId := mux.Vars(r)["cardId"] + cardID := mux.Vars(r)["cardID"] 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) { ErrResponse(w, http.StatusNotFound, err) } else { diff --git a/net/server/internal/api_getCardProfile.go b/net/server/internal/api_getCardProfile.go index b24bf097..ce9de3d7 100644 --- a/net/server/internal/api_getCardProfile.go +++ b/net/server/internal/api_getCardProfile.go @@ -15,10 +15,10 @@ func GetCardProfile(w http.ResponseWriter, r *http.Request) { ErrResponse(w, code, err) return } - cardId := mux.Vars(r)["cardId"] + cardID := mux.Vars(r)["cardID"] 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) { ErrResponse(w, http.StatusNotFound, err) } else { diff --git a/net/server/internal/api_getChannelDetail.go b/net/server/internal/api_getChannelDetail.go index 90fd7602..9042ab87 100644 --- a/net/server/internal/api_getChannelDetail.go +++ b/net/server/internal/api_getChannelDetail.go @@ -12,7 +12,7 @@ func GetChannelDetail(w http.ResponseWriter, r *http.Request) { // scan parameters params := mux.Vars(r) - channelId := params["channelId"] + channelID := params["channelID"] var guid string var act *store.Account @@ -31,7 +31,7 @@ func GetChannelDetail(w http.ResponseWriter, r *http.Request) { return } act = &card.Account - guid = card.Guid + guid = card.GUID } else { ErrResponse(w, http.StatusBadRequest, errors.New("unknown token type")) return @@ -39,7 +39,7 @@ func GetChannelDetail(w http.ResponseWriter, r *http.Request) { // load channel 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) { ErrResponse(w, http.StatusNotFound, err) } else { diff --git a/net/server/internal/api_getChannelSummary.go b/net/server/internal/api_getChannelSummary.go index 4b1a638b..f8859aec 100644 --- a/net/server/internal/api_getChannelSummary.go +++ b/net/server/internal/api_getChannelSummary.go @@ -12,7 +12,7 @@ func GetChannelSummary(w http.ResponseWriter, r *http.Request) { // scan parameters params := mux.Vars(r) - channelId := params["channelId"] + channelID := params["channelID"] var guid string var act *store.Account @@ -31,7 +31,7 @@ func GetChannelSummary(w http.ResponseWriter, r *http.Request) { return } act = &card.Account - guid = card.Guid + guid = card.GUID } else { ErrResponse(w, http.StatusBadRequest, errors.New("unknown token type")) return @@ -41,7 +41,7 @@ func GetChannelSummary(w http.ResponseWriter, r *http.Request) { var slot store.ChannelSlot if err := store.DB.Preload("Channel.Topics", func(db *gorm.DB) *gorm.DB { 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) { ErrResponse(w, http.StatusNotFound, err) } else { diff --git a/net/server/internal/api_getChannelTopic.go b/net/server/internal/api_getChannelTopic.go index 34d25ca8..195c2cfd 100644 --- a/net/server/internal/api_getChannelTopic.go +++ b/net/server/internal/api_getChannelTopic.go @@ -12,7 +12,7 @@ func GetChannelTopic(w http.ResponseWriter, r *http.Request) { // scan parameters params := mux.Vars(r) - topicId := params["topicId"] + topicID := params["topicID"] channelSlot, _, err, code := getChannelSlot(r, false) if err != nil { @@ -22,7 +22,7 @@ func GetChannelTopic(w http.ResponseWriter, r *http.Request) { // load topic 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) { code = http.StatusNotFound } else { @@ -36,7 +36,7 @@ func GetChannelTopic(w http.ResponseWriter, r *http.Request) { func isMember(guid string, cards []store.Card) bool { for _, card := range cards { - if guid == card.Guid { + if guid == card.GUID { return true } } @@ -46,7 +46,7 @@ func isMember(guid string, cards []store.Card) bool { func isViewer(guid string, groups []store.Group) bool { for _, group := range groups { for _, card := range group.Cards { - if guid == card.Guid { + if guid == card.GUID { return true } } @@ -58,7 +58,7 @@ func getChannelSlot(r *http.Request, member bool) (slot store.ChannelSlot, guid // scan parameters params := mux.Vars(r) - channelId := params["channelId"] + channelID := params["channelID"] // validate contact access var account *store.Account @@ -68,7 +68,7 @@ func getChannelSlot(r *http.Request, member bool) (slot store.ChannelSlot, guid if err != nil { return } - guid = account.Guid + guid = account.GUID } else if tokenType == APP_TOKENCONTACT { var card *store.Card card, code, err = ParamContactToken(r, true) @@ -76,7 +76,7 @@ func getChannelSlot(r *http.Request, member bool) (slot store.ChannelSlot, guid return } account = &card.Account - guid = card.Guid + guid = card.GUID } else { err = errors.New("unknown token type") code = http.StatusBadRequest @@ -84,7 +84,7 @@ func getChannelSlot(r *http.Request, member bool) (slot store.ChannelSlot, guid } // 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) { code = http.StatusNotFound } else { diff --git a/net/server/internal/api_getChannelTopicAsset.go b/net/server/internal/api_getChannelTopicAsset.go index 44127e8c..dc92f6b7 100644 --- a/net/server/internal/api_getChannelTopicAsset.go +++ b/net/server/internal/api_getChannelTopicAsset.go @@ -12,8 +12,8 @@ func GetChannelTopicAsset(w http.ResponseWriter, r *http.Request) { // scan parameters params := mux.Vars(r) - topicId := params["topicId"] - assetId := params["assetId"] + topicID := params["topicID"] + assetID := params["assetID"] channelSlot, _, err, code := getChannelSlot(r, true) if err != nil { @@ -24,7 +24,7 @@ func GetChannelTopicAsset(w http.ResponseWriter, r *http.Request) { // load 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) { ErrResponse(w, http.StatusNotFound, err) } else { @@ -32,7 +32,7 @@ func GetChannelTopicAsset(w http.ResponseWriter, r *http.Request) { } return } - if asset.Topic.TopicSlot.TopicSlotId != topicId { + if asset.Topic.TopicSlot.TopicSlotID != topicID { ErrResponse(w, http.StatusNotFound, errors.New("invalid topic asset")) return } @@ -42,7 +42,7 @@ func GetChannelTopicAsset(w http.ResponseWriter, r *http.Request) { } // 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) } diff --git a/net/server/internal/api_getChannelTopicAssets.go b/net/server/internal/api_getChannelTopicAssets.go index dd4f257c..0d30dd14 100644 --- a/net/server/internal/api_getChannelTopicAssets.go +++ b/net/server/internal/api_getChannelTopicAssets.go @@ -12,7 +12,7 @@ func GetChannelTopicAssets(w http.ResponseWriter, r *http.Request) { // scan parameters params := mux.Vars(r) - topicId := params["topicId"] + topicID := params["topicID"] channelSlot, guid, err, code := getChannelSlot(r, true) if err != nil { @@ -22,7 +22,7 @@ func GetChannelTopicAssets(w http.ResponseWriter, r *http.Request) { // load topic 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) { ErrResponse(w, http.StatusNotFound, err) } else { @@ -36,7 +36,7 @@ func GetChannelTopicAssets(w http.ResponseWriter, r *http.Request) { } // 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")) return } @@ -44,7 +44,7 @@ func GetChannelTopicAssets(w http.ResponseWriter, r *http.Request) { // return list of assets assets := []Asset{} 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) } diff --git a/net/server/internal/api_getChannelTopicDetail.go b/net/server/internal/api_getChannelTopicDetail.go index 766d02e1..df642b38 100644 --- a/net/server/internal/api_getChannelTopicDetail.go +++ b/net/server/internal/api_getChannelTopicDetail.go @@ -12,7 +12,7 @@ func GetChannelTopicDetail(w http.ResponseWriter, r *http.Request) { // scan parameters params := mux.Vars(r) - topicId := params["topicId"] + topicID := params["topicID"] var subject Subject if err := ParseRequest(r, w, &subject); err != nil { @@ -28,7 +28,7 @@ func GetChannelTopicDetail(w http.ResponseWriter, r *http.Request) { // load topic 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) { code = http.StatusNotFound } else { diff --git a/net/server/internal/api_getChannelTopicSubjectField.go b/net/server/internal/api_getChannelTopicSubjectField.go index 96790ca6..5f6fa913 100644 --- a/net/server/internal/api_getChannelTopicSubjectField.go +++ b/net/server/internal/api_getChannelTopicSubjectField.go @@ -17,7 +17,7 @@ func GetChannelTopicSubjectField(w http.ResponseWriter, r *http.Request) { // scan parameters params := mux.Vars(r) - topicId := params["topicId"] + topicID := params["topicID"] field := params["field"] elements := strings.Split(field, ".") @@ -29,7 +29,7 @@ func GetChannelTopicSubjectField(w http.ResponseWriter, r *http.Request) { // load topic 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) { code = http.StatusNotFound } else { diff --git a/net/server/internal/api_getChannelTopicTagSubjectField.go b/net/server/internal/api_getChannelTopicTagSubjectField.go index b43ce7f3..7b4de8f9 100644 --- a/net/server/internal/api_getChannelTopicTagSubjectField.go +++ b/net/server/internal/api_getChannelTopicTagSubjectField.go @@ -17,8 +17,8 @@ func GetChannelTopicTagSubjectField(w http.ResponseWriter, r *http.Request) { // scan parameters params := mux.Vars(r) - topicId := params["topicId"] - tagId := params["tagId"] + topicID := params["topicID"] + tagID := params["tagID"] field := params["field"] elements := strings.Split(field, ".") @@ -30,7 +30,7 @@ func GetChannelTopicTagSubjectField(w http.ResponseWriter, r *http.Request) { // load tag 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) { code = http.StatusNotFound } else { @@ -42,7 +42,7 @@ func GetChannelTopicTagSubjectField(w http.ResponseWriter, r *http.Request) { ErrResponse(w, http.StatusNotFound, errors.New("referenced missing tag")) return } - if tagSlot.Tag.Topic.TopicSlot.TopicSlotId != topicId { + if tagSlot.Tag.Topic.TopicSlot.TopicSlotID != topicID { ErrResponse(w, http.StatusNotFound, errors.New("invalid topic tag")) return } diff --git a/net/server/internal/api_getChannelTopicTags.go b/net/server/internal/api_getChannelTopicTags.go index 4d07a361..278cb510 100644 --- a/net/server/internal/api_getChannelTopicTags.go +++ b/net/server/internal/api_getChannelTopicTags.go @@ -36,7 +36,7 @@ func GetChannelTopicTags(w http.ResponseWriter, r *http.Request) { // scan parameters params := mux.Vars(r) - topicId := params["topicId"] + topicID := params["topicID"] rev := r.FormValue("revision") if rev != "" { @@ -76,7 +76,7 @@ func GetChannelTopicTags(w http.ResponseWriter, r *http.Request) { // load topic 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) { ErrResponse(w, http.StatusNotFound, err) } else { diff --git a/net/server/internal/api_getChannels.go b/net/server/internal/api_getChannels.go index 3f4f5629..5705552e 100644 --- a/net/server/internal/api_getChannels.go +++ b/net/server/internal/api_getChannels.go @@ -119,7 +119,7 @@ func GetChannels(w http.ResponseWriter, r *http.Request) { for _, slot := range slots { if !typesSet || hasChannelType(types, slot.Channel) { - shared := isChannelShared(card.Guid, slot.Channel) + shared := isChannelShared(card.GUID, slot.Channel) if channelRevisionSet { response = append(response, getChannelRevisionModel(&slot, shared)) } else if shared { @@ -144,13 +144,13 @@ func isChannelShared(guid string, channel *store.Channel) bool { return false } for _, card := range channel.Cards { - if guid == card.Guid { + if guid == card.GUID { return true } } for _, group := range channel.Groups { for _, card := range group.Cards { - if guid == card.Guid { + if guid == card.GUID { return true } } diff --git a/net/server/internal/api_getCloseMessage.go b/net/server/internal/api_getCloseMessage.go index 3ca87d58..6202e51f 100644 --- a/net/server/internal/api_getCloseMessage.go +++ b/net/server/internal/api_getCloseMessage.go @@ -16,10 +16,10 @@ func GetCloseMessage(w http.ResponseWriter, r *http.Request) { return } detail := account.AccountDetail - cardId := mux.Vars(r)["cardId"] + cardID := mux.Vars(r)["cardID"] 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) { ErrResponse(w, http.StatusInternalServerError, err) } else { @@ -38,11 +38,11 @@ func GetCloseMessage(w http.ResponseWriter, r *http.Request) { } disconnect := &Disconnect{ - Contact: slot.Card.Guid, + Contact: slot.Card.GUID, } 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 { ErrResponse(w, http.StatusInternalServerError, err) return diff --git a/net/server/internal/api_getGroupSubjectField.go b/net/server/internal/api_getGroupSubjectField.go index ed8431bd..77bdf0e4 100644 --- a/net/server/internal/api_getGroupSubjectField.go +++ b/net/server/internal/api_getGroupSubjectField.go @@ -17,7 +17,7 @@ func GetGroupSubjectField(w http.ResponseWriter, r *http.Request) { // scan parameters params := mux.Vars(r) - groupId := params["groupId"] + groupID := params["groupID"] field := params["field"] elements := strings.Split(field, ".") @@ -29,7 +29,7 @@ func GetGroupSubjectField(w http.ResponseWriter, r *http.Request) { // load group 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) { ErrResponse(w, http.StatusNotFound, err) } else { diff --git a/net/server/internal/api_getNodeAccountImage.go b/net/server/internal/api_getNodeAccountImage.go index 6696c542..5dfa35f1 100644 --- a/net/server/internal/api_getNodeAccountImage.go +++ b/net/server/internal/api_getNodeAccountImage.go @@ -16,7 +16,7 @@ func GetNodeAccountImage(w http.ResponseWriter, r *http.Request) { // get referenced account id params := mux.Vars(r) - accountId, res := strconv.ParseUint(params["accountId"], 10, 32) + accountID, res := strconv.ParseUint(params["accountID"], 10, 32) if res != nil { ErrResponse(w, http.StatusBadRequest, res) return @@ -28,7 +28,7 @@ func GetNodeAccountImage(w http.ResponseWriter, r *http.Request) { } 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) { ErrResponse(w, http.StatusNotFound, err) } else { diff --git a/net/server/internal/api_getNodeAccounts.go b/net/server/internal/api_getNodeAccounts.go index 04cae725..3b8c7c98 100644 --- a/net/server/internal/api_getNodeAccounts.go +++ b/net/server/internal/api_getNodeAccounts.go @@ -21,8 +21,8 @@ func GetNodeAccounts(w http.ResponseWriter, r *http.Request) { profiles := []AccountProfile{} for _, account := range accounts { profiles = append(profiles, AccountProfile{ - AccountId: uint32(account.ID), - Guid: account.Guid, + AccountID: uint32(account.ID), + GUID: account.GUID, Handle: account.Username, Name: account.AccountDetail.Name, Description: account.AccountDetail.Description, diff --git a/net/server/internal/api_getOpenMessage.go b/net/server/internal/api_getOpenMessage.go index a53b56d4..e1ed3db5 100644 --- a/net/server/internal/api_getOpenMessage.go +++ b/net/server/internal/api_getOpenMessage.go @@ -16,10 +16,10 @@ func GetOpenMessage(w http.ResponseWriter, r *http.Request) { return } detail := account.AccountDetail - cardId := mux.Vars(r)["cardId"] + cardID := mux.Vars(r)["cardID"] 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) { ErrResponse(w, http.StatusInternalServerError, err) } else { @@ -38,7 +38,7 @@ func GetOpenMessage(w http.ResponseWriter, r *http.Request) { } connect := &Connect{ - Contact: slot.Card.Guid, + Contact: slot.Card.GUID, Token: slot.Card.InToken, ArticleRevision: account.ArticleRevision, ProfileRevision: account.ProfileRevision, @@ -54,7 +54,7 @@ func GetOpenMessage(w http.ResponseWriter, r *http.Request) { } 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 { ErrResponse(w, http.StatusInternalServerError, err) return diff --git a/net/server/internal/api_getProfileMessage.go b/net/server/internal/api_getProfileMessage.go index 5d5cce0f..49878f70 100644 --- a/net/server/internal/api_getProfileMessage.go +++ b/net/server/internal/api_getProfileMessage.go @@ -43,7 +43,7 @@ func GetProfileMessage(w http.ResponseWriter, r *http.Request) { Node: getStrConfigValue(CONFIG_DOMAIN, ""), } 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 { ErrResponse(w, http.StatusInternalServerError, res) return diff --git a/net/server/internal/api_removeAccount.go b/net/server/internal/api_removeAccount.go index ffd39081..765f997d 100644 --- a/net/server/internal/api_removeAccount.go +++ b/net/server/internal/api_removeAccount.go @@ -78,7 +78,7 @@ func RemoveAccount(w http.ResponseWriter, r *http.Request) { } // 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 { ErrMsg(err) } diff --git a/net/server/internal/api_removeArticle.go b/net/server/internal/api_removeArticle.go index f8746b2e..7cc7d318 100644 --- a/net/server/internal/api_removeArticle.go +++ b/net/server/internal/api_removeArticle.go @@ -18,11 +18,11 @@ func RemoveArticle(w http.ResponseWriter, r *http.Request) { // scan parameters params := mux.Vars(r) - articleId := params["articleId"] + articleID := params["articleID"] // load referenced article 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) { ErrResponse(w, http.StatusInternalServerError, err) } else { @@ -39,7 +39,7 @@ func RemoveArticle(w http.ResponseWriter, r *http.Request) { cards := make(map[string]*store.Card) for _, group := range slot.Article.Groups { for _, card := range group.Cards { - cards[card.Guid] = &card + cards[card.GUID] = &card } } diff --git a/net/server/internal/api_removeCard.go b/net/server/internal/api_removeCard.go index 932ef13b..235a71db 100644 --- a/net/server/internal/api_removeCard.go +++ b/net/server/internal/api_removeCard.go @@ -18,11 +18,11 @@ func RemoveCard(w http.ResponseWriter, r *http.Request) { // scan parameters params := mux.Vars(r) - cardId := params["cardId"] + cardID := params["cardID"] // load referenced card 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) { ErrResponse(w, http.StatusInternalServerError, err) } else { @@ -48,7 +48,7 @@ func RemoveCard(w http.ResponseWriter, r *http.Request) { return res } for _, card := range channel.Cards { - cards[card.Guid] = &card + cards[card.GUID] = &card } } if res := tx.Model(&slot.Card).Association("Groups").Clear(); res != nil { diff --git a/net/server/internal/api_removeChannel.go b/net/server/internal/api_removeChannel.go index a136ef79..fbb6ce79 100644 --- a/net/server/internal/api_removeChannel.go +++ b/net/server/internal/api_removeChannel.go @@ -14,7 +14,7 @@ func RemoveChannel(w http.ResponseWriter, r *http.Request) { // scan parameters params := mux.Vars(r) - channelId := params["channelId"] + channelID := params["channelID"] // validate contact access var account *store.Account @@ -41,7 +41,7 @@ func RemoveChannel(w http.ResponseWriter, r *http.Request) { // load channel 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) { ErrResponse(w, http.StatusNotFound, err) } else { @@ -57,11 +57,11 @@ func RemoveChannel(w http.ResponseWriter, r *http.Request) { // determine affected contact list cards := make(map[string]store.Card) for _, card := range slot.Channel.Cards { - cards[card.Guid] = card + cards[card.GUID] = card } for _, group := range slot.Channel.Groups { 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 go garbageCollect(account) } else { - if _, member := cards[contact.Guid]; !member { + if _, member := cards[contact.GUID]; !member { ErrResponse(w, http.StatusNotFound, errors.New("member channel not found")); return } diff --git a/net/server/internal/api_removeChannelTopic.go b/net/server/internal/api_removeChannelTopic.go index 9d40380a..9be39401 100644 --- a/net/server/internal/api_removeChannelTopic.go +++ b/net/server/internal/api_removeChannelTopic.go @@ -12,8 +12,8 @@ func RemoveChannelTopic(w http.ResponseWriter, r *http.Request) { // scan parameters params := mux.Vars(r) - channelId := params["channelId"] - topicId := params["topicId"] + channelID := params["channelID"] + topicID := params["topicID"] channelSlot, guid, err, code := getChannelSlot(r, true) if err != nil { @@ -24,7 +24,7 @@ func RemoveChannelTopic(w http.ResponseWriter, r *http.Request) { // load topic 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) { ErrResponse(w, http.StatusNotFound, ret) } else { @@ -35,13 +35,13 @@ func RemoveChannelTopic(w http.ResponseWriter, r *http.Request) { ErrResponse(w, http.StatusNotFound, errors.New("referenced empty topic")) 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")) return } // 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")) return } @@ -86,11 +86,11 @@ func RemoveChannelTopic(w http.ResponseWriter, r *http.Request) { // determine affected contact list cards := make(map[string]store.Card) for _, card := range channelSlot.Channel.Cards { - cards[card.Guid] = card + cards[card.GUID] = card } for _, group := range channelSlot.Channel.Groups { for _, card := range group.Cards { - cards[card.Guid] = card + cards[card.GUID] = card } } diff --git a/net/server/internal/api_removeChannelTopicAsset.go b/net/server/internal/api_removeChannelTopicAsset.go index 077976e5..c98d09c7 100644 --- a/net/server/internal/api_removeChannelTopicAsset.go +++ b/net/server/internal/api_removeChannelTopicAsset.go @@ -12,8 +12,8 @@ func RemoveChannelTopicAsset(w http.ResponseWriter, r *http.Request) { // scan parameters params := mux.Vars(r) - topicId := params["topicId"] - assetId := params["assetId"] + topicID := params["topicID"] + assetID := params["assetID"] channelSlot, guid, err, code := getChannelSlot(r, true) if err != nil { @@ -24,7 +24,7 @@ func RemoveChannelTopicAsset(w http.ResponseWriter, r *http.Request) { // load 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) { ErrResponse(w, http.StatusNotFound, err) } else { @@ -32,13 +32,13 @@ func RemoveChannelTopicAsset(w http.ResponseWriter, r *http.Request) { } return } - if asset.Topic.TopicSlot.TopicSlotId != topicId { + if asset.Topic.TopicSlot.TopicSlotID != topicID { ErrResponse(w, http.StatusNotFound, errors.New("invalid topic")) return } // 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")) return } @@ -76,11 +76,11 @@ func RemoveChannelTopicAsset(w http.ResponseWriter, r *http.Request) { // determine affected contact list cards := make(map[string]store.Card) for _, card := range channelSlot.Channel.Cards { - cards[card.Guid] = card + cards[card.GUID] = card } for _, group := range channelSlot.Channel.Groups { for _, card := range group.Cards { - cards[card.Guid] = card + cards[card.GUID] = card } } diff --git a/net/server/internal/api_removeChannelTopicTag.go b/net/server/internal/api_removeChannelTopicTag.go index 48bfc6bc..d26113ae 100644 --- a/net/server/internal/api_removeChannelTopicTag.go +++ b/net/server/internal/api_removeChannelTopicTag.go @@ -12,9 +12,9 @@ func RemoveChannelTopicTag(w http.ResponseWriter, r *http.Request) { // scan parameters params := mux.Vars(r) - channelId := params["channelId"] - topicId := params["topicId"] - tagId := params["tagId"] + channelID := params["channelID"] + topicID := params["topicID"] + tagID := params["tagID"] channelSlot, guid, err, code := getChannelSlot(r, false) if err != nil { @@ -25,7 +25,7 @@ func RemoveChannelTopicTag(w http.ResponseWriter, r *http.Request) { // load topic 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) { ErrResponse(w, http.StatusNotFound, ret) } else { @@ -36,7 +36,7 @@ func RemoveChannelTopicTag(w http.ResponseWriter, r *http.Request) { ErrResponse(w, http.StatusNotFound, errors.New("referenced empty topic")) 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")) return } @@ -45,7 +45,7 @@ func RemoveChannelTopicTag(w http.ResponseWriter, r *http.Request) { var tag *store.Tag var tags []store.Tag for _, t := range topicSlot.Topic.Tags { - if t.TagSlot.TagSlotId == tagId { + if t.TagSlot.TagSlotID == tagID { tag = &t } else { tags = append(tags, t) @@ -60,7 +60,7 @@ func RemoveChannelTopicTag(w http.ResponseWriter, r *http.Request) { } // check permission - if tag.Guid != guid { + if tag.GUID != guid { ErrResponse(w, http.StatusUnauthorized, errors.New("not creator of tag")) return } @@ -98,11 +98,11 @@ func RemoveChannelTopicTag(w http.ResponseWriter, r *http.Request) { // determine affected contact list cards := make(map[string]store.Card) for _, card := range channelSlot.Channel.Cards { - cards[card.Guid] = card + cards[card.GUID] = card } for _, group := range channelSlot.Channel.Groups { for _, card := range group.Cards { - cards[card.Guid] = card + cards[card.GUID] = card } } diff --git a/net/server/internal/api_removeGroup.go b/net/server/internal/api_removeGroup.go index c5c78783..2727c13b 100644 --- a/net/server/internal/api_removeGroup.go +++ b/net/server/internal/api_removeGroup.go @@ -18,11 +18,11 @@ func RemoveGroup(w http.ResponseWriter, r *http.Request) { // scan parameters params := mux.Vars(r) - groupId := params["groupId"] + groupID := params["groupID"] // load referenced group 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) { ErrResponse(w, http.StatusInternalServerError, err) } else { diff --git a/net/server/internal/api_removeNodeAccount.go b/net/server/internal/api_removeNodeAccount.go index 2f024165..476eddcb 100644 --- a/net/server/internal/api_removeNodeAccount.go +++ b/net/server/internal/api_removeNodeAccount.go @@ -14,7 +14,7 @@ func RemoveNodeAccount(w http.ResponseWriter, r *http.Request) { // get referenced account id params := mux.Vars(r) - accountId, res := strconv.ParseUint(params["accountId"], 10, 32) + accountID, res := strconv.ParseUint(params["accountID"], 10, 32) if res != nil { ErrResponse(w, http.StatusBadRequest, res) return @@ -26,7 +26,7 @@ func RemoveNodeAccount(w http.ResponseWriter, r *http.Request) { } 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) { ErrResponse(w, http.StatusNotFound, err) } else { @@ -98,7 +98,7 @@ func RemoveNodeAccount(w http.ResponseWriter, r *http.Request) { } // 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 { ErrMsg(err) } diff --git a/net/server/internal/api_setAccountAccess.go b/net/server/internal/api_setAccountAccess.go index 6691822a..186e95d3 100644 --- a/net/server/internal/api_setAccountAccess.go +++ b/net/server/internal/api_setAccountAccess.go @@ -39,7 +39,7 @@ func SetAccountAccess(w http.ResponseWriter, r *http.Request) { // create app entry app := store.App { - AccountID: account.Guid, + AccountID: account.GUID, Name: appData.Name, Description: appData.Description, Image: appData.Image, @@ -65,7 +65,7 @@ func SetAccountAccess(w http.ResponseWriter, r *http.Request) { return } - WriteResponse(w, account.Guid + "." + access) + WriteResponse(w, account.GUID + "." + access) } diff --git a/net/server/internal/api_setArticleGroup.go b/net/server/internal/api_setArticleGroup.go index b94c0d98..f10f4ada 100644 --- a/net/server/internal/api_setArticleGroup.go +++ b/net/server/internal/api_setArticleGroup.go @@ -18,12 +18,12 @@ func SetArticleGroup(w http.ResponseWriter, r *http.Request) { // scan parameters params := mux.Vars(r) - articleId := params["articleId"] - groupId := params["groupId"] + articleID := params["articleID"] + groupID := params["groupID"] // load referenced article 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) { ErrResponse(w, http.StatusInternalServerError, err) } else { @@ -38,7 +38,7 @@ func SetArticleGroup(w http.ResponseWriter, r *http.Request) { // load referenced group 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) { ErrResponse(w, http.StatusInternalServerError, err) } else { diff --git a/net/server/internal/api_setArticleSubject.go b/net/server/internal/api_setArticleSubject.go index 8f8489a7..b92c00b0 100644 --- a/net/server/internal/api_setArticleSubject.go +++ b/net/server/internal/api_setArticleSubject.go @@ -18,7 +18,7 @@ func SetArticleSubject(w http.ResponseWriter, r *http.Request) { // scan parameters params := mux.Vars(r) - articleId := params["articleId"] + articleID := params["articleID"] var subject Subject if err := ParseRequest(r, w, &subject); err != nil { @@ -28,7 +28,7 @@ func SetArticleSubject(w http.ResponseWriter, r *http.Request) { // load referenced article 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) { ErrResponse(w, http.StatusInternalServerError, err) } else { @@ -45,7 +45,7 @@ func SetArticleSubject(w http.ResponseWriter, r *http.Request) { cards := make(map[string]store.Card) for _, group := range slot.Article.Groups { for _, card := range group.Cards { - cards[card.Guid] = card + cards[card.GUID] = card } } diff --git a/net/server/internal/api_setCardGroup.go b/net/server/internal/api_setCardGroup.go index 2e61d68a..873bd4ef 100644 --- a/net/server/internal/api_setCardGroup.go +++ b/net/server/internal/api_setCardGroup.go @@ -17,12 +17,12 @@ func SetCardGroup(w http.ResponseWriter, r *http.Request) { // scan parameters params := mux.Vars(r) - cardId := params["cardId"] - groupId := params["groupId"] + cardID := params["cardID"] + groupID := params["groupID"] // load referenced card 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) { ErrResponse(w, http.StatusNotFound, err) } else { @@ -37,7 +37,7 @@ func SetCardGroup(w http.ResponseWriter, r *http.Request) { // load referenced group 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) { ErrResponse(w, http.StatusInternalServerError, err) } else { diff --git a/net/server/internal/api_setCardNotes.go b/net/server/internal/api_setCardNotes.go index 43b3b666..8ef8af5c 100644 --- a/net/server/internal/api_setCardNotes.go +++ b/net/server/internal/api_setCardNotes.go @@ -18,7 +18,7 @@ func SetCardNotes(w http.ResponseWriter, r *http.Request) { // scan parameters params := mux.Vars(r) - cardId := params["cardId"] + cardID := params["cardID"] var notes string if err := ParseRequest(r, w, ¬es); err != nil { @@ -28,7 +28,7 @@ func SetCardNotes(w http.ResponseWriter, r *http.Request) { // load referenced card 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) { ErrResponse(w, http.StatusInternalServerError, err) } else { diff --git a/net/server/internal/api_setCardProfile.go b/net/server/internal/api_setCardProfile.go index 88d304e7..b42af3f6 100644 --- a/net/server/internal/api_setCardProfile.go +++ b/net/server/internal/api_setCardProfile.go @@ -18,7 +18,7 @@ func SetCardProfile(w http.ResponseWriter, r *http.Request) { // scan parameters params := mux.Vars(r) - cardId := params["cardId"] + cardID := params["cardID"] var message DataMessage if err := ParseRequest(r, w, &message); err != nil { @@ -34,7 +34,7 @@ func SetCardProfile(w http.ResponseWriter, r *http.Request) { } 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) { ErrResponse(w, http.StatusNotFound, err) } else { @@ -47,7 +47,7 @@ func SetCardProfile(w http.ResponseWriter, r *http.Request) { ErrResponse(w, http.StatusNotFound, errors.New("referenced empty card")) return } - if card.Guid != guid { + if card.GUID != guid { ErrResponse(w, http.StatusBadRequest, errors.New("invalid profile")) return } diff --git a/net/server/internal/api_setCardStatus.go b/net/server/internal/api_setCardStatus.go index 1a37852a..9a3a7cc6 100644 --- a/net/server/internal/api_setCardStatus.go +++ b/net/server/internal/api_setCardStatus.go @@ -22,7 +22,7 @@ func SetCardStatus(w http.ResponseWriter, r *http.Request) { // scan parameters params := mux.Vars(r) - cardId := params["cardId"] + cardID := params["cardID"] token := r.FormValue("token") // scan revisions @@ -75,7 +75,7 @@ func SetCardStatus(w http.ResponseWriter, r *http.Request) { // load referenced card 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) { ErrResponse(w, http.StatusInternalServerError, err) } else { diff --git a/net/server/internal/api_setChannelCard.go b/net/server/internal/api_setChannelCard.go index abc85594..7e82233c 100644 --- a/net/server/internal/api_setChannelCard.go +++ b/net/server/internal/api_setChannelCard.go @@ -18,12 +18,12 @@ func SetChannelCard(w http.ResponseWriter, r *http.Request) { // scan parameters params := mux.Vars(r) - channelId := params["channelId"] - cardId := params["cardId"] + channelID := params["channelID"] + cardID := params["cardID"] // load referenced channel 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) { ErrResponse(w, http.StatusInternalServerError, err) } else { @@ -38,7 +38,7 @@ func SetChannelCard(w http.ResponseWriter, r *http.Request) { // load referenced card 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) { ErrResponse(w, http.StatusInternalServerError, err) } else { @@ -54,14 +54,14 @@ func SetChannelCard(w http.ResponseWriter, r *http.Request) { // determine contact list cards := make(map[string]store.Card) for _, card := range channelSlot.Channel.Cards { - cards[card.Guid] = card + cards[card.GUID] = card } for _, group := range channelSlot.Channel.Groups { 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 err = store.DB.Transaction(func(tx *gorm.DB) error { diff --git a/net/server/internal/api_setChannelGroup.go b/net/server/internal/api_setChannelGroup.go index d4034b85..be2cd617 100644 --- a/net/server/internal/api_setChannelGroup.go +++ b/net/server/internal/api_setChannelGroup.go @@ -18,12 +18,12 @@ func SetChannelGroup(w http.ResponseWriter, r *http.Request) { // scan parameters params := mux.Vars(r) - channelId := params["channelId"] - groupId := params["groupId"] + channelID := params["channelID"] + groupID := params["groupID"] // load referenced channel 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) { ErrResponse(w, http.StatusInternalServerError, err) } else { @@ -38,7 +38,7 @@ func SetChannelGroup(w http.ResponseWriter, r *http.Request) { // load referenced group 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) { ErrResponse(w, http.StatusInternalServerError, err) } else { @@ -73,7 +73,7 @@ func SetChannelGroup(w http.ResponseWriter, r *http.Request) { cards := make(map[string]store.Card) for _, group := range channelSlot.Channel.Groups { for _, card := range group.Cards { - cards[card.Guid] = card + cards[card.GUID] = card } } diff --git a/net/server/internal/api_setChannelSubject.go b/net/server/internal/api_setChannelSubject.go index b908599a..82e8a5e1 100644 --- a/net/server/internal/api_setChannelSubject.go +++ b/net/server/internal/api_setChannelSubject.go @@ -18,7 +18,7 @@ func SetChannelSubject(w http.ResponseWriter, r *http.Request) { // scan parameters params := mux.Vars(r) - channelId := params["channelId"] + channelID := params["channelID"] var subject Subject if err := ParseRequest(r, w, &subject); err != nil { @@ -28,7 +28,7 @@ func SetChannelSubject(w http.ResponseWriter, r *http.Request) { // load referenced channel 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) { ErrResponse(w, http.StatusInternalServerError, err) } else { @@ -44,11 +44,11 @@ func SetChannelSubject(w http.ResponseWriter, r *http.Request) { // determine affected contact list cards := make(map[string]store.Card) for _, card := range slot.Channel.Cards { - cards[card.Guid] = card + cards[card.GUID] = card } for _, group := range slot.Channel.Groups { for _, card := range group.Cards { - cards[card.Guid] = card + cards[card.GUID] = card } } diff --git a/net/server/internal/api_setChannelTopicConfirmed.go b/net/server/internal/api_setChannelTopicConfirmed.go index eb48b428..799019fe 100644 --- a/net/server/internal/api_setChannelTopicConfirmed.go +++ b/net/server/internal/api_setChannelTopicConfirmed.go @@ -12,7 +12,7 @@ func SetChannelTopicConfirmed(w http.ResponseWriter, r *http.Request) { // scan parameters params := mux.Vars(r) - topicId := params["topicId"] + topicID := params["topicID"] var status string if err := ParseRequest(r, w, &status); err != nil { @@ -33,7 +33,7 @@ func SetChannelTopicConfirmed(w http.ResponseWriter, r *http.Request) { // load topic 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) { ErrResponse(w, http.StatusNotFound, err) } else { @@ -75,11 +75,11 @@ func SetChannelTopicConfirmed(w http.ResponseWriter, r *http.Request) { // determine affected contact list cards := make(map[string]store.Card) for _, card := range channelSlot.Channel.Cards { - cards[card.Guid] = card + cards[card.GUID] = card } for _, group := range channelSlot.Channel.Groups { for _, card := range group.Cards { - cards[card.Guid] = card + cards[card.GUID] = card } } diff --git a/net/server/internal/api_setChannelTopicSubject.go b/net/server/internal/api_setChannelTopicSubject.go index baf5eca4..96c1ab1c 100644 --- a/net/server/internal/api_setChannelTopicSubject.go +++ b/net/server/internal/api_setChannelTopicSubject.go @@ -12,7 +12,7 @@ func SetChannelTopicSubject(w http.ResponseWriter, r *http.Request) { // scan parameters params := mux.Vars(r) - topicId := params["topicId"] + topicID := params["topicID"] confirm := r.FormValue("confirm"); var subject Subject @@ -30,7 +30,7 @@ func SetChannelTopicSubject(w http.ResponseWriter, r *http.Request) { // load topic 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) { ErrResponse(w, http.StatusNotFound, err) } else { @@ -40,7 +40,7 @@ func SetChannelTopicSubject(w http.ResponseWriter, r *http.Request) { } // 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")) return } @@ -88,11 +88,11 @@ func SetChannelTopicSubject(w http.ResponseWriter, r *http.Request) { // determine affected contact list cards := make(map[string]store.Card) for _, card := range channelSlot.Channel.Cards { - cards[card.Guid] = card + cards[card.GUID] = card } for _, group := range channelSlot.Channel.Groups { for _, card := range group.Cards { - cards[card.Guid] = card + cards[card.GUID] = card } } diff --git a/net/server/internal/api_setChannelTopicTagSubject.go b/net/server/internal/api_setChannelTopicTagSubject.go index d7f94a19..2ce9edf4 100644 --- a/net/server/internal/api_setChannelTopicTagSubject.go +++ b/net/server/internal/api_setChannelTopicTagSubject.go @@ -12,9 +12,9 @@ func SetChannelTopicTagSubject(w http.ResponseWriter, r *http.Request) { // scan parameters params := mux.Vars(r) - channelId := params["channelId"] - topicId := params["topicId"] - tagId := params["tagId"] + channelID := params["channelID"] + topicID := params["topicID"] + tagID := params["tagID"] var subject Subject if err := ParseRequest(r, w, &subject); err != nil { @@ -31,7 +31,7 @@ func SetChannelTopicTagSubject(w http.ResponseWriter, r *http.Request) { // load topic 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) { ErrResponse(w, http.StatusNotFound, err) } else { @@ -43,15 +43,15 @@ func SetChannelTopicTagSubject(w http.ResponseWriter, r *http.Request) { ErrResponse(w, http.StatusNotFound, errors.New("referenced empty tag")) 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")) 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")) return } - if tagSlot.Tag.Guid != guid { + if tagSlot.Tag.GUID != guid { ErrResponse(w, http.StatusUnauthorized, errors.New("not creator of tag")) return } @@ -92,11 +92,11 @@ func SetChannelTopicTagSubject(w http.ResponseWriter, r *http.Request) { // determine affected contact list cards := make(map[string]store.Card) for _, card := range channelSlot.Channel.Cards { - cards[card.Guid] = card + cards[card.GUID] = card } for _, group := range channelSlot.Channel.Groups { for _, card := range group.Cards { - cards[card.Guid] = card + cards[card.GUID] = card } } diff --git a/net/server/internal/api_setCloseMessage.go b/net/server/internal/api_setCloseMessage.go index b9d68862..eb379cc3 100644 --- a/net/server/internal/api_setCloseMessage.go +++ b/net/server/internal/api_setCloseMessage.go @@ -40,7 +40,7 @@ func SetCloseMessage(w http.ResponseWriter, r *http.Request) { // see if card exists 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) { ErrResponse(w, http.StatusInternalServerError, err) } else { diff --git a/net/server/internal/api_setGroupSubject.go b/net/server/internal/api_setGroupSubject.go index 7d862887..0831c22b 100644 --- a/net/server/internal/api_setGroupSubject.go +++ b/net/server/internal/api_setGroupSubject.go @@ -18,7 +18,7 @@ func SetGroupSubject(w http.ResponseWriter, r *http.Request) { // scan parameters params := mux.Vars(r) - groupId := params["groupId"] + groupID := params["groupID"] var subject Subject if err := ParseRequest(r, w, &subject); err != nil { @@ -28,7 +28,7 @@ func SetGroupSubject(w http.ResponseWriter, r *http.Request) { // load referenced group 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) { ErrResponse(w, http.StatusInternalServerError, err) } else { diff --git a/net/server/internal/api_setNodeAccount.go b/net/server/internal/api_setNodeAccount.go index 75b9c414..7e39953d 100644 --- a/net/server/internal/api_setNodeAccount.go +++ b/net/server/internal/api_setNodeAccount.go @@ -14,7 +14,7 @@ func SetNodeAccount(w http.ResponseWriter, r *http.Request) { // get referenced account id params := mux.Vars(r) - accountId, res := strconv.ParseUint(params["accountId"], 10, 32) + accountID, res := strconv.ParseUint(params["accountID"], 10, 32) if res != nil { ErrResponse(w, http.StatusBadRequest, res) return @@ -35,7 +35,7 @@ func SetNodeAccount(w http.ResponseWriter, r *http.Request) { accountToken := store.AccountToken{ TokenType: APP_TOKENRESET, Token: token, - AccountID: uint(accountId), + AccountID: uint(accountID), Expires: time.Now().Unix() + APP_CREATEEXPIRE, }; diff --git a/net/server/internal/api_setNodeAccountStatus.go b/net/server/internal/api_setNodeAccountStatus.go index b20cf2cd..e8186725 100644 --- a/net/server/internal/api_setNodeAccountStatus.go +++ b/net/server/internal/api_setNodeAccountStatus.go @@ -11,7 +11,7 @@ func SetNodeAccountStatus(w http.ResponseWriter, r *http.Request) { // get referenced account id params := mux.Vars(r) - accountId, res := strconv.ParseUint(params["accountId"], 10, 32) + accountID, res := strconv.ParseUint(params["accountID"], 10, 32) if res != nil { ErrResponse(w, http.StatusBadRequest, res) return @@ -28,7 +28,7 @@ func SetNodeAccountStatus(w http.ResponseWriter, r *http.Request) { 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) return } diff --git a/net/server/internal/api_setNodeConfig.go b/net/server/internal/api_setNodeConfig.go index 7e854aa1..aee3f910 100644 --- a/net/server/internal/api_setNodeConfig.go +++ b/net/server/internal/api_setNodeConfig.go @@ -29,7 +29,7 @@ func SetNodeConfig(w http.ResponseWriter, r *http.Request) { if res := tx.Clauses(clause.OnConflict{ Columns: []clause.Column{{Name: "config_id"}}, 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 } @@ -37,7 +37,7 @@ func SetNodeConfig(w http.ResponseWriter, r *http.Request) { if res := tx.Clauses(clause.OnConflict{ Columns: []clause.Column{{Name: "config_id"}}, 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 } @@ -45,7 +45,7 @@ func SetNodeConfig(w http.ResponseWriter, r *http.Request) { if res := tx.Clauses(clause.OnConflict{ Columns: []clause.Column{{Name: "config_id"}}, 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 } @@ -53,7 +53,7 @@ func SetNodeConfig(w http.ResponseWriter, r *http.Request) { if res := tx.Clauses(clause.OnConflict{ Columns: []clause.Column{{Name: "config_id"}}, 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 } diff --git a/net/server/internal/api_setNodeStatus.go b/net/server/internal/api_setNodeStatus.go index e99f8871..95ed2cd8 100644 --- a/net/server/internal/api_setNodeStatus.go +++ b/net/server/internal/api_setNodeStatus.go @@ -27,10 +27,10 @@ func SetNodeStatus(w http.ResponseWriter, r *http.Request) { } 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 } - 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 nil; diff --git a/net/server/internal/api_setOpenMessage.go b/net/server/internal/api_setOpenMessage.go index 12a2900d..80263ebf 100644 --- a/net/server/internal/api_setOpenMessage.go +++ b/net/server/internal/api_setOpenMessage.go @@ -44,7 +44,7 @@ func SetOpenMessage(w http.ResponseWriter, r *http.Request) { // see if card exists slot := &store.CardSlot{} 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) { ErrResponse(w, http.StatusInternalServerError, err) return @@ -56,7 +56,7 @@ func SetOpenMessage(w http.ResponseWriter, r *http.Request) { ErrResponse(w, http.StatusInternalServerError, res) return } - card.Guid = guid + card.GUID = guid card.Username = connect.Handle card.Name = connect.Name card.Description = connect.Description @@ -72,14 +72,14 @@ func SetOpenMessage(w http.ResponseWriter, r *http.Request) { card.NotifiedChannel = connect.ChannelRevision card.OutToken = connect.Token card.InToken = hex.EncodeToString(data) - card.AccountID = account.Guid + card.AccountID = account.GUID // create slot err = store.DB.Transaction(func(tx *gorm.DB) error { if res := tx.Save(card).Error; res != nil { return res } - slot.CardSlotId = uuid.New().String() + slot.CardSlotID = uuid.New().String() slot.AccountID = account.ID slot.Revision = account.CardRevision + 1 slot.CardID = card.ID diff --git a/net/server/internal/configUtil.go b/net/server/internal/configUtil.go index 6bb4dd8b..7241f244 100644 --- a/net/server/internal/configUtil.go +++ b/net/server/internal/configUtil.go @@ -15,36 +15,36 @@ const CONFIG_STORAGE = "storage" const CONFIG_ASSETPATH = "asset_path" const CONFIG_SCRIPTPATH = "script_path" -func getStrConfigValue(configId string, empty string) string { +func getStrConfigValue(configID string, empty string) string { 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) { return empty } return config.StrValue } -func getNumConfigValue(configId string, empty int64) int64 { +func getNumConfigValue(configID string, empty int64) int64 { 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) { return empty } return config.NumValue } -func getBoolConfigValue(configId string, empty bool) bool { +func getBoolConfigValue(configID string, empty bool) bool { 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) { return empty } return config.BoolValue } -func getBinConfigValue(configId string, empty []byte) []byte { +func getBinConfigValue(configID string, empty []byte) []byte { 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) { return empty } diff --git a/net/server/internal/garbageUtil.go b/net/server/internal/garbageUtil.go index 64a95037..a97ee9a2 100644 --- a/net/server/internal/garbageUtil.go +++ b/net/server/internal/garbageUtil.go @@ -13,7 +13,7 @@ func garbageCollect(act *store.Account) { defer garbageSync.Unlock() // 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) if err != nil { ErrMsg(err) @@ -35,13 +35,13 @@ func garbageCollect(act *store.Account) { // mark all referenced files for _, asset := range assets { - list[asset.AssetId] = true + list[asset.AssetID] = true } // delete any unreferenced file for id, set := range list { if !set { - LogMsg("removing file asset " + act.Guid + "/" + id) + LogMsg("removing file asset " + act.GUID + "/" + id) if err := os.Remove(dir + "/" + id); err != nil { ErrMsg(err) } diff --git a/net/server/internal/main_test.go b/net/server/internal/main_test.go index 2fdf560a..ed74ea7e 100644 --- a/net/server/internal/main_test.go +++ b/net/server/internal/main_test.go @@ -41,13 +41,13 @@ func TestMain(m *testing.M) { } // 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 { panic("failed to configure scripts 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 { panic("failed to configure data path") } diff --git a/net/server/internal/messageUtil.go b/net/server/internal/messageUtil.go index 7b00bfce..c9d8143d 100644 --- a/net/server/internal/messageUtil.go +++ b/net/server/internal/messageUtil.go @@ -72,7 +72,7 @@ func ReadDataMessage(msg *DataMessage, obj interface{}) (string, string, int64, } // validate signer - if signedData.Guid != guid { + if signedData.GUID != guid { return "", "", 0, errors.New("invalid message source") } @@ -99,7 +99,7 @@ func WriteDataMessage(privateKey string, publicKey string, keyType string, return nil, err } var signedData SignedData - signedData.Guid = guid + signedData.GUID = guid signedData.Timestamp = time.Now().Unix() signedData.MessageType = messageType signedData.Value = string(data) diff --git a/net/server/internal/modelUtil.go b/net/server/internal/modelUtil.go index baf54094..9bf1c52e 100644 --- a/net/server/internal/modelUtil.go +++ b/net/server/internal/modelUtil.go @@ -7,7 +7,7 @@ import ( func getProfileModel(account *store.Account) *Profile { return &Profile{ - Guid: account.Guid, + GUID: account.GUID, Handle: account.Username, Name: account.AccountDetail.Name, Description: account.AccountDetail.Description, @@ -23,13 +23,13 @@ func getCardModel(slot *store.CardSlot) *Card { if slot.Card == nil { return &Card{ - Id: slot.CardSlotId, + ID: slot.CardSlotID, Revision: slot.Revision, } } return &Card{ - Id: slot.CardSlotId, + ID: slot.CardSlotID, Revision: slot.Revision, Data: &CardData { NotifiedProfile: slot.Card.NotifiedProfile, @@ -48,13 +48,13 @@ func getCardRevisionModel(slot *store.CardSlot) *Card { if slot.Card == nil { return &Card{ - Id: slot.CardSlotId, + ID: slot.CardSlotID, Revision: slot.Revision, } } return &Card{ - Id: slot.CardSlotId, + ID: slot.CardSlotID, Revision: slot.Revision, Data: &CardData { NotifiedProfile: slot.Card.NotifiedProfile, @@ -71,7 +71,7 @@ func getCardDetailModel(slot *store.CardSlot) *CardDetail { var groups []string; for _, group := range slot.Card.Groups { - groups = append(groups, group.GroupSlot.GroupSlotId) + groups = append(groups, group.GroupSlot.GroupSlotID) } return &CardDetail{ @@ -85,7 +85,7 @@ func getCardDetailModel(slot *store.CardSlot) *CardDetail { func getCardProfileModel(slot *store.CardSlot) *CardProfile { return &CardProfile{ - Guid: slot.Card.Guid, + GUID: slot.Card.GUID, Handle: slot.Card.Username, Name: slot.Card.Name, Description: slot.Card.Description, @@ -99,13 +99,13 @@ func getCardProfileModel(slot *store.CardSlot) *CardProfile { func getGroupModel(slot *store.GroupSlot) *Group { if slot.Group == nil { return &Group{ - Id: slot.GroupSlotId, + ID: slot.GroupSlotID, Revision: slot.Revision, } } return &Group{ - Id: slot.GroupSlotId, + ID: slot.GroupSlotID, Revision: slot.Revision, Data: &GroupData { DataType: slot.Group.DataType, @@ -119,22 +119,22 @@ func getGroupModel(slot *store.GroupSlot) *Group { func getArticleModel(slot *store.ArticleSlot, showData bool, showList bool) *Article { if !showData || slot.Article == nil { return &Article{ - Id: slot.ArticleSlotId, + ID: slot.ArticleSlotID, Revision: slot.Revision, } } - var articleGroups *IdList + var articleGroups *IDList if showList { var groups []string; 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{ - Id: slot.ArticleSlotId, + ID: slot.ArticleSlotID, Revision: slot.Revision, Data: &ArticleData { DataType: slot.Article.DataType, @@ -150,13 +150,13 @@ func getChannelRevisionModel(slot *store.ChannelSlot, showData bool) *Channel { if !showData || slot.Channel == nil { return &Channel{ - Id: slot.ChannelSlotId, + ID: slot.ChannelSlotID, Revision: slot.Revision, } } return &Channel{ - Id: slot.ChannelSlotId, + ID: slot.ChannelSlotID, Revision: slot.Revision, Data: &ChannelData { DetailRevision: slot.Channel.DetailRevision, @@ -175,18 +175,18 @@ func getChannelDetailModel(slot *store.ChannelSlot, showList bool) *ChannelDetai if showList { var groups []string; for _, group := range slot.Channel.Groups { - groups = append(groups, group.GroupSlot.GroupSlotId) + groups = append(groups, group.GroupSlot.GroupSlotID) } var cards []string; for _, card := range slot.Channel.Cards { - cards = append(cards, card.CardSlot.CardSlotId) + cards = append(cards, card.CardSlot.CardSlotID) } contacts = &ChannelContacts{ Groups: groups, Cards: cards } } members := []string{} for _, card := range slot.Channel.Cards { - members = append(members, card.Guid) + members = append(members, card.GUID) } return &ChannelDetail{ @@ -207,7 +207,7 @@ func getChannelSummaryModel(slot *store.ChannelSlot) *ChannelSummary { topicDetail := TopicDetail{}; 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.Data = slot.Channel.Topics[0].Data; 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 { return &Channel{ - Id: slot.ChannelSlotId, + ID: slot.ChannelSlotID, Revision: slot.Revision, } } return &Channel{ - Id: slot.ChannelSlotId, + ID: slot.ChannelSlotID, Revision: slot.Revision, Data: &ChannelData { DetailRevision: slot.Channel.DetailRevision, @@ -245,13 +245,13 @@ func getTopicRevisionModel(slot *store.TopicSlot) *Topic { if slot.Topic == nil { return &Topic{ - Id: slot.TopicSlotId, + ID: slot.TopicSlotID, Revision: slot.Revision, } } return &Topic{ - Id: slot.TopicSlotId, + ID: slot.TopicSlotID, Revision: slot.Revision, Data: &TopicData { DetailRevision: slot.Topic.DetailRevision, @@ -276,7 +276,7 @@ func getTopicDetailModel(slot *store.TopicSlot) *TopicDetail { } return &TopicDetail{ - Guid: slot.Topic.Guid, + GUID: slot.Topic.GUID, DataType: slot.Topic.DataType, Data: slot.Topic.Data, Created: slot.Topic.Created, @@ -290,13 +290,13 @@ func getTopicModel(slot *store.TopicSlot) *Topic { if slot.Topic == nil { return &Topic{ - Id: slot.TopicSlotId, + ID: slot.TopicSlotID, Revision: slot.Revision, } } return &Topic{ - Id: slot.TopicSlotId, + ID: slot.TopicSlotID, Revision: slot.Revision, Data: &TopicData { DetailRevision: slot.Topic.DetailRevision, @@ -310,16 +310,16 @@ func getTagModel(slot *store.TagSlot) *Tag { if slot.Tag == nil { return &Tag{ - Id: slot.TagSlotId, + ID: slot.TagSlotID, Revision: slot.Revision, } } return &Tag{ - Id: slot.TagSlotId, + ID: slot.TagSlotID, Revision: slot.Revision, Data: &TagData{ - Guid: slot.Tag.Guid, + GUID: slot.Tag.GUID, DataType: slot.Tag.DataType, Data: slot.Tag.Data, Created: slot.Tag.Created, diff --git a/net/server/internal/models.go b/net/server/internal/models.go index e4e89e20..1ca6055e 100644 --- a/net/server/internal/models.go +++ b/net/server/internal/models.go @@ -2,9 +2,9 @@ package databag type AccountProfile struct { - AccountId uint32 `json:"accountId"` + AccountID uint32 `json:"accountID"` - Guid string `json:"guid"` + GUID string `json:"guid"` Handle string `json:"handle,omitempty"` @@ -39,7 +39,7 @@ type Announce struct { type App struct { - Id string `json:"id"` + ID string `json:"id"` Revision int64 `json:"revision"` @@ -61,7 +61,7 @@ type AppData struct { type Article struct { - Id string `json:"id"` + ID string `json:"id"` Revision int64 `json:"revision"` @@ -78,7 +78,7 @@ type ArticleData struct { Updated int64 `json:"updated"` - Groups *IdList `json:"groups,omitempty"` + Groups *IDList `json:"groups,omitempty"` } type ArticleGroups struct { @@ -88,7 +88,7 @@ type ArticleGroups struct { type Asset struct { - AssetId string `json:"assetId"` + AssetID string `json:"assetID"` Transform string `json:"transform,omitempty"` @@ -97,7 +97,7 @@ type Asset struct { type Card struct { - Id string `json:"id"` + ID string `json:"id"` Revision int64 `json:"revision"` @@ -136,7 +136,7 @@ type CardDetail struct { type CardProfile struct { - Guid string `json:"guid"` + GUID string `json:"guid"` Handle string `json:"handle,omitempty"` @@ -162,7 +162,7 @@ type ChannelContacts struct { type Channel struct { - Id string `json:"id"` + ID string `json:"id"` Revision int64 `json:"revision"` @@ -280,7 +280,7 @@ type Disconnect struct { type Group struct { - Id string `json:"id"` + ID string `json:"id"` Revision int64 `json:"revision"` @@ -317,9 +317,9 @@ type Identity struct { Node string `json:"node"` } -type IdList struct { +type IDList struct { - Ids []string `json:"ids"` + IDs []string `json:"ids"` } type LoginAccess struct { @@ -342,7 +342,7 @@ type NodeConfig struct { type Profile struct { - Guid string `json:"guid"` + GUID string `json:"guid"` Handle string `json:"handle,omitempty"` @@ -387,7 +387,7 @@ type Revision struct { type SignedData struct { - Guid string `json:"guid"` + GUID string `json:"guid"` Timestamp int64 `json:"timestamp"` @@ -405,7 +405,7 @@ type Subject struct { type Tag struct { - Id string `json:"id"` + ID string `json:"id"` Revision int64 `json:"revision"` @@ -414,7 +414,7 @@ type Tag struct { type TagData struct { - Guid string `json:"guid"` + GUID string `json:"guid"` DataType string `json:"dataType"` @@ -427,7 +427,7 @@ type TagData struct { type Topic struct { - Id string `json:"id"` + ID string `json:"id"` Revision int64 `json:"revision"` @@ -445,7 +445,7 @@ type TopicData struct { type TopicDetail struct { - Guid string `json:"guid"` + GUID string `json:"guid"` DataType string `json:"dataType"` diff --git a/net/server/internal/notify.go b/net/server/internal/notify.go index c9367b6d..70ffa0a7 100644 --- a/net/server/internal/notify.go +++ b/net/server/internal/notify.go @@ -101,7 +101,7 @@ func SendRemoteNotification(notification *store.Notification) { ErrMsg(err); 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)) if err != nil { ErrMsg(err) @@ -123,7 +123,7 @@ func SetProfileNotification(account *store.Account) { // select all connected cards 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) return } @@ -134,7 +134,7 @@ func SetProfileNotification(account *store.Account) { notification := &store.Notification{ Node: card.Node, Module: APP_NOTIFYPROFILE, - Guid: card.Guid, + GUID: card.GUID, Token: card.OutToken, Revision: account.ProfileRevision, } @@ -163,7 +163,7 @@ func SetContactArticleNotification(account *store.Account, card *store.Card) { notification := &store.Notification{ Node: card.Node, Module: APP_NOTIFYARTICLE, - Guid: card.Guid, + GUID: card.GUID, Token: card.OutToken, Revision: account.ArticleRevision, } @@ -188,7 +188,7 @@ func SetContactViewNotification(account *store.Account, card *store.Card) { notification := &store.Notification{ Node: card.Node, Module: APP_NOTIFYVIEW, - Guid: card.Guid, + GUID: card.GUID, Token: card.OutToken, Revision: card.ViewRevision, } @@ -212,7 +212,7 @@ func SetContactChannelNotification(account *store.Account, card *store.Card) { notification := &store.Notification{ Node: card.Node, Module: APP_NOTIFYCHANNEL, - Guid: card.Guid, + GUID: card.GUID, Token: card.OutToken, Revision: account.ChannelRevision, } diff --git a/net/server/internal/routers.go b/net/server/internal/routers.go index daa9e899..82229465 100644 --- a/net/server/internal/routers.go +++ b/net/server/internal/routers.go @@ -77,7 +77,7 @@ var routes = Routes{ Route{ "GetAccountAsset", strings.ToUpper("Get"), - "/account/assets/{assetId}", + "/account/assets/{assetID}", GetAccountAsset, }, @@ -140,7 +140,7 @@ var routes = Routes{ Route{ "RemoveAccountApp", strings.ToUpper("Delete"), - "/account/apps/{appId}", + "/account/apps/{appID}", RemoveAccountApp, }, @@ -196,21 +196,21 @@ var routes = Routes{ Route{ "GetNodeAccountImage", strings.ToUpper("Get"), - "/admin/accounts/{accountId}/image", + "/admin/accounts/{accountID}/image", GetNodeAccountImage, }, Route{ "SetNodeAccountStatus", strings.ToUpper("Put"), - "/admin/accounts/{accountId}/status", + "/admin/accounts/{accountID}/status", SetNodeAccountStatus, }, Route{ "AddNodeAccountAccess", strings.ToUpper("Post"), - "/admin/accounts/{accountId}/auth", + "/admin/accounts/{accountID}/auth", AddNodeAccountAccess, }, @@ -245,14 +245,14 @@ var routes = Routes{ Route{ "RemoveNodeAccount", strings.ToUpper("Delete"), - "/admin/accounts/{accountId}", + "/admin/accounts/{accountID}", RemoveNodeAccount, }, Route{ "SetNodeAccount", strings.ToUpper("Put"), - "/admin/accounts/{accountId}/reset", + "/admin/accounts/{accountID}/reset", SetNodeAccount, }, @@ -280,7 +280,7 @@ var routes = Routes{ Route{ "GetGroupSubjectField", strings.ToUpper("Get"), - "/alias/groups/{groupId}/subject/{field}", + "/alias/groups/{groupID}/subject/{field}", GetGroupSubjectField, }, @@ -294,14 +294,14 @@ var routes = Routes{ Route{ "RemoveGroup", strings.ToUpper("Delete"), - "/alias/groups/{groupId}", + "/alias/groups/{groupID}", RemoveGroup, }, Route{ "SetGroupSubject", strings.ToUpper("Put"), - "/alias/groups/{groupId}/subject", + "/alias/groups/{groupID}/subject", SetGroupSubject, }, @@ -315,14 +315,14 @@ var routes = Routes{ Route{ "ClearArticleGroup", strings.ToUpper("Delete"), - "/attribute/articles/{articleId}/groups/{groupId}", + "/attribute/articles/{articleID}/groups/{groupID}", ClearArticleGroup, }, Route{ "GetArticleSubjectField", strings.ToUpper("Get"), - "/attribute/articles/{articleId}/subject/{field}", + "/attribute/articles/{articleID}/subject/{field}", GetArticleSubjectField, }, @@ -336,21 +336,21 @@ var routes = Routes{ Route{ "RemoveArticle", strings.ToUpper("Delete"), - "/attribute/articles/{articleId}", + "/attribute/articles/{articleID}", RemoveArticle, }, Route{ "SetArticleGroup", strings.ToUpper("Put"), - "/attribute/articles/{articleId}/groups/{groupId}", + "/attribute/articles/{articleID}/groups/{groupID}", SetArticleGroup, }, Route{ "SetArticleSubject", strings.ToUpper("Put"), - "/attribute/articles/{articleId}/subject", + "/attribute/articles/{articleID}/subject", SetArticleSubject, }, @@ -371,35 +371,35 @@ var routes = Routes{ Route{ "ClearCardGroup", strings.ToUpper("Delete"), - "/contact/cards/{cardId}/groups/{groupId}", + "/contact/cards/{cardID}/groups/{groupID}", ClearCardGroup, }, Route{ "ClearCardNotes", strings.ToUpper("Delete"), - "/contact/cards/{cardId}/notes", + "/contact/cards/{cardID}/notes", ClearCardNotes, }, Route{ "GetCardDetail", strings.ToUpper("Get"), - "/contact/cards/{cardId}/detail", + "/contact/cards/{cardID}/detail", GetCardDetail, }, Route{ "GetCardProfile", strings.ToUpper("Get"), - "/contact/cards/{cardId}/profile", + "/contact/cards/{cardID}/profile", GetCardProfile, }, Route{ "GetCardProfileImage", strings.ToUpper("Get"), - "/contact/cards/{cardId}/profile/image", + "/contact/cards/{cardID}/profile/image", GetCardProfileImage, }, @@ -413,21 +413,21 @@ var routes = Routes{ Route{ "GetCloseMessage", strings.ToUpper("Get"), - "/contact/cards/{cardId}/closeMessage", + "/contact/cards/{cardID}/closeMessage", GetCloseMessage, }, Route{ "GetOpenMessage", strings.ToUpper("Get"), - "/contact/cards/{cardId}/openMessage", + "/contact/cards/{cardID}/openMessage", GetOpenMessage, }, Route{ "RemoveCard", strings.ToUpper("Delete"), - "/contact/cards/{cardId}", + "/contact/cards/{cardID}", RemoveCard, }, @@ -441,28 +441,28 @@ var routes = Routes{ Route{ "SetCardGroup", strings.ToUpper("Put"), - "/contact/cards/{cardId}/groups/{groupId}", + "/contact/cards/{cardID}/groups/{groupID}", SetCardGroup, }, Route{ "SetCardNotes", strings.ToUpper("Put"), - "/contact/cards/{cardId}/notes", + "/contact/cards/{cardID}/notes", SetCardNotes, }, Route{ "SetCardProfile", strings.ToUpper("Put"), - "/contact/cards/{cardId}/profile", + "/contact/cards/{cardID}/profile", SetCardProfile, }, Route{ "SetCardStatus", strings.ToUpper("Put"), - "/contact/cards/{cardId}/status", + "/contact/cards/{cardID}/status", SetCardStatus, }, @@ -511,112 +511,112 @@ var routes = Routes{ Route{ "AddChannelTopicAsset", strings.ToUpper("Post"), - "/content/channels/{channelId}/topics/{topicId}/assets", + "/content/channels/{channelID}/topics/{topicID}/assets", AddChannelTopicAsset, }, Route{ "AddChannelTopic", strings.ToUpper("Post"), - "/content/channels/{channelId}/topics", + "/content/channels/{channelID}/topics", AddChannelTopic, }, Route{ "AddChannelTopicTag", strings.ToUpper("Post"), - "/content/channels/{channelId}/topics/{topicId}/tags", + "/content/channels/{channelID}/topics/{topicID}/tags", AddChannelTopicTag, }, Route{ "ClearChannelCard", strings.ToUpper("Delete"), - "/content/channels/{channelId}/cards/{cardId}", + "/content/channels/{channelID}/cards/{cardID}", ClearChannelCard, }, Route{ "ClearChannelGroup", strings.ToUpper("Delete"), - "/content/channels/{channelId}/groups/{groupId}", + "/content/channels/{channelID}/groups/{groupID}", ClearChannelGroup, }, Route{ "GetChannelTopicAsset", strings.ToUpper("Get"), - "/content/channels/{channelId}/topics/{topicId}/assets/{assetId}", + "/content/channels/{channelID}/topics/{topicID}/assets/{assetID}", GetChannelTopicAsset, }, Route{ "GetChannelTopicAssets", strings.ToUpper("Get"), - "/content/channels/{channelId}/topics/{topicId}/assets", + "/content/channels/{channelID}/topics/{topicID}/assets", GetChannelTopicAssets, }, Route{ "GetChannelDetail", strings.ToUpper("Get"), - "/content/channels/{channelId}/detail", + "/content/channels/{channelID}/detail", GetChannelDetail, }, Route{ "GetChannelSummary", strings.ToUpper("Get"), - "/content/channels/{channelId}/summary", + "/content/channels/{channelID}/summary", GetChannelSummary, }, Route{ "GetChannelSubjectField", strings.ToUpper("Get"), - "/content/channels/{channelId}/subject/{field}", + "/content/channels/{channelID}/subject/{field}", GetChannelSubjectField, }, Route{ "GetChannelTopic", strings.ToUpper("Get"), - "/content/channels/{channelId}/topics/{topicId}/detail", + "/content/channels/{channelID}/topics/{topicID}/detail", GetChannelTopic, }, Route{ "GetChannelTopicDetail", strings.ToUpper("Get"), - "/content/channels/{channelId}/topics/{topicId}/detail", + "/content/channels/{channelID}/topics/{topicID}/detail", GetChannelTopicDetail, }, Route{ "GetChannelTopicSubjectField", strings.ToUpper("Get"), - "/content/channels/{channelId}/topics/{topicId}/subject/{field}", + "/content/channels/{channelID}/topics/{topicID}/subject/{field}", GetChannelTopicSubjectField, }, Route{ "GetChannelTopicTagSubjectField", strings.ToUpper("Get"), - "/content/channels/{channelId}/topics/{topicId}/tags/{tagId}/subject/{field}", + "/content/channels/{channelID}/topics/{topicID}/tags/{tagID}/subject/{field}", GetChannelTopicTagSubjectField, }, Route{ "GetChannelTopicTags", strings.ToUpper("Get"), - "/content/channels/{channelId}/topics/{topicId}/tags", + "/content/channels/{channelID}/topics/{topicID}/tags", GetChannelTopicTags, }, Route{ "GetChannelTopics", strings.ToUpper("Get"), - "/content/channels/{channelId}/topics", + "/content/channels/{channelID}/topics", GetChannelTopics, }, @@ -630,70 +630,70 @@ var routes = Routes{ Route{ "RemoveChannel", strings.ToUpper("Delete"), - "/content/channels/{channelId}", + "/content/channels/{channelID}", RemoveChannel, }, Route{ "RemoveChannelTopicAsset", strings.ToUpper("Delete"), - "/content/channels/{channelId}/topics/{topicId}/assets/{assetId}", + "/content/channels/{channelID}/topics/{topicID}/assets/{assetID}", RemoveChannelTopicAsset, }, Route{ "RemoveChannelTopic", strings.ToUpper("Delete"), - "/content/channels/{channelId}/topics/{topicId}", + "/content/channels/{channelID}/topics/{topicID}", RemoveChannelTopic, }, Route{ "RemoveChannelTopicTag", strings.ToUpper("Delete"), - "/content/channels/{channelId}/topics/{topicId}/tags/{tagId}", + "/content/channels/{channelID}/topics/{topicID}/tags/{tagID}", RemoveChannelTopicTag, }, Route{ "SetChannelCard", strings.ToUpper("Put"), - "/content/channels/{channelId}/cards/{cardId}", + "/content/channels/{channelID}/cards/{cardID}", SetChannelCard, }, Route{ "SetChannelTopicConfirmed", strings.ToUpper("Put"), - "/content/channels/{channelId}/topics/{topicId}/confirmed", + "/content/channels/{channelID}/topics/{topicID}/confirmed", SetChannelTopicConfirmed, }, Route{ "SetChannelGroup", strings.ToUpper("Put"), - "/content/channels/{channelId}/groups/{groupId}", + "/content/channels/{channelID}/groups/{groupID}", SetChannelGroup, }, Route{ "SetChannelSubject", strings.ToUpper("Put"), - "/content/channels/{channelId}/subject", + "/content/channels/{channelID}/subject", SetChannelSubject, }, Route{ "SetChannelTopicSubject", strings.ToUpper("Put"), - "/content/channels/{channelId}/topics/{topicId}/subject", + "/content/channels/{channelID}/topics/{topicID}/subject", SetChannelTopicSubject, }, Route{ "SetChannelTopicTagSubject", strings.ToUpper("Put"), - "/content/channels/{channelId}/topics/{topicId}/tags/{tagId}/subject", + "/content/channels/{channelID}/topics/{topicID}/tags/{tagID}/subject", SetChannelTopicTagSubject, }, diff --git a/net/server/internal/store/schema.go b/net/server/internal/store/schema.go index adff09d4..b493aac0 100644 --- a/net/server/internal/store/schema.go +++ b/net/server/internal/store/schema.go @@ -27,7 +27,7 @@ func AutoMigrate(db *gorm.DB) { type Notification struct { ID uint `gorm:"primaryKey;not null;unique;autoIncrement"` Node string `gorm:"not null"` - Guid string `gorm:"not null"` + GUID string `gorm:"not null"` Module string `gorm:"not null"` Token string `gorm:"not null"` Revision int64 `gorm:"not null"` @@ -35,7 +35,7 @@ type Notification struct { type Config struct { ID uint `gorm:"primaryKey;not null;unique;autoIncrement"` - ConfigId string `gorm:"not null;uniqueIndex"` + ConfigID string `gorm:"not null;uniqueIndex"` StrValue string NumValue int64 BoolValue bool @@ -55,7 +55,7 @@ type AccountToken struct { type Account struct { ID uint `gorm:"primaryKey;not null;unique;autoIncrement"` AccountDetailID uint `gorm:"not null"` - Guid string `gorm:"not null;uniqueIndex"` + GUID string `gorm:"not null;uniqueIndex"` Username string `gorm:"not null;uniqueIndex"` Handle string `gorm:"uniqueIndex"` Password []byte `gorm:"not null"` @@ -94,12 +94,12 @@ type App struct { Url string Token string `gorm:"not null;index:appguid,unique"` Created int64 `gorm:"autoCreateTime"` - Account Account `gorm:"references:Guid"` + Account Account `gorm:"references:GUID"` } type GroupSlot struct { 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"` Revision int64 `gorm:"not null"` GroupID uint `gorm:"not null;default:0"` @@ -129,7 +129,7 @@ type GroupData struct { type CardSlot struct { 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"` Revision int64 `gorm:"not null"` CardID uint `gorm:"not null;default:0"` @@ -140,7 +140,7 @@ type CardSlot struct { type Card struct { ID uint `gorm:"primaryKey;not null;unique;autoIncrement"` 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 Name string Description string @@ -161,7 +161,7 @@ type Card struct { NotifiedArticle int64 NotifiedChannel int64 NotifiedProfile int64 - Account Account `gorm:"references:Guid"` + Account Account `gorm:"references:GUID"` Groups []Group `gorm:"many2many:card_groups"` Channels []Channel `gorm:"many2many:channel_cards"` CardSlot CardSlot @@ -169,7 +169,7 @@ type Card struct { type ArticleSlot struct { 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"` Revision int64 `gorm:"not null"` ArticleID uint `gorm:"not null;default:0"` @@ -190,7 +190,7 @@ type Article struct { type ChannelSlot struct { 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"` Revision int64 `gorm:"not null"` ChannelID uint `gorm:"not null;default:0"` @@ -215,7 +215,7 @@ type Channel struct { type TopicSlot struct { 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"` ChannelID uint `gorm:"not null;index:topicchannel,unique"` Revision int64 `gorm:"not null"` @@ -230,7 +230,7 @@ type Topic struct { AccountID uint ChannelID uint TopicSlotID uint `gorm:"not null;index:topictopicslot,unique"` - Guid string + GUID string DataType string `gorm:"index"` Data string Status string `gorm:"not null;index"` @@ -246,7 +246,7 @@ type Topic struct { type Asset struct { 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"` ChannelID uint TopicID uint @@ -254,7 +254,7 @@ type Asset struct { Size int64 Crc uint32 Transform string - TransformId string + TransformID string TransformParams string TransformQueue string Created int64 `gorm:"autoCreateTime"` @@ -266,7 +266,7 @@ type Asset struct { type TagSlot struct { 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"` ChannelID uint `gorm:"not null"` TopicID uint `gorm:"not null;index:tagtopic"` @@ -283,7 +283,7 @@ type Tag struct { AccountID uint ChannelID uint `gorm:"not null;index:channeltag"` TopicID uint `gorm:"not null;index:topictag"` - Guid string `gorm:"not null"` + GUID string `gorm:"not null"` DataType string `gorm:"index"` Data string Created int64 `gorm:"autoCreateTime"` diff --git a/net/server/internal/testApp.go b/net/server/internal/testApp.go index f5fd9dc0..fb750a9c 100644 --- a/net/server/internal/testApp.go +++ b/net/server/internal/testApp.go @@ -108,16 +108,16 @@ func (c *TestContactData) UpdateContact() (err error) { func (c *TestContactData) UpdateContactProfile() (err error) { var msg DataMessage - token := c.card.Data.CardProfile.Guid + "." + c.card.Data.CardDetail.Token - params := &TestApiParams{ query: "/profile/message", tokenType: APP_TOKENCONTACT, token: token } - response := &TestApiResponse{ data: &msg } - if err = TestApiRequest(GetProfileMessage, params, response); err != nil { + token := c.card.Data.CardProfile.GUID + "." + c.card.Data.CardDetail.Token + params := &TestAPIParams{ query: "/profile/message", tokenType: APP_TOKENCONTACT, token: token } + response := &TestAPIResponse{ data: &msg } + if err = TestAPIRequest(GetProfileMessage, params, response); err != nil { return } - 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 } - response = &TestApiResponse{} - if err = TestApiRequest(SetCardProfile, params, response); err != nil { + 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 } + response = &TestAPIResponse{} + if err = TestAPIRequest(SetCardProfile, params, response); err != nil { return } return @@ -126,29 +126,29 @@ func (c *TestContactData) UpdateContactProfile() (err error) { func (c *TestContactData) UpdateContactArticle() (err error) { var articles []Article if c.articleRevision == 0 || c.viewRevision != c.card.Data.NotifiedView { - token := c.card.Data.CardProfile.Guid + "." + c.card.Data.CardDetail.Token - params := &TestApiParams{ query: "/articles", tokenType: APP_TOKENCONTACT, token: token } - response := &TestApiResponse{ data: &articles } - if err = TestApiRequest(GetArticles, params, response); err != nil { + token := c.card.Data.CardProfile.GUID + "." + c.card.Data.CardDetail.Token + params := &TestAPIParams{ query: "/articles", tokenType: APP_TOKENCONTACT, token: token } + response := &TestAPIResponse{ data: &articles } + if err = TestAPIRequest(GetArticles, params, response); err != nil { return } c.articles = make(map[string]*Article) } 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) 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 } - response := &TestApiResponse{ data: &articles } - if err = TestApiRequest(GetArticles, params, response); err != nil { + response := &TestAPIResponse{ data: &articles } + if err = TestAPIRequest(GetArticles, params, response); err != nil { return } } for _, article := range articles { if article.Data == nil { - delete(c.articles, article.Id) + delete(c.articles, article.ID) } else { - c.articles[article.Id] = &article + c.articles[article.ID] = &article } } return nil @@ -157,29 +157,29 @@ func (c *TestContactData) UpdateContactArticle() (err error) { func (c *TestContactData) UpdateContactChannels() (err error) { var channels []Channel if c.channelRevision == 0 || c.viewRevision != c.card.Data.NotifiedView { - token := c.card.Data.CardProfile.Guid + "." + c.card.Data.CardDetail.Token - params := &TestApiParams{ query: "/channels", tokenType: APP_TOKENCONTACT, token: token } - response := &TestApiResponse{ data: &channels } - if err = TestApiRequest(GetChannels, params, response); err != nil { + token := c.card.Data.CardProfile.GUID + "." + c.card.Data.CardDetail.Token + params := &TestAPIParams{ query: "/channels", tokenType: APP_TOKENCONTACT, token: token } + response := &TestAPIResponse{ data: &channels } + if err = TestAPIRequest(GetChannels, params, response); err != nil { return } } 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) 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 } - response := &TestApiResponse{ data: &channels } - if err = TestApiRequest(GetChannels, params, response); err != nil { + response := &TestAPIResponse{ data: &channels } + if err = TestAPIRequest(GetChannels, params, response); err != nil { return } } for _, channel := range channels { if channel.Data == nil { - delete(c.channels, channel.Id) + delete(c.channels, channel.ID) } else { - tc, set := c.channels[channel.Id] + tc, set := c.channels[channel.ID] if set { if channel.Revision != tc.channel.Revision { if err = c.UpdateContactChannel(tc, &channel); err != nil { @@ -188,8 +188,8 @@ func (c *TestContactData) UpdateContactChannels() (err error) { tc.channel.Revision = channel.Revision } } else { - tc := &TestChannel{ channel: Channel{ Id: channel.Id, Data: &ChannelData{} } } - c.channels[channel.Id] = tc + tc := &TestChannel{ channel: Channel{ ID: channel.ID, Data: &ChannelData{} } } + c.channels[channel.ID] = tc if err = c.UpdateContactChannel(tc, &channel); err != nil { return } @@ -212,12 +212,12 @@ func (c *TestContactData) UpdateContactChannel(storeChannel *TestChannel, channe storeChannel.channel.Data.ChannelDetail = channel.Data.ChannelDetail 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 - params := &TestApiParams{ query: "/channel/{channelId}", path: map[string]string{ "channelId": channel.Id }, + token := c.card.Data.CardProfile.GUID + "." + c.card.Data.CardDetail.Token + params := &TestAPIParams{ query: "/channel/{channelID}", path: map[string]string{ "channelID": channel.ID }, tokenType: APP_TOKENCONTACT, token: token } detail := &ChannelDetail{} - response := &TestApiResponse{ data: &detail } - if err = TestApiRequest(GetChannelDetail, params, response); err != nil { + response := &TestAPIResponse{ data: &detail } + if err = TestAPIRequest(GetChannelDetail, params, response); err != nil { return } if channel.Data == nil { @@ -234,30 +234,30 @@ func (c *TestContactData) UpdateContactChannel(storeChannel *TestChannel, channe func (c *TestContactData) UpdateContactChannelTopics(storeChannel *TestChannel) (err error) { var topics []Topic if storeChannel.channel.Revision == 0 { - token := c.card.Data.CardProfile.Guid + "." + c.card.Data.CardDetail.Token - params := &TestApiParams{ query: "/channels/{channelId}/topics", - path: map[string]string{ "channelId": storeChannel.channel.Id }, tokenType: APP_TOKENCONTACT, token: token } - response := &TestApiResponse{ data: &topics } - if err = TestApiRequest(GetChannelTopics, params, response); err != nil { + token := c.card.Data.CardProfile.GUID + "." + c.card.Data.CardDetail.Token + params := &TestAPIParams{ query: "/channels/{channelID}/topics", + path: map[string]string{ "channelID": storeChannel.channel.ID }, tokenType: APP_TOKENCONTACT, token: token } + response := &TestAPIResponse{ data: &topics } + if err = TestAPIRequest(GetChannelTopics, params, response); err != nil { return } storeChannel.topics = make(map[string]*TestTopic) } 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) - params := &TestApiParams{ query: "/channels/{channelId}/topics?revision=" + revision, - path: map[string]string{ "channelId": storeChannel.channel.Id }, tokenType: APP_TOKENCONTACT, token: token } - response := &TestApiResponse{ data: &topics } - if err = TestApiRequest(GetChannelTopics, params, response); err != nil { + params := &TestAPIParams{ query: "/channels/{channelID}/topics?revision=" + revision, + path: map[string]string{ "channelID": storeChannel.channel.ID }, tokenType: APP_TOKENCONTACT, token: token } + response := &TestAPIResponse{ data: &topics } + if err = TestAPIRequest(GetChannelTopics, params, response); err != nil { return } } for _, topic := range topics { if topic.Data == nil { - delete(storeChannel.topics, topic.Id) + delete(storeChannel.topics, topic.ID) } else { - storeTopic, set := storeChannel.topics[topic.Id] + storeTopic, set := storeChannel.topics[topic.ID] if set { if topic.Revision != storeTopic.topic.Revision { if err = c.UpdateContactChannelTopic(storeChannel, storeTopic, &topic); err != nil { @@ -266,8 +266,8 @@ func (c *TestContactData) UpdateContactChannelTopics(storeChannel *TestChannel) storeTopic.topic.Revision = topic.Revision } } else { - storeTopic := &TestTopic{ topic: Topic{ Id: topic.Id, Data: &TopicData{} } } - storeChannel.topics[topic.Id] = storeTopic + storeTopic := &TestTopic{ topic: Topic{ ID: topic.ID, Data: &TopicData{} } } + storeChannel.topics[topic.ID] = storeTopic if err = c.UpdateContactChannelTopic(storeChannel, storeTopic, &topic); err != nil { return } @@ -290,13 +290,13 @@ func (c *TestContactData) UpdateContactChannelTopic(storeChannel *TestChannel, s storeTopic.topic.Data.TopicDetail = topic.Data.TopicDetail 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 - params := &TestApiParams{ query: "/channels/{channelId}/topics/{topicId}", - path: map[string]string{ "channelId": storeChannel.channel.Id, "topicId": topic.Id }, + token := c.card.Data.CardProfile.GUID + "." + c.card.Data.CardDetail.Token + params := &TestAPIParams{ query: "/channels/{channelID}/topics/{topicID}", + path: map[string]string{ "channelID": storeChannel.channel.ID, "topicID": topic.ID }, tokenType: APP_TOKENCONTACT, token: token } topic := Topic{} - response := &TestApiResponse{ data: &topic } - if err = TestApiRequest(GetChannelTopic, params, response); err != nil { + response := &TestAPIResponse{ data: &topic } + if err = TestAPIRequest(GetChannelTopic, params, response); err != nil { return } 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) { var tags []Tag if storeTopic.topic.Revision == 0 { - token := c.card.Data.CardProfile.Guid + "." + c.card.Data.CardDetail.Token - params := &TestApiParams{ query: "/channels/{channelId}/topics/{topicId}/tags", - path: map[string]string{ "channelId": storeChannel.channel.Id, "topicId": storeTopic.topic.Id }, + token := c.card.Data.CardProfile.GUID + "." + c.card.Data.CardDetail.Token + params := &TestAPIParams{ query: "/channels/{channelID}/topics/{topicID}/tags", + path: map[string]string{ "channelID": storeChannel.channel.ID, "topicID": storeTopic.topic.ID }, tokenType: APP_TOKENCONTACT, token: token } - response := &TestApiResponse{ data: &tags } - if err = TestApiRequest(GetChannelTopicTags, params, response); err != nil { + response := &TestAPIResponse{ data: &tags } + if err = TestAPIRequest(GetChannelTopicTags, params, response); err != nil { return } storeTopic.tags = make(map[string]*Tag) } else { revision := strconv.FormatInt(storeTopic.topic.Revision, 10) - token := c.card.Data.CardProfile.Guid + "." + c.card.Data.CardDetail.Token - params := &TestApiParams{ query: "/channels/{channelId}/topics/{topicId}/tags?revision=" + revision, - path: map[string]string{ "channelId": storeChannel.channel.Id, "topicId": storeTopic.topic.Id }, + token := c.card.Data.CardProfile.GUID + "." + c.card.Data.CardDetail.Token + params := &TestAPIParams{ query: "/channels/{channelID}/topics/{topicID}/tags?revision=" + revision, + path: map[string]string{ "channelID": storeChannel.channel.ID, "topicID": storeTopic.topic.ID }, tokenType: APP_TOKENCONTACT, token: token } - response := &TestApiResponse{ data: &tags } - if err = TestApiRequest(GetChannelTopicTags, params, response); err != nil { + response := &TestAPIResponse{ data: &tags } + if err = TestAPIRequest(GetChannelTopicTags, params, response); err != nil { return } } for _, tag := range tags { if tag.Data == nil { - delete(storeTopic.tags, tag.Id) + delete(storeTopic.tags, tag.ID) } else { - storeTopic.tags[tag.Id] = &tag + storeTopic.tags[tag.ID] = &tag } } return @@ -346,10 +346,10 @@ func (c *TestContactData) UpdateContactChannelTopicTags(storeChannel *TestChanne func (c *TestContactData) UpdateContactCardDetail() (err error) { var cardDetail CardDetail - params := &TestApiParams{ query: "/contact/cards/{cardId}/detail", tokenType: APP_TOKENAGENT, token: c.token, - path: map[string]string{ "cardId": c.card.Id } } - response := &TestApiResponse{ data: &cardDetail } - if err = TestApiRequest(GetCardDetail, params, response); err != nil { + params := &TestAPIParams{ query: "/contact/cards/{cardID}/detail", tokenType: APP_TOKENAGENT, token: c.token, + path: map[string]string{ "cardID": c.card.ID } } + response := &TestAPIResponse{ data: &cardDetail } + if err = TestAPIRequest(GetCardDetail, params, response); err != nil { return } c.card.Data.CardDetail = &cardDetail @@ -358,10 +358,10 @@ func (c *TestContactData) UpdateContactCardDetail() (err error) { func (c *TestContactData) UpdateContactCardProfile() (err error) { var cardProfile CardProfile - params := &TestApiParams{ query: "/contact/cards/{cardId}/profile", tokenType: APP_TOKENAGENT, token: c.token, - path: map[string]string{ "cardId": c.card.Id } } - response := &TestApiResponse{ data: &cardProfile } - if err = TestApiRequest(GetCardProfile, params, response); err != nil { + params := &TestAPIParams{ query: "/contact/cards/{cardID}/profile", tokenType: APP_TOKENAGENT, token: c.token, + path: map[string]string{ "cardID": c.card.ID } } + response := &TestAPIResponse{ data: &cardProfile } + if err = TestAPIRequest(GetCardProfile, params, response); err != nil { return } c.card.Data.CardProfile = &cardProfile @@ -393,33 +393,33 @@ type TestApp struct { } func (a *TestApp) UpdateProfile() (err error) { - params := &TestApiParams{ query: "/profile", tokenType: APP_TOKENAGENT, token: a.token } - response := &TestApiResponse{ data: &a.profile } - err = TestApiRequest(GetProfile, params, response) + params := &TestAPIParams{ query: "/profile", tokenType: APP_TOKENAGENT, token: a.token } + response := &TestAPIResponse{ data: &a.profile } + err = TestAPIRequest(GetProfile, params, response) return } func (a *TestApp) UpdateGroups() (err error) { var groups []Group if a.revision.Group == 0 { - params := &TestApiParams{ query: "/groups", tokenType: APP_TOKENAGENT, token: a.token } - response := &TestApiResponse{ data: &groups } - if err = TestApiRequest(GetGroups, params, response); err != nil { + params := &TestAPIParams{ query: "/groups", tokenType: APP_TOKENAGENT, token: a.token } + response := &TestAPIResponse{ data: &groups } + if err = TestAPIRequest(GetGroups, params, response); err != nil { return } } else { revision := strconv.FormatInt(a.revision.Group, 10) - params := &TestApiParams{ query: "/groups?revision=" + revision, tokenType: APP_TOKENAGENT, token: a.token } - response := &TestApiResponse{ data: &groups } - if err = TestApiRequest(GetGroups, params, response); err != nil { + params := &TestAPIParams{ query: "/groups?revision=" + revision, tokenType: APP_TOKENAGENT, token: a.token } + response := &TestAPIResponse{ data: &groups } + if err = TestAPIRequest(GetGroups, params, response); err != nil { return } } for _, group := range groups { if group.Data == nil { - delete(a.groups, group.Id) + delete(a.groups, group.ID) } else { - a.groups[group.Id] = &group + a.groups[group.ID] = &group } } return @@ -428,24 +428,24 @@ func (a *TestApp) UpdateGroups() (err error) { func (a *TestApp) UpdateArticles() (err error) { var articles []Article if a.revision.Article == 0 { - params := &TestApiParams{ query: "/articles", tokenType: APP_TOKENAGENT, token: a.token } - response := &TestApiResponse{ data: &articles } - if err = TestApiRequest(GetArticles, params, response); err != nil { + params := &TestAPIParams{ query: "/articles", tokenType: APP_TOKENAGENT, token: a.token } + response := &TestAPIResponse{ data: &articles } + if err = TestAPIRequest(GetArticles, params, response); err != nil { return } } else { revision := strconv.FormatInt(a.revision.Article, 10) - params := &TestApiParams{ query: "/articles?articleRevision=" + revision, tokenType: APP_TOKENAGENT, token: a.token } - response := &TestApiResponse{ data: &articles } - if err = TestApiRequest(GetArticles, params, response); err != nil { + params := &TestAPIParams{ query: "/articles?articleRevision=" + revision, tokenType: APP_TOKENAGENT, token: a.token } + response := &TestAPIResponse{ data: &articles } + if err = TestAPIRequest(GetArticles, params, response); err != nil { return } } for _, article := range articles { if article.Data == nil { - delete(a.articles, article.Id) + delete(a.articles, article.ID) } else { - a.articles[article.Id] = &article + a.articles[article.ID] = &article } } return @@ -454,25 +454,25 @@ func (a *TestApp) UpdateArticles() (err error) { func (a *TestApp) UpdateChannels() (err error) { var channels []Channel if a.revision.Channel == 0 { - params := &TestApiParams{ query: "/channels", tokenType: APP_TOKENAGENT, token: a.token } - response := &TestApiResponse{ data: &channels } - if err = TestApiRequest(GetChannels, params, response); err != nil { + params := &TestAPIParams{ query: "/channels", tokenType: APP_TOKENAGENT, token: a.token } + response := &TestAPIResponse{ data: &channels } + if err = TestAPIRequest(GetChannels, params, response); err != nil { return } } else { revision := strconv.FormatInt(a.revision.Channel, 10) - params := &TestApiParams{ query: "/channels?channelRevision=" + revision, tokenType: APP_TOKENAGENT, token: a.token } - response := &TestApiResponse{ data: &channels } - if err = TestApiRequest(GetChannels, params, response); err != nil { + params := &TestAPIParams{ query: "/channels?channelRevision=" + revision, tokenType: APP_TOKENAGENT, token: a.token } + response := &TestAPIResponse{ data: &channels } + if err = TestAPIRequest(GetChannels, params, response); err != nil { return } } for _, channel := range channels { if channel.Data == nil { - delete(a.channels, channel.Id) + delete(a.channels, channel.ID) } else { - storeChannel, set := a.channels[channel.Id] + storeChannel, set := a.channels[channel.ID] if set { if channel.Revision != storeChannel.channel.Revision { if err = a.UpdateChannel(storeChannel, &channel); err != nil { @@ -481,8 +481,8 @@ func (a *TestApp) UpdateChannels() (err error) { storeChannel.channel.Revision = channel.Revision } } else { - storeChannel := &TestChannel{ channel: Channel{ Id: channel.Id, Data: &ChannelData{} } } - a.channels[channel.Id] = storeChannel + storeChannel := &TestChannel{ channel: Channel{ ID: channel.ID, Data: &ChannelData{} } } + a.channels[channel.ID] = storeChannel if err = a.UpdateChannel(storeChannel, &channel); err != nil { return } @@ -505,11 +505,11 @@ func (a *TestApp) UpdateChannel(storeChannel *TestChannel, channel *Channel) (er storeChannel.channel.Data.ChannelDetail = channel.Data.ChannelDetail 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 } detail := &ChannelDetail{} - response := &TestApiResponse{ data: &detail } - if err = TestApiRequest(GetChannelDetail, params, response); err != nil { + response := &TestAPIResponse{ data: &detail } + if err = TestAPIRequest(GetChannelDetail, params, response); err != nil { return } 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) { var topics []Topic if storeChannel.channel.Revision == 0 { - params := &TestApiParams{ query: "/channels/{channelId}/topics", - path: map[string]string{ "channelId": storeChannel.channel.Id }, tokenType: APP_TOKENAGENT, token: a.token } - response := &TestApiResponse{ data: &topics } - if err = TestApiRequest(GetChannelTopics, params, response); err != nil { + params := &TestAPIParams{ query: "/channels/{channelID}/topics", + path: map[string]string{ "channelID": storeChannel.channel.ID }, tokenType: APP_TOKENAGENT, token: a.token } + response := &TestAPIResponse{ data: &topics } + if err = TestAPIRequest(GetChannelTopics, params, response); err != nil { return } storeChannel.topics = make(map[string]*TestTopic) } else { revision := strconv.FormatInt(storeChannel.channel.Revision, 10) - params := &TestApiParams{ query: "/channels/{channelId}/topics?revision=" + revision, - path: map[string]string{ "channelId": storeChannel.channel.Id }, tokenType: APP_TOKENAGENT, token: a.token } - response := &TestApiResponse{ data: &topics } - if err = TestApiRequest(GetChannelTopics, params, response); err != nil { + params := &TestAPIParams{ query: "/channels/{channelID}/topics?revision=" + revision, + path: map[string]string{ "channelID": storeChannel.channel.ID }, tokenType: APP_TOKENAGENT, token: a.token } + response := &TestAPIResponse{ data: &topics } + if err = TestAPIRequest(GetChannelTopics, params, response); err != nil { return } } for _, topic := range topics { if topic.Data == nil { - delete(storeChannel.topics, topic.Id) + delete(storeChannel.topics, topic.ID) } else { - storeTopic, set := storeChannel.topics[topic.Id] + storeTopic, set := storeChannel.topics[topic.ID] if set { if topic.Revision != storeTopic.topic.Revision { 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 } } else { - storeTopic := &TestTopic{ topic: Topic{ Id: topic.Id, Data: &TopicData{} } } - storeChannel.topics[topic.Id] = storeTopic + storeTopic := &TestTopic{ topic: Topic{ ID: topic.ID, Data: &TopicData{} } } + storeChannel.topics[topic.ID] = storeTopic if err = a.UpdateChannelTopic(storeChannel, storeTopic, &topic); err != nil { return } @@ -580,12 +580,12 @@ func (a *TestApp) UpdateChannelTopic(storeChannel *TestChannel, storeTopic *Test storeTopic.topic.Data.TopicDetail = topic.Data.TopicDetail storeTopic.topic.Data.DetailRevision = topic.Data.DetailRevision } else if storeTopic.topic.Data.DetailRevision != topic.Data.DetailRevision { - params := &TestApiParams{ query: "/channels/{channelId}/topics/{topicId}", - path: map[string]string{ "channelId": storeChannel.channel.Id, "topicId": topic.Id }, + params := &TestAPIParams{ query: "/channels/{channelID}/topics/{topicID}", + path: map[string]string{ "channelID": storeChannel.channel.ID, "topicID": topic.ID }, tokenType: APP_TOKENAGENT, token: a.token } topic := Topic{} - response := &TestApiResponse{ data: &topic } - if err = TestApiRequest(GetChannelTopic, params, response); err != nil { + response := &TestAPIResponse{ data: &topic } + if err = TestAPIRequest(GetChannelTopic, params, response); err != nil { return } 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) { var tags []Tag if storeTopic.topic.Revision == 0 { - params := &TestApiParams{ query: "/channels/{channelId}/topics/{topicId}/tags", - path: map[string]string{ "channelId": storeChannel.channel.Id, "topicId": storeTopic.topic.Id }, + params := &TestAPIParams{ query: "/channels/{channelID}/topics/{topicID}/tags", + path: map[string]string{ "channelID": storeChannel.channel.ID, "topicID": storeTopic.topic.ID }, tokenType: APP_TOKENAGENT, token: a.token } - response := &TestApiResponse{ data: &tags } - if err = TestApiRequest(GetChannelTopicTags, params, response); err != nil { + response := &TestAPIResponse{ data: &tags } + if err = TestAPIRequest(GetChannelTopicTags, params, response); err != nil { return } storeTopic.tags = make(map[string]*Tag) } else { revision := strconv.FormatInt(storeTopic.topic.Revision, 10) - params := &TestApiParams{ query: "/channels/{channelId}/topics/{topicId}/tags?revision=" + revision, - path: map[string]string{ "channelId": storeChannel.channel.Id, "topicId": storeTopic.topic.Id }, + params := &TestAPIParams{ query: "/channels/{channelID}/topics/{topicID}/tags?revision=" + revision, + path: map[string]string{ "channelID": storeChannel.channel.ID, "topicID": storeTopic.topic.ID }, tokenType: APP_TOKENAGENT, token: a.token } - response := &TestApiResponse{ data: &tags } - if err = TestApiRequest(GetChannelTopicTags, params, response); err != nil { + response := &TestAPIResponse{ data: &tags } + if err = TestAPIRequest(GetChannelTopicTags, params, response); err != nil { return } } for _, tag := range tags { if tag.Data == nil { - delete(storeTopic.tags, tag.Id) + delete(storeTopic.tags, tag.ID) } else { - storeTopic.tags[tag.Id] = &tag + storeTopic.tags[tag.ID] = &tag } } return @@ -634,20 +634,20 @@ func (a *TestApp) UpdateChannelTopicTags(storeChannel *TestChannel, storeTopic * func (a *TestApp) UpdateCards() (err error) { var cards []Card if a.revision.Card == 0 { - params := &TestApiParams{ query: "/cards", tokenType: APP_TOKENAGENT, token: a.token } - response := &TestApiResponse{ data: &cards } - if err = TestApiRequest(GetCards, params, response); err != nil { + params := &TestAPIParams{ query: "/cards", tokenType: APP_TOKENAGENT, token: a.token } + response := &TestAPIResponse{ data: &cards } + if err = TestAPIRequest(GetCards, params, response); err != nil { return } for _, card := range cards { if card.Data == nil { - delete(a.contacts, card.Id) + delete(a.contacts, card.ID) } else { // set new card contactData := &TestContactData{ card: card, articles: make(map[string]*Article), channels: make(map[string]*TestChannel), cardDetailRevision: card.Data.DetailRevision, cardProfileRevision: card.Data.ProfileRevision, profileRevision: card.Data.ProfileRevision, token: a.token } - a.contacts[card.Id] = contactData + a.contacts[card.ID] = contactData if err = contactData.UpdateContact(); err != nil { contactData.offsync = true PrintMsg(err) @@ -656,28 +656,28 @@ func (a *TestApp) UpdateCards() (err error) { } } else { revision := strconv.FormatInt(a.revision.Card, 10) - params := &TestApiParams{ query: "/cards?revision=" + revision, tokenType: APP_TOKENAGENT, token: a.token } - response := &TestApiResponse{ data: &cards } - if err = TestApiRequest(GetCards, params, response); err != nil { + params := &TestAPIParams{ query: "/cards?revision=" + revision, tokenType: APP_TOKENAGENT, token: a.token } + response := &TestAPIResponse{ data: &cards } + if err = TestAPIRequest(GetCards, params, response); err != nil { return } for _, card := range cards { if card.Data == nil { - delete(a.contacts, card.Id) + delete(a.contacts, card.ID) } else { - contactData, set := a.contacts[card.Id] + contactData, set := a.contacts[card.ID] if !set { // 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 } - response := &TestApiResponse{ data: &card } - if err = TestApiRequest(GetCard, params, response); err != nil { + response := &TestAPIResponse{ data: &card } + if err = TestAPIRequest(GetCard, params, response); err != nil { return } contactData := &TestContactData{ card: card, articles: make(map[string]*Article), channels: make(map[string]*TestChannel), cardDetailRevision: card.Data.DetailRevision, cardProfileRevision: card.Data.ProfileRevision, profileRevision: card.Data.ProfileRevision, token: a.token } - a.contacts[card.Id] = contactData + a.contacts[card.ID] = contactData if err = contactData.UpdateContact(); err != nil { contactData.offsync = true PrintMsg(err) @@ -825,7 +825,7 @@ func (a *TestApp) WaitFor(check func(*TestApp) bool) error { /*** endpoint test function ***/ -type TestApiParams struct { +type TestAPIParams struct { restType string path map[string]string query string @@ -836,13 +836,13 @@ type TestApiParams struct { credentials string } -type TestApiResponse struct { +type TestAPIResponse struct { code int data interface{} 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 w *httptest.ResponseRecorder diff --git a/net/server/internal/testUtil.go b/net/server/internal/testUtil.go index 4259e401..bab7a2b3 100644 --- a/net/server/internal/testUtil.go +++ b/net/server/internal/testUtil.go @@ -20,14 +20,14 @@ const test_ReadDeadline = 2 const test_RevisionWait = 100 type TestCard struct { - Guid string + GUID string Token string - CardId string - GroupId string + CardID string + GroupID string } type TestContact struct { - Guid string + GUID string Token string Revisions chan *Revision A TestCard @@ -55,7 +55,7 @@ func GetTestRevision(status chan *Revision) (rev *Revision) { } } -func ApiTestData( +func APITestData( endpoint func(http.ResponseWriter, *http.Request), requestType string, name string, @@ -112,7 +112,7 @@ func ApiTestData( return } -func ApiTestMsg( +func APITestMsg( endpoint func(http.ResponseWriter, *http.Request), requestType string, name string, @@ -173,7 +173,7 @@ func ApiTestMsg( return } -func ApiTestUpload( +func APITestUpload( endpoint func(http.ResponseWriter, *http.Request), requestType string, name string, @@ -260,110 +260,110 @@ func AddTestGroup(prefix string) (*TestGroup, error) { // allocate contacts 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 } - 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 } - 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 } - 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 } // 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 } - 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 } - 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 } - 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 } - 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 } - 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 } - 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 } - 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 } // 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 } - 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 } - 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 } - 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 } - 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 } // 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 } - 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 } - 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 } - 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 } - 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 } - 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 } // 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 } - 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 } - 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 } - 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 } // 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 } - 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 } - 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 } - 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 } - 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 } @@ -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 w *httptest.ResponseRecorder var cardDetail CardDetail var cardProfile CardProfile 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 } r = mux.SetURLVars(r, vars) @@ -449,7 +449,7 @@ func GetCardToken(account string, cardId string) (token string, err error) { 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 } r = mux.SetURLVars(r, vars) @@ -458,11 +458,11 @@ func GetCardToken(account string, cardId string) (token string, err error) { return } - token = cardProfile.Guid + "." + cardDetail.Token + token = cardProfile.GUID + "." + cardDetail.Token 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 w *httptest.ResponseRecorder var cards []Card @@ -476,8 +476,8 @@ func GetCardId(account string, guid string) (cardId string, err error) { } for _, card := range cards { - if card.Data.CardProfile.Guid == guid { - cardId = card.Id + if card.Data.CardProfile.GUID == guid { + cardID = card.ID return } } @@ -485,7 +485,7 @@ func GetCardId(account string, guid string) (cardId string, err error) { 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 w *httptest.ResponseRecorder var subject *Subject @@ -505,14 +505,14 @@ func GroupTestCard(account string, cardId string) (groupId string, err error) { if err = ReadResponse(w, &group); err != nil { return } - groupId = group.Id + groupID = group.ID // 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 } - vars["groupId"] = group.Id - vars["cardId"] = cardId + vars["groupID"] = group.ID + vars["cardID"] = cardID r = mux.SetURLVars(r, vars) SetBearerAuth(r, account) SetCardGroup(w, r) @@ -522,16 +522,16 @@ func GroupTestCard(account string, cardId string) (groupId string, err error) { return } -func OpenTestCard(account string, cardId string) (err error) { +func OpenTestCard(account string, cardID string) (err error) { var r *http.Request var w *httptest.ResponseRecorder var msg DataMessage var card Card - var vars = map[string]string{ "cardId": cardId } + var vars = map[string]string{ "cardID": cardID } var contactStatus ContactStatus // 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 } r = mux.SetURLVars(r, vars) @@ -541,7 +541,7 @@ func OpenTestCard(account string, cardId string) (err error) { } // 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 } r = mux.SetURLVars(r, vars) @@ -565,7 +565,7 @@ func OpenTestCard(account string, cardId string) (err error) { article := "articleRevision=" + strconv.FormatInt(contactStatus.ArticleRevision, 10) channel := "channelRevision=" + strconv.FormatInt(contactStatus.ChannelRevision, 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 } r = mux.SetURLVars(r, vars) @@ -577,7 +577,7 @@ func OpenTestCard(account string, cardId string) (err error) { 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 w *httptest.ResponseRecorder var msg DataMessage @@ -600,7 +600,7 @@ func AddTestCard(account string, contact string) (cardId string, err error) { if err = ReadResponse(w, &card); err != nil { return } - cardId = card.Id + cardID = card.ID return } @@ -638,7 +638,7 @@ func AddTestAccount(username string) (guid string, token string, err error) { if err = ReadResponse(w, &profile); err != nil { return } - guid = profile.Guid + guid = profile.GUID // acquire new token for attaching app if r, w, err = NewRequest("POST", "/account/apps", &app); err != nil { diff --git a/net/server/internal/transcodeUtil.go b/net/server/internal/transcodeUtil.go index 03ff02d1..5eec3d27 100644 --- a/net/server/internal/transcodeUtil.go +++ b/net/server/internal/transcodeUtil.go @@ -98,8 +98,8 @@ func transcodeAsset(asset *store.Asset) { ErrMsg(err) } } else { - input := data + "/" + asset.Account.Guid + "/" + asset.TransformId - output := data + "/" + asset.Account.Guid + "/" + asset.AssetId + input := data + "/" + asset.Account.GUID + "/" + asset.TransformID + output := data + "/" + asset.Account.GUID + "/" + asset.AssetID cmd := exec.Command(script + "/transform_" + asset.Transform + ".sh", input, output, asset.TransformParams) var stdout bytes.Buffer cmd.Stdout = &stdout @@ -174,11 +174,11 @@ func UpdateAsset(asset *store.Asset, status string, crc uint32, size int64) (err // determine affected contact list cards := make(map[string]store.Card) for _, card := range topic.Channel.Cards { - cards[card.Guid] = card + cards[card.GUID] = card } for _, group := range topic.Channel.Groups { for _, card := range group.Cards { - cards[card.Guid] = card + cards[card.GUID] = card } } diff --git a/net/server/internal/ucAccountConfig_test.go b/net/server/internal/ucAccountConfig_test.go index 851ec5f0..fcf04416 100644 --- a/net/server/internal/ucAccountConfig_test.go +++ b/net/server/internal/ucAccountConfig_test.go @@ -9,8 +9,8 @@ import ( ) func TestAccountConfig(t *testing.T) { - var params *TestApiParams - var response *TestApiResponse + var params *TestAPIParams + var response *TestAPIResponse var channel *Channel var topic *Topic var assets *[]Asset @@ -31,55 +31,55 @@ func TestAccountConfig(t *testing.T) { // get reset token var token string - params = &TestApiParams{ query: "/account/auth", authorization: "accountconfigA:pass" } - response = &TestApiResponse{ data: &token } - assert.NoError(t, TestApiRequest(AddAccountAuthentication, params, response)) + params = &TestAPIParams{ query: "/account/auth", authorization: "accountconfigA:pass" } + response = &TestAPIResponse{ data: &token } + assert.NoError(t, TestAPIRequest(AddAccountAuthentication, params, response)) // set reset token - params = &TestApiParams{ query: "/account/auth", tokenType: APP_TOKENRESET, token: token, credentials: "newguy:ssap" } - assert.NoError(t, TestApiRequest(SetAccountAuthentication, params, nil)) + params = &TestAPIParams{ query: "/account/auth", tokenType: APP_TOKENRESET, token: token, credentials: "newguy:ssap" } + assert.NoError(t, TestAPIRequest(SetAccountAuthentication, params, nil)) // fail getting reset token - params = &TestApiParams{ query: "/account/auth", authorization: "accountconfigA:pass" } - response = &TestApiResponse{ data: &token } - assert.Error(t, TestApiRequest(AddAccountAuthentication, params, response)) + params = &TestAPIParams{ query: "/account/auth", authorization: "accountconfigA:pass" } + response = &TestAPIResponse{ data: &token } + assert.Error(t, TestAPIRequest(AddAccountAuthentication, params, response)) // create new channel channel = &Channel{} subject = &Subject{ Data: "channeldata", DataType: "channeldatatype" } - params = &TestApiParams{ query: "/content/channels", tokenType: APP_TOKENAGENT, token: set.A.Token, body: subject } - response = &TestApiResponse{ data: channel } - assert.NoError(t, TestApiRequest(AddChannel, params, response)) + params = &TestAPIParams{ query: "/content/channels", tokenType: APP_TOKENAGENT, token: set.A.Token, body: subject } + response = &TestAPIResponse{ data: channel } + assert.NoError(t, TestAPIRequest(AddChannel, params, response)) // create new topic topic = &Topic{} subject = &Subject{ DataType: "topicdatatype", Data: "topicdata" } - params = &TestApiParams{ query: "/content/channels/{channelId}/topics", tokenType: APP_TOKENAGENT, token: set.A.Token, - path: map[string]string{ "channelId": channel.Id }, body: subject } - response = &TestApiResponse{ data: topic } - assert.NoError(t, TestApiRequest(AddChannelTopic, params, response)) + params = &TestAPIParams{ query: "/content/channels/{channelID}/topics", tokenType: APP_TOKENAGENT, token: set.A.Token, + path: map[string]string{ "channelID": channel.ID }, body: subject } + response = &TestAPIResponse{ data: topic } + assert.NoError(t, TestAPIRequest(AddChannelTopic, params, response)) // add asset to topic 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", }) 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)), pathParams, img, APP_TOKENAGENT, set.A.Token, assets, nil)) // update topic status := APP_TOPICCONFIRMED - 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 } - assert.NoError(t, TestApiRequest(SetChannelTopicConfirmed, params, nil)) + 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 } + assert.NoError(t, TestAPIRequest(SetChannelTopicConfirmed, params, nil)) // wait for assets assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool { for _, testChannel := range testApp.channels { - if testChannel.channel.Id == channel.Id { + if testChannel.channel.ID == channel.ID { for _, testTopic := range testChannel.topics { - if testTopic.topic.Id == topic.Id { + if testTopic.topic.ID == topic.ID { detail := testTopic.topic.Data.TopicDetail if detail.Status == APP_TOPICCONFIRMED && detail.Transform == APP_TRANSFORMCOMPLETE { return true @@ -94,35 +94,35 @@ func TestAccountConfig(t *testing.T) { // set to searchable searchable := true - params = &TestApiParams{ query: "/account/searchable", tokenType: APP_TOKENAGENT, token: set.A.Token, body: &searchable } - assert.NoError(t, TestApiRequest(SetAccountSearchable, params, nil)) + params = &TestAPIParams{ query: "/account/searchable", tokenType: APP_TOKENAGENT, token: set.A.Token, body: &searchable } + assert.NoError(t, TestAPIRequest(SetAccountSearchable, params, nil)) // get account status accountStatus := &AccountStatus{} - params = &TestApiParams{ query: "/account/status", tokenType: APP_TOKENAGENT, token: set.A.Token } - response = &TestApiResponse{ data: accountStatus } - assert.NoError(t, TestApiRequest(GetAccountStatus, params, response)) + params = &TestAPIParams{ query: "/account/status", tokenType: APP_TOKENAGENT, token: set.A.Token } + response = &TestAPIResponse{ data: accountStatus } + assert.NoError(t, TestAPIRequest(GetAccountStatus, params, response)) assert.True(t, accountStatus.Searchable) // add asset to topic assets = &[]Asset{} - pathParams = &map[string]string{ "channelId": channel.Id, "topicId": topic.Id } - assert.Error(t, ApiTestUpload(AddChannelTopicAsset, "POST", - "/content/channels/{channelId}/topics/{topicId}/assets?transforms=" + url.QueryEscape(string(transforms)), + pathParams = &map[string]string{ "channelID": channel.ID, "topicID": topic.ID } + assert.Error(t, APITestUpload(AddChannelTopicAsset, "POST", + "/content/channels/{channelID}/topics/{topicID}/assets?transforms=" + url.QueryEscape(string(transforms)), pathParams, img, APP_TOKENAGENT, set.A.Token, assets, nil)) // get list of accounts profiles := []CardProfile{} - params = &TestApiParams{ query: "/account/listing" } - response = &TestApiResponse{ data: &profiles } - assert.NoError(t, TestApiRequest(GetAccountListing, params, response)) + params = &TestAPIParams{ query: "/account/listing" } + response = &TestAPIResponse{ data: &profiles } + assert.NoError(t, TestAPIRequest(GetAccountListing, params, response)) 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 - params = &TestApiParams{ query: "/account/profile", authorization: "newguy:ssap" } - assert.NoError(t, TestApiRequest(RemoveAccount, params, nil)) + params = &TestAPIParams{ query: "/account/profile", authorization: "newguy:ssap" } + assert.NoError(t, TestAPIRequest(RemoveAccount, params, nil)) } diff --git a/net/server/internal/ucAttributeShare_test.go b/net/server/internal/ucAttributeShare_test.go index 63b496e4..61b349c2 100644 --- a/net/server/internal/ucAttributeShare_test.go +++ b/net/server/internal/ucAttributeShare_test.go @@ -34,33 +34,33 @@ func TestAttributeShare(t *testing.T) { // get latest card = &Card{} - param["cardId"] = set.B.A.CardId + param["cardID"] = set.B.A.CardID bRev = GetTestRevision(set.B.Revisions) - assert.NoError(t, ApiTestMsg(GetCard, "GET", "/contact/cards/{cardId}", + assert.NoError(t, APITestMsg(GetCard, "GET", "/contact/cards/{cardID}", ¶m, nil, APP_TOKENAGENT, set.B.Token, card, nil)) bViewRevision = card.Data.NotifiedView bArticleRevision = card.Data.NotifiedArticle card = &Card{} - param["cardId"] = set.C.A.CardId + param["cardID"] = set.C.A.CardID cRev = GetTestRevision(set.C.Revisions) - assert.NoError(t, ApiTestMsg(GetCard, "GET", "/contact/cards/{cardId}", + assert.NoError(t, APITestMsg(GetCard, "GET", "/contact/cards/{cardID}", ¶m, nil, APP_TOKENAGENT, set.C.Token, card, nil)) bViewRevision = card.Data.NotifiedView bArticleRevision = card.Data.NotifiedArticle // add a new attribute 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)) assert.Equal(t, 0, len(*articles)) article = &Article{} 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)) assert.Equal(t, "subjectdata", article.Data.Data) assert.Equal(t, "subjectdatatype", article.Data.DataType) 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)) assert.Equal(t, 1, len(*articles)) @@ -69,10 +69,10 @@ func TestAttributeShare(t *testing.T) { assert.Nil(t, GetTestRevision(set.C.Revisions)) // share article with B - param["articleId"] = article.Id - param["groupId"] = set.A.B.GroupId + param["articleID"] = article.ID + param["groupID"] = set.A.B.GroupID article = &Article{} - assert.NoError(t, ApiTestMsg(SetArticleGroup, "PUT", "/attribute/articles/{articleId}/groups/{groupId}", + assert.NoError(t, APITestMsg(SetArticleGroup, "PUT", "/attribute/articles/{articleID}/groups/{groupID}", ¶m, nil, APP_TOKENAGENT, set.A.Token, article, nil)) // validate B & C view @@ -81,7 +81,7 @@ func TestAttributeShare(t *testing.T) { assert.NotEqual(t, bRev.Card, rev.Card) assert.Nil(t, GetTestRevision(set.C.Revisions)) 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)) assert.Equal(t, 1, len(*cards)) assert.NotEqual(t, bArticleRevision, (*cards)[0].Data.NotifiedArticle) @@ -89,12 +89,12 @@ func TestAttributeShare(t *testing.T) { bRev = rev bArticleRevision = (*cards)[0].Data.NotifiedArticle 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)) assert.Equal(t, 1, len(*articles)) assert.NotNil(t, (*articles)[0].Data) 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)) assert.Equal(t, 0, len(*articles)) @@ -102,9 +102,9 @@ func TestAttributeShare(t *testing.T) { image := "iVBORw0KGgoAAAANSUhEUgAAAaQAAAGkCAIAAADxLsZiAAAFzElEQVR4nOzWUY3jMBhG0e0qSEqoaIqiaEIoGAxh3gZAldid3nMI+JOiXP3bGOMfwLf7v3oAwAxiBySIHZAgdkCC2AEJYgckiB2QIHZAgtgBCWIHJIgdkCB2QILYAQliBySIHZAgdkCC2AEJYgckiB2QIHZAgtgBCWIHJIgdkCB2QILYAQliBySIHZAgdkCC2AEJYgckiB2QIHZAgtgBCWIHJGzTXnrtx7S3pnk+7qsnnMk3+ny+0dtcdkCC2AEJYgckiB2QIHZAgtgBCWIHJIgdkCB2QILYAQliBySIHZAgdkCC2AEJYgckiB2QIHZAgtgBCWIHJIgdkCB2QILYAQliBySIHZAgdkCC2AEJYgckiB2QIHZAgtgBCWIHJIgdkCB2QILYAQliBySIHZAgdkCC2AEJYgckiB2QIHZAgtgBCWIHJIgdkCB2QILYAQliBySIHZAgdkCC2AEJYgckiB2QIHZAgtgBCWIHJIgdkCB2QILYAQliBySIHZAgdkCC2AEJYgckiB2QIHZAgtgBCWIHJIgdkCB2QILYAQnbtJeej/u0t+Bb+Y/e5rIDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSbmOM1RsALueyAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyAhG31gD/stR+rJ5zv+bivnnAm34hfLjsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBhWz2Az/Laj9UT4BIuOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgITbGGP1BoDLueyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7ICEnwAAAP//DQ4epwV6rzkAAAAASUVORK5CYII=" data := "{ \"nested\" : { \"image\" : \"" + image + "\" } }" subject = &Subject{ Data: data, DataType: "nestedimage" } - param["articleId"] = article.Id + param["articleID"] = article.ID article = &Article{} - assert.NoError(t, ApiTestMsg(SetArticleSubject, "PUT", "/attribute/articles/{articleId}/subject", + assert.NoError(t, APITestMsg(SetArticleSubject, "PUT", "/attribute/articles/{articleID}/subject", ¶m, subject, APP_TOKENAGENT, set.A.Token, article, nil)) // validate B & C view @@ -113,7 +113,7 @@ func TestAttributeShare(t *testing.T) { assert.NotEqual(t, bRev.Card, rev.Card) assert.Nil(t, GetTestRevision(set.C.Revisions)) 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)) assert.Equal(t, 1, len(*cards)) assert.NotEqual(t, bArticleRevision, (*cards)[0].Data.NotifiedArticle) @@ -122,7 +122,7 @@ func TestAttributeShare(t *testing.T) { rView = strconv.FormatInt(bViewRevision, 10) rArticle = strconv.FormatInt(bArticleRevision, 10) 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)) assert.Equal(t, 1, len(*articles)) assert.Equal(t, "nestedimage", (*articles)[0].Data.DataType) @@ -130,16 +130,16 @@ func TestAttributeShare(t *testing.T) { bViewRevision = (*cards)[0].Data.NotifiedView // share article with C - param["articleId"] = article.Id - param["groupId"] = set.A.C.GroupId + param["articleID"] = article.ID + param["groupID"] = set.A.C.GroupID article = &Article{} - assert.NoError(t, ApiTestMsg(SetArticleGroup, "PUT", "/attribute/articles/{articleId}/groups/{groupId}", + assert.NoError(t, APITestMsg(SetArticleGroup, "PUT", "/attribute/articles/{articleID}/groups/{groupID}", ¶m, nil, APP_TOKENAGENT, set.A.Token, article, nil)) // A retrieve image - param["articleId"] = article.Id + param["articleID"] = article.ID 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}", ¶m, nil, APP_TOKENAGENT, set.A.Token, 0, 0) assert.NoError(t, aErr) 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)) // C retrieve image - param["articleId"] = article.Id + param["articleID"] = article.ID 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}", ¶m, nil, APP_TOKENCONTACT, set.C.A.Token, 0, 0) assert.NoError(t, cErr) 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.Nil(t, GetTestRevision(set.B.Revisions)) 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)) assert.Equal(t, 1, len(*cards)) cRev = rev 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)) assert.Equal(t, 1, len(*articles)) 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) // unshare article with B - param["articleId"] = article.Id - param["groupId"] = set.A.B.GroupId + param["articleID"] = article.ID + param["groupID"] = set.A.B.GroupID article = &Article{} - assert.NoError(t, ApiTestMsg(ClearArticleGroup, "DELETE", "/attribute/articles/{articleId}/groups/{groupId}", + assert.NoError(t, APITestMsg(ClearArticleGroup, "DELETE", "/attribute/articles/{articleID}/groups/{groupID}", ¶m, nil, APP_TOKENAGENT, set.A.Token, article, nil)) // validate B & C view @@ -187,7 +187,7 @@ func TestAttributeShare(t *testing.T) { assert.NotEqual(t, bRev.Card, rev.Card) assert.Nil(t, GetTestRevision(set.C.Revisions)) 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)) assert.Equal(t, 1, len(*cards)) assert.NotEqual(t, bArticleRevision, (*cards)[0].Data.NotifiedArticle) @@ -196,20 +196,20 @@ func TestAttributeShare(t *testing.T) { rView = strconv.FormatInt(bViewRevision, 10) rArticle = strconv.FormatInt(bArticleRevision, 10) 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)) assert.Equal(t, 1, len(*articles)) assert.Nil(t, (*articles)[0].Data) card = &Card{} - param["cardId"] = set.C.A.CardId + param["cardID"] = set.C.A.CardID GetTestRevision(set.B.Revisions) // delete article - param["articleId"] = article.Id - assert.NoError(t, ApiTestMsg(RemoveArticle, "DELETE", "/attribute/articles/{articleId}", + param["articleID"] = article.ID + assert.NoError(t, APITestMsg(RemoveArticle, "DELETE", "/attribute/articles/{articleID}", ¶m, nil, APP_TOKENAGENT, set.A.Token, nil, nil)) 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)) assert.Equal(t, 0, len(*articles)) @@ -219,13 +219,13 @@ func TestAttributeShare(t *testing.T) { assert.NotEqual(t, cRev.Card, rev.Card) assert.Nil(t, GetTestRevision(set.B.Revisions)) 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)) assert.Equal(t, 1, len(*cards)) rView = strconv.FormatInt(cViewRevision, 10) rArticle = strconv.FormatInt(cArticleRevision, 10) 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)) assert.Equal(t, 1, len(*articles)) assert.Nil(t, (*articles)[0].Data) @@ -234,38 +234,38 @@ func TestAttributeShare(t *testing.T) { rView = strconv.FormatInt(cViewRevision - 1, 10) rArticle = strconv.FormatInt(cArticleRevision - 1, 10) 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)) // reset B's view 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)) bArticleRevision, _ = strconv.ParseInt(hdr["Article-Revision"][0], 10, 64) bViewRevision, _ = strconv.ParseInt(hdr["View-Revision"][0], 10, 64) // add a new attribute 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)) assert.Equal(t, 0, len(*articles)) article = &Article{} 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)) assert.Equal(t, "subjectdata", article.Data.Data) assert.Equal(t, "subjectdatatype", article.Data.DataType) articles = &[]Article{} // share article with B - param["articleId"] = article.Id - param["groupId"] = set.A.B.GroupId + param["articleID"] = article.ID + param["groupID"] = set.A.B.GroupID article = &Article{} - assert.NoError(t, ApiTestMsg(SetArticleGroup, "PUT", "/attribute/articles/{articleId}/groups/{groupId}", + assert.NoError(t, APITestMsg(SetArticleGroup, "PUT", "/attribute/articles/{articleID}/groups/{groupID}", ¶m, nil, APP_TOKENAGENT, set.A.Token, article, nil)) rView = strconv.FormatInt(bViewRevision, 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)) assert.Equal(t, 1, len(*articles)) assert.NotNil(t, (*articles)[0].Data) @@ -273,12 +273,12 @@ func TestAttributeShare(t *testing.T) { bViewRevision, _ = strconv.ParseInt(hdr["View-Revision"][0], 10, 64) // delete B's group - assert.NoError(t, ApiTestMsg(RemoveGroup, "DELETE", "/alias/groups/{groupId}", + assert.NoError(t, APITestMsg(RemoveGroup, "DELETE", "/alias/groups/{groupID}", ¶m, 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)) 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)) view, _ := strconv.ParseInt(hdr["View-Revision"][0], 10, 64) assert.NotEqual(t, bViewRevision, view) diff --git a/net/server/internal/ucChannelShare_test.go b/net/server/internal/ucChannelShare_test.go index cc28fa6b..daa4c7fb 100644 --- a/net/server/internal/ucChannelShare_test.go +++ b/net/server/internal/ucChannelShare_test.go @@ -33,59 +33,59 @@ func TestChannelShare(t *testing.T) { // add new channel channel = &Channel{} 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)) // retrieve channels 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)) assert.Equal(t, 1, len(*channels)) assert.NotNil(t, (*channels)[0].Data) detailRevision = (*channels)[0].Data.DetailRevision 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)) assert.Equal(t, 0, len(*channels)) 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)) assert.Equal(t, 0, len(*channels)) // assign channel to B - params["channelId"] = channel.Id - params["cardId"] = set.A.B.CardId - assert.NoError(t, ApiTestMsg(SetChannelCard, "PUT", "/content/channels/{channelId}/cards/{cardId}", + params["channelID"] = channel.ID + params["cardID"] = set.A.B.CardID + assert.NoError(t, APITestMsg(SetChannelCard, "PUT", "/content/channels/{channelID}/cards/{cardID}", ¶ms, nil, APP_TOKENAGENT, set.A.Token, nil, nil)) // check shared channel channels = &[]Channel{} 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)) assert.Equal(t, 1, len(*channels)) assert.NotNil(t, (*channels)[0].Data) assert.NotEqual(t, detailRevision, (*channels)[0].Data.DetailRevision) channels = &[]Channel{} 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)) assert.Equal(t, 1, len(*channels)) assert.NotNil(t, (*channels)[0].Data) channels = &[]Channel{} 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)) assert.Equal(t, 1, len(*channels)) assert.Nil(t, (*channels)[0].Data) // get discovered channel detail = &ChannelDetail{} - assert.NoError(t, ApiTestMsg(GetChannelDetail, "GET", "/content/channels/{channelId}/detail", + assert.NoError(t, APITestMsg(GetChannelDetail, "GET", "/content/channels/{channelID}/detail", ¶ms, nil, APP_TOKENCONTACT, set.B.A.Token, detail, nil)) assert.Equal(t, "channeldatatype", detail.DataType) 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) // get revision @@ -93,22 +93,22 @@ func TestChannelShare(t *testing.T) { bRev = GetTestRevision(set.B.Revisions) cRev = GetTestRevision(set.C.Revisions) 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)) 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)) 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)) 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)) // assign channel to C - params["channelId"] = channel.Id - params["cardId"] = set.A.C.CardId - assert.NoError(t, ApiTestMsg(SetChannelCard, "PUT", "/content/channels/{channelId}/cards/{cardId}", + params["channelID"] = channel.ID + params["cardID"] = set.A.C.CardID + assert.NoError(t, APITestMsg(SetChannelCard, "PUT", "/content/channels/{channelID}/cards/{cardID}", ¶ms, nil, APP_TOKENAGENT, set.A.Token, nil, nil)) // check revision change @@ -118,7 +118,7 @@ func TestChannelShare(t *testing.T) { rev = GetTestRevision(set.B.Revisions) assert.NotEqual(t, rev.Card, bRev.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)) assert.Equal(t, 1, len(*cards)) r, _ = strconv.ParseInt(bChannelRevision["Channel-Revision"][0], 10, 64) @@ -130,7 +130,7 @@ func TestChannelShare(t *testing.T) { rev = GetTestRevision(set.C.Revisions) assert.NotEqual(t, rev.Card, cRev.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)) assert.Equal(t, 1, len(*cards)) r, _ = strconv.ParseInt(cChannelRevision["Channel-Revision"][0], 10, 64) @@ -141,18 +141,18 @@ func TestChannelShare(t *testing.T) { channels = &[]Channel{} 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)) assert.Equal(t, 1, len(*channels)) channels = &[]Channel{} 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)) assert.Equal(t, 1, len(*channels)) // get discovered channel detail = &ChannelDetail{} - assert.NoError(t, ApiTestMsg(GetChannelDetail, "GET", "/content/channels/{channelId}/detail", + assert.NoError(t, APITestMsg(GetChannelDetail, "GET", "/content/channels/{channelID}/detail", ¶ms, nil, APP_TOKENCONTACT, set.C.A.Token, detail, nil)) assert.Equal(t, "channeldatatype", detail.DataType) assert.Equal(t, 2, len(detail.Members)) @@ -163,16 +163,16 @@ func TestChannelShare(t *testing.T) { GetTestRevision(set.C.Revisions) // remove channel from C - params["channelId"] = channel.Id - params["cardId"] = set.A.C.CardId - assert.NoError(t, ApiTestMsg(ClearChannelCard, "DELETE", "/content/channels/{channelId}/cards/{cardId}", + params["channelID"] = channel.ID + params["cardID"] = set.A.C.CardID + assert.NoError(t, APITestMsg(ClearChannelCard, "DELETE", "/content/channels/{channelID}/cards/{cardID}", ¶ms, nil, APP_TOKENAGENT, set.A.Token, nil, nil)) // check channel view from C assert.NotNil(t, GetTestRevision(set.B.Revisions)) assert.NotNil(t, GetTestRevision(set.C.Revisions)) 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)) assert.Equal(t, 1, len(*channels)) assert.Nil(t, (*channels)[0].Data) @@ -182,7 +182,7 @@ func TestChannelShare(t *testing.T) { data := "{ \"nested\" : { \"image\" : \"" + image + "\" } }" subject = &Subject{ Data: data, DataType: "nestedimage" } channel = &Channel{} - assert.NoError(t, ApiTestMsg(SetChannelSubject, "PUT", "/content/channels/{channelId}/subject", + assert.NoError(t, APITestMsg(SetChannelSubject, "PUT", "/content/channels/{channelID}/subject", ¶ms, subject, APP_TOKENAGENT, set.A.Token, channel, nil)) // check notifications @@ -190,9 +190,9 @@ func TestChannelShare(t *testing.T) { assert.Nil(t, GetTestRevision(set.C.Revisions)) // add C group to channel - params["groupId"] = set.A.C.GroupId + params["groupID"] = set.A.C.GroupID channel = &Channel{} - assert.NoError(t, ApiTestMsg(SetChannelGroup, "PUT", "/content/channels/{channelId}/groups/{groupId}", + assert.NoError(t, APITestMsg(SetChannelGroup, "PUT", "/content/channels/{channelID}/groups/{groupID}", ¶ms, 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.Groups)) @@ -202,9 +202,9 @@ func TestChannelShare(t *testing.T) { GetTestRevision(set.C.Revisions) // remove channel from B - params["channelId"] = channel.Id - params["cardId"] = set.A.B.CardId - assert.NoError(t, ApiTestMsg(ClearChannelCard, "DELETE", "/content/channels/{channelId}/cards/{cardId}", + params["channelID"] = channel.ID + params["cardID"] = set.A.B.CardID + assert.NoError(t, APITestMsg(ClearChannelCard, "DELETE", "/content/channels/{channelID}/cards/{cardID}", ¶ms, nil, APP_TOKENAGENT, set.A.Token, channel, nil)) // check notifications @@ -212,9 +212,9 @@ func TestChannelShare(t *testing.T) { assert.NotNil(t, GetTestRevision(set.C.Revisions)) // remove C group from channel - params["groupId"] = set.A.C.GroupId + params["groupID"] = set.A.C.GroupID channel = &Channel{} - assert.NoError(t, ApiTestMsg(ClearChannelGroup, "DELETE", "/content/channels/{channelId}/groups/{groupId}", + assert.NoError(t, APITestMsg(ClearChannelGroup, "DELETE", "/content/channels/{channelID}/groups/{groupID}", ¶ms, 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.Groups)) diff --git a/net/server/internal/ucContactApp_test.go b/net/server/internal/ucContactApp_test.go index a51e5eaf..73dac299 100644 --- a/net/server/internal/ucContactApp_test.go +++ b/net/server/internal/ucContactApp_test.go @@ -6,8 +6,8 @@ import ( ) func TestContactApp(t *testing.T) { - var params *TestApiParams - var response *TestApiResponse + var params *TestAPIParams + var response *TestAPIResponse // allocate test accounts set, err := AddTestGroup("contactapp") @@ -30,7 +30,7 @@ func TestContactApp(t *testing.T) { Name: "Roland", 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)) // wait for test @@ -44,13 +44,13 @@ func TestContactApp(t *testing.T) { // add a new article article := &Article{} subject := &Subject{ Data: "subjectdata", DataType: "subjectdatatype" } - params = &TestApiParams{ restType: "POST", query: "/articles", tokenType: APP_TOKENAGENT, token: set.A.Token, body: subject } - response = &TestApiResponse{ data: article } - assert.NoError(t, TestApiRequest(AddArticle, params, response)) + params = &TestAPIParams{ restType: "POST", query: "/articles", tokenType: APP_TOKENAGENT, token: set.A.Token, body: subject } + response = &TestAPIResponse{ data: article } + assert.NoError(t, TestAPIRequest(AddArticle, params, response)) // wait for a 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" { return true } @@ -58,14 +58,14 @@ func TestContactApp(t *testing.T) { })) // 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 } - response = &TestApiResponse{} - assert.NoError(t, TestApiRequest(RemoveArticle, params, response)) + response = &TestAPIResponse{} + assert.NoError(t, TestAPIRequest(RemoveArticle, params, response)) // wait for a to be removed 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 false @@ -74,23 +74,23 @@ func TestContactApp(t *testing.T) { // add a new article in contact article = &Article{} subject = &Subject{ Data: "subjectdataB", DataType: "subjectdatatypeB" } - params = &TestApiParams{ restType: "POST", query: "/articles", tokenType: APP_TOKENAGENT, token: set.B.Token, body: subject } - response = &TestApiResponse{ data: article } - assert.NoError(t, TestApiRequest(AddArticle, params, response)) - articleId := article.Id + params = &TestAPIParams{ restType: "POST", query: "/articles", tokenType: APP_TOKENAGENT, token: set.B.Token, body: subject } + response = &TestAPIResponse{ data: article } + assert.NoError(t, TestAPIRequest(AddArticle, params, response)) + articleID := article.ID // share article article = &Article{} - 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 }} - response = &TestApiResponse{ data: article } - assert.NoError(t, TestApiRequest(SetArticleGroup, params, response)) + 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 }} + response = &TestAPIResponse{ data: article } + assert.NoError(t, TestAPIRequest(SetArticleGroup, params, response)) // wait for 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 { - _, articleSet := contact.articles[articleId] + _, articleSet := contact.articles[articleID] if articleSet { return true } @@ -100,16 +100,16 @@ func TestContactApp(t *testing.T) { // remove new article in contact article = &Article{} - params = &TestApiParams{ restType: "DELETE", query: "/articles/{articleId}", tokenType: APP_TOKENAGENT, token: set.B.Token, - path: map[string]string{ "articleId": articleId }} - response = &TestApiResponse{ } - assert.NoError(t, TestApiRequest(RemoveArticle, params, response)) + params = &TestAPIParams{ restType: "DELETE", query: "/articles/{articleID}", tokenType: APP_TOKENAGENT, token: set.B.Token, + path: map[string]string{ "articleID": articleID }} + response = &TestAPIResponse{ } + assert.NoError(t, TestAPIRequest(RemoveArticle, params, response)) // wait for 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 { - _, articleSet := contact.articles[articleId] + _, articleSet := contact.articles[articleID] if !articleSet { return true } @@ -120,23 +120,23 @@ func TestContactApp(t *testing.T) { // add a new article in contact article = &Article{} subject = &Subject{ Data: "subjectdataB", DataType: "subjectdatatypeB" } - params = &TestApiParams{ restType: "POST", query: "/articles", tokenType: APP_TOKENAGENT, token: set.B.Token, body: subject } - response = &TestApiResponse{ data: article } - assert.NoError(t, TestApiRequest(AddArticle, params, response)) - articleId = article.Id + params = &TestAPIParams{ restType: "POST", query: "/articles", tokenType: APP_TOKENAGENT, token: set.B.Token, body: subject } + response = &TestAPIResponse{ data: article } + assert.NoError(t, TestAPIRequest(AddArticle, params, response)) + articleID = article.ID // share article article = &Article{} - 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 }} - response = &TestApiResponse{ data: article } - assert.NoError(t, TestApiRequest(SetArticleGroup, params, response)) + 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 }} + response = &TestAPIResponse{ data: article } + assert.NoError(t, TestAPIRequest(SetArticleGroup, params, response)) // wait for 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 { - _, articleSet := contact.articles[articleId] + _, articleSet := contact.articles[articleID] if articleSet { return true } @@ -146,16 +146,16 @@ func TestContactApp(t *testing.T) { // remove group in contact article = &Article{} - params = &TestApiParams{ restType: "DELETE", query: "/groups/{groupId}", tokenType: APP_TOKENAGENT, token: set.B.Token, - path: map[string]string{ "groupId": set.B.A.GroupId }} - response = &TestApiResponse{ } - assert.NoError(t, TestApiRequest(RemoveGroup, params, response)) + params = &TestAPIParams{ restType: "DELETE", query: "/groups/{groupID}", tokenType: APP_TOKENAGENT, token: set.B.Token, + path: map[string]string{ "groupID": set.B.A.GroupID }} + response = &TestAPIResponse{ } + assert.NoError(t, TestAPIRequest(RemoveGroup, params, response)) // wait for 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 { - _, articleSet := contact.articles[articleId] + _, articleSet := contact.articles[articleID] if !articleSet { return true } @@ -165,9 +165,9 @@ func TestContactApp(t *testing.T) { // update Bs profile profileData = &ProfileData{ Name: "contactappname" } - params = &TestApiParams{ restType: "PUT", query: "/profile/data", tokenType: APP_TOKENAGENT, token: set.B.Token, body: profileData } - response = &TestApiResponse{} - assert.NoError(t, TestApiRequest(SetProfile, params, response)) + params = &TestAPIParams{ restType: "PUT", query: "/profile/data", tokenType: APP_TOKENAGENT, token: set.B.Token, body: profileData } + response = &TestAPIResponse{} + assert.NoError(t, TestAPIRequest(SetProfile, params, response)) // wait for assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool { @@ -181,22 +181,22 @@ func TestContactApp(t *testing.T) { // disconnect from B card := &Card{} - 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 } - response = &TestApiResponse{ data: card } - assert.NoError(t, TestApiRequest(SetCardStatus, params, response)) + 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 } + response = &TestAPIResponse{ data: card } + assert.NoError(t, TestAPIRequest(SetCardStatus, params, response)) msg := &DataMessage{} - params = &TestApiParams { query: "/contact/cards/{cardId}/closeMessage", tokenType: APP_TOKENAGENT, token: set.B.Token, - path: map[string]string{ "cardId": set.B.A.CardId } } - response = &TestApiResponse{ data: msg } - assert.NoError(t, TestApiRequest(GetCloseMessage, params, response)) - params = &TestApiParams { restType: "PUT", query: "/contact/closeMessage", body: msg } - response = &TestApiResponse{} - assert.NoError(t, TestApiRequest(SetCloseMessage, params, response)) + params = &TestAPIParams { query: "/contact/cards/{cardID}/closeMessage", tokenType: APP_TOKENAGENT, token: set.B.Token, + path: map[string]string{ "cardID": set.B.A.CardID } } + response = &TestAPIResponse{ data: msg } + assert.NoError(t, TestAPIRequest(GetCloseMessage, params, response)) + params = &TestAPIParams { restType: "PUT", query: "/contact/closeMessage", body: msg } + response = &TestAPIResponse{} + assert.NoError(t, TestAPIRequest(SetCloseMessage, params, response)) // wait for 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 { return true } diff --git a/net/server/internal/ucContactSync_test.go b/net/server/internal/ucContactSync_test.go index 1a995c37..4b425910 100644 --- a/net/server/internal/ucContactSync_test.go +++ b/net/server/internal/ucContactSync_test.go @@ -30,17 +30,17 @@ func TestContactSync(t *testing.T) { // set profile image image := "iVBORw0KGgoAAAANSUhEUgAAAaQAAAGkCAIAAADxLsZiAAAFzElEQVR4nOzWUY3jMBhG0e0qSEqoaIqiaEIoGAxh3gZAldid3nMI+JOiXP3bGOMfwLf7v3oAwAxiBySIHZAgdkCC2AEJYgckiB2QIHZAgtgBCWIHJIgdkCB2QILYAQliBySIHZAgdkCC2AEJYgckiB2QIHZAgtgBCWIHJIgdkCB2QILYAQliBySIHZAgdkCC2AEJYgckiB2QIHZAgtgBCWIHJGzTXnrtx7S3pnk+7qsnnMk3+ny+0dtcdkCC2AEJYgckiB2QIHZAgtgBCWIHJIgdkCB2QILYAQliBySIHZAgdkCC2AEJYgckiB2QIHZAgtgBCWIHJIgdkCB2QILYAQliBySIHZAgdkCC2AEJYgckiB2QIHZAgtgBCWIHJIgdkCB2QILYAQliBySIHZAgdkCC2AEJYgckiB2QIHZAgtgBCWIHJIgdkCB2QILYAQliBySIHZAgdkCC2AEJYgckiB2QIHZAgtgBCWIHJIgdkCB2QILYAQliBySIHZAgdkCC2AEJYgckiB2QIHZAgtgBCWIHJIgdkCB2QILYAQnbtJeej/u0t+Bb+Y/e5rIDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSbmOM1RsALueyAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyAhG31gD/stR+rJ5zv+bivnnAm34hfLjsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBhWz2Az/Laj9UT4BIuOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgITbGGP1BoDLueyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7ICEnwAAAP//DQ4epwV6rzkAAAAASUVORK5CYII=" - 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)) // 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)) - param["cardId"] = set.B.A.CardId - assert.NoError(t, ApiTestMsg(SetCardProfile, "PUT", "/contact/cards/{cardId}/profile", + param["cardID"] = set.B.A.CardID + assert.NoError(t, APITestMsg(SetCardProfile, "PUT", "/contact/cards/{cardID}/profile", ¶m, &msg, APP_TOKENAGENT, set.B.Token, &card, nil)) 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", ¶m, &data, APP_TOKENAGENT, set.B.Token, 0, 0) assert.NoError(t, res) @@ -52,122 +52,122 @@ func TestContactSync(t *testing.T) { // get full card list 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)) cardRevision = hdr["Card-Revision"][0] 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)) cardRevision = hdr["Card-Revision"][0] assert.Equal(t, 0, len(*cards)) // ?? actual 1 // set card notes GetTestRevision(set.B.Revisions) - assert.NoError(t, ApiTestMsg(SetCardNotes, "PUT", "/conact/cards/{cardId}/notes", + assert.NoError(t, APITestMsg(SetCardNotes, "PUT", "/conact/cards/{cardID}/notes", ¶m, "CardA notes", APP_TOKENAGENT, set.B.Token, &detail, nil)) rev = GetTestRevision(set.B.Revisions) 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)) assert.Equal(t, 1, len(*cards)) detailRevision = (*cards)[0].Data.DetailRevision // clear card notes GetTestRevision(set.B.Revisions) - assert.NoError(t, ApiTestMsg(ClearCardNotes, "DELETE", "/contact/cards/{cardId}/notes", + assert.NoError(t, APITestMsg(ClearCardNotes, "DELETE", "/contact/cards/{cardID}/notes", ¶m, nil, APP_TOKENAGENT, set.B.Token, &detail, nil)) assert.NotEqual(t, rev.Card, GetTestRevision(set.B.Revisions).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)) assert.Equal(t, 1, len(*cards)) assert.NotEqual(t, detailRevision, (*cards)[0].Data.DetailRevision) // remove card from group card = &Card{} - param["cardId"] = set.B.A.CardId - assert.NoError(t, ApiTestMsg(GetCard, "GET", "/contact/cards/{cardId}", + param["cardID"] = set.B.A.CardID + assert.NoError(t, APITestMsg(GetCard, "GET", "/contact/cards/{cardID}", ¶m, nil, APP_TOKENAGENT, set.B.Token, card, nil)) assert.Equal(t, "connected", card.Data.CardDetail.Status) viewRevision = card.Data.NotifiedView card = &Card{} - param["cardId"] = set.A.B.CardId - param["groupId"] = set.A.B.GroupId - assert.NoError(t, ApiTestMsg(ClearCardGroup, "DELETE", "/contact/cards/{cardId}/groups/{groupId}", + param["cardID"] = set.A.B.CardID + param["groupID"] = set.A.B.GroupID + assert.NoError(t, APITestMsg(ClearCardGroup, "DELETE", "/contact/cards/{cardID}/groups/{groupID}", ¶m, nil, APP_TOKENAGENT, set.A.Token, card, nil)) assert.Equal(t, 0, len(card.Data.CardDetail.Groups)) assert.NotEqual(t, rev.Card, GetTestRevision(set.B.Revisions).Card) card = &Card{} - param["cardId"] = set.B.A.CardId - assert.NoError(t, ApiTestMsg(GetCard, "GET", "/contact/cards/{cardId}", + param["cardID"] = set.B.A.CardID + assert.NoError(t, APITestMsg(GetCard, "GET", "/contact/cards/{cardID}", ¶m, nil, APP_TOKENAGENT, set.B.Token, card, nil)) assert.NotEqual(t, viewRevision, card.Data.NotifiedView) // disconnect card card = &Card{} - param["cardId"] = set.A.B.CardId - assert.NoError(t, ApiTestMsg(SetCardStatus, "PUT", "/contact/cards/{cardId}/status", + param["cardID"] = set.A.B.CardID + assert.NoError(t, APITestMsg(SetCardStatus, "PUT", "/contact/cards/{cardID}/status", ¶m, 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", ¶m, 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)) assert.NotNil(t, GetTestRevision(set.B.Revisions)) card = &Card{} - param["cardId"] = set.B.A.CardId - assert.NoError(t, ApiTestMsg(GetCard, "GET", "/contact/cards/{cardId}", + param["cardID"] = set.B.A.CardID + assert.NoError(t, APITestMsg(GetCard, "GET", "/contact/cards/{cardID}", ¶m, nil, APP_TOKENAGENT, set.B.Token, card, nil)) assert.Equal(t, "confirmed", card.Data.CardDetail.Status) // cancel request card = &Card{} - param["cardId"] = set.D.A.CardId - assert.NoError(t, ApiTestMsg(GetCard, "GET", "/contact/cards/{cardId}", + param["cardID"] = set.D.A.CardID + assert.NoError(t, APITestMsg(GetCard, "GET", "/contact/cards/{cardID}", ¶m, nil, APP_TOKENAGENT, set.D.Token, card, nil)) - param["cardId"] = set.A.D.CardId - assert.NoError(t, ApiTestMsg(SetCardStatus, "PUT", "/contact/cards/{cardId}/status", + param["cardID"] = set.A.D.CardID + assert.NoError(t, APITestMsg(SetCardStatus, "PUT", "/contact/cards/{cardID}/status", ¶m, 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", ¶m, 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)) // delete card - param["cardId"] = set.A.C.CardId - assert.NoError(t, ApiTestMsg(RemoveCard, "DELETE", "/contact/cards/{cardId}", + param["cardID"] = set.A.C.CardID + assert.NoError(t, APITestMsg(RemoveCard, "DELETE", "/contact/cards/{cardID}", ¶m, nil, APP_TOKENAGENT, set.A.Token, nil, nil)) card = &Card{} - assert.NoError(t, ApiTestMsg(GetCard, "GET", "/contact/cards/{cardId}", + assert.NoError(t, APITestMsg(GetCard, "GET", "/contact/cards/{cardID}", ¶m, nil, APP_TOKENAGENT, set.A.Token, card, nil)) assert.Nil(t, card.Data) // update and delete group - param["groupId"] = set.D.C.GroupId + param["groupID"] = set.D.C.GroupID subject := &Subject{ DataType: "contactsynctype", Data: "contactsyncdata" } - assert.NoError(t, ApiTestMsg(SetGroupSubject, "PUT", "/alias/groups/{groupId}", + assert.NoError(t, APITestMsg(SetGroupSubject, "PUT", "/alias/groups/{groupID}", ¶m, subject, APP_TOKENAGENT, set.D.Token, nil, nil)) 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)) assert.Equal(t, 1, len(*groups)) assert.Equal(t, "contactsynctype", (*groups)[0].Data.DataType) assert.Equal(t, "contactsyncdata", (*groups)[0].Data.Data) rev = GetTestRevision(set.C.Revisions) card = &Card{} - param["cardId"] = set.C.D.CardId - assert.NoError(t, ApiTestMsg(GetCard, "GET", "/contact/cards/{cardId}", + param["cardID"] = set.C.D.CardID + assert.NoError(t, APITestMsg(GetCard, "GET", "/contact/cards/{cardID}", ¶m, nil, APP_TOKENAGENT, set.C.Token, card, nil)) viewRevision = card.Data.NotifiedView - param["groupId"] = set.D.C.GroupId - assert.NoError(t, ApiTestMsg(RemoveGroup, "GET", "/alias/groups/{groupId}", + param["groupID"] = set.D.C.GroupID + assert.NoError(t, APITestMsg(RemoveGroup, "GET", "/alias/groups/{groupID}", ¶m, nil, APP_TOKENAGENT, set.D.Token, nil, nil)) 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)) assert.Equal(t, 0, len(*groups)) assert.NotEqual(t, rev.Card, GetTestRevision(set.C.Revisions).Card) card = &Card{} - assert.NoError(t, ApiTestMsg(GetCard, "GET", "/contact/cards/{cardId}", + assert.NoError(t, APITestMsg(GetCard, "GET", "/contact/cards/{cardID}", ¶m, nil, APP_TOKENAGENT, set.C.Token, card, nil)) assert.NotEqual(t, viewRevision, card.Data.NotifiedView) } diff --git a/net/server/internal/ucMessangerApp_test.go b/net/server/internal/ucMessangerApp_test.go index 4c2cf991..b254b96e 100644 --- a/net/server/internal/ucMessangerApp_test.go +++ b/net/server/internal/ucMessangerApp_test.go @@ -6,8 +6,8 @@ import ( ) func TestMessangerApp(t *testing.T) { - var params *TestApiParams - var response *TestApiResponse + var params *TestAPIParams + var response *TestAPIResponse var channel *Channel var topic *Topic var tag *Tag @@ -29,7 +29,7 @@ func TestMessangerApp(t *testing.T) { })) // set profile - params = &TestApiParams{ + params = &TestAPIParams{ restType: "PUT", query: "/profile/data", body: &ProfileData{ @@ -39,8 +39,8 @@ func TestMessangerApp(t *testing.T) { tokenType: APP_TOKENAGENT, token: set.A.Token, } - response = &TestApiResponse{} - assert.NoError(t, TestApiRequest(SetProfile, params, response)) + response = &TestAPIResponse{} + assert.NoError(t, TestAPIRequest(SetProfile, params, response)) // wait for test assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool{ @@ -51,7 +51,7 @@ func TestMessangerApp(t *testing.T) { })) // add a channel - params = &TestApiParams{ + params = &TestAPIParams{ restType: "POST", query: "/content/channels", body: &Subject{ @@ -62,13 +62,13 @@ func TestMessangerApp(t *testing.T) { token: set.A.Token, } channel = &Channel{} - response = &TestApiResponse{ data: channel } - assert.NoError(t, TestApiRequest(AddChannel, params, response)) + response = &TestAPIResponse{ data: channel } + assert.NoError(t, TestAPIRequest(AddChannel, params, response)) // wait for test assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool{ for _, c := range testApp.channels { - if c.channel.Id == channel.Id { + if c.channel.ID == channel.ID { return true } } @@ -76,10 +76,10 @@ func TestMessangerApp(t *testing.T) { })) // add a topic to channel - params = &TestApiParams{ + params = &TestAPIParams{ restType: "POST", - query: "/content/channels/{channelId}/topics", - path: map[string]string{ "channelId": channel.Id }, + query: "/content/channels/{channelID}/topics", + path: map[string]string{ "channelID": channel.ID }, body: &Subject{ Data: "channeltopicdataA", DataType: "channeltopicdatatypeA", @@ -88,15 +88,15 @@ func TestMessangerApp(t *testing.T) { token: set.A.Token, } topic = &Topic{} - response = &TestApiResponse{ data: topic } - assert.NoError(t, TestApiRequest(AddChannelTopic, params, response)) + response = &TestAPIResponse{ data: topic } + assert.NoError(t, TestAPIRequest(AddChannelTopic, params, response)) // wait for test assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool{ for _, c := range testApp.channels { - if c.channel.Id == channel.Id { + if c.channel.ID == channel.ID { for _, t := range c.topics { - if t.topic.Id == topic.Id { + if t.topic.ID == topic.ID { return true } } @@ -106,10 +106,10 @@ func TestMessangerApp(t *testing.T) { })) // add a tag to channel topic - params = &TestApiParams{ + params = &TestAPIParams{ restType: "POST", - query: "/content/channels/{channelId}/topics/{topicId}/tags", - path: map[string]string{ "channelId": channel.Id, "topicId": topic.Id }, + query: "/content/channels/{channelID}/topics/{topicID}/tags", + path: map[string]string{ "channelID": channel.ID, "topicID": topic.ID }, body: &Subject{ Data: "channeltopictagdataA", DataType: "channeltopictagdatatypeA", @@ -118,17 +118,17 @@ func TestMessangerApp(t *testing.T) { token: set.A.Token, } tag = &Tag{} - response = &TestApiResponse{ data: tag } - assert.NoError(t, TestApiRequest(AddChannelTopicTag, params, response)) + response = &TestAPIResponse{ data: tag } + assert.NoError(t, TestAPIRequest(AddChannelTopicTag, params, response)) // wait for test assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool{ for _, testChannel := range testApp.channels { - if testChannel.channel.Id == channel.Id { + if testChannel.channel.ID == channel.ID { for _, testTopic := range testChannel.topics { - if testTopic.topic.Id == topic.Id { + if testTopic.topic.ID == topic.ID { for _, testTag := range testTopic.tags { - if testTag.Id == tag.Id { + if testTag.ID == tag.ID { return true } } @@ -141,7 +141,7 @@ func TestMessangerApp(t *testing.T) { // add a channel - params = &TestApiParams{ + params = &TestAPIParams{ restType: "POST", query: "/content/channels", body: &Subject{ @@ -152,26 +152,26 @@ func TestMessangerApp(t *testing.T) { token: set.B.Token, } channel = &Channel{} - response = &TestApiResponse{ data: channel } - assert.NoError(t, TestApiRequest(AddChannel, params, response)) + response = &TestAPIResponse{ data: channel } + assert.NoError(t, TestAPIRequest(AddChannel, params, response)) // share channel with A - params = &TestApiParams{ + params = &TestAPIParams{ restType: "PUT", - query: "/content/channels/{channelId}/cards/{cardId}", - path: map[string]string{ "cardId": set.B.A.CardId, "channelId": channel.Id }, + query: "/content/channels/{channelID}/cards/{cardID}", + path: map[string]string{ "cardID": set.B.A.CardID, "channelID": channel.ID }, tokenType: APP_TOKENAGENT, token: set.B.Token, } - response = &TestApiResponse{} - assert.NoError(t, TestApiRequest(SetChannelCard, params, response)) + response = &TestAPIResponse{} + assert.NoError(t, TestAPIRequest(SetChannelCard, params, response)) // wait for test assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool{ 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 { - if testChannel.channel.Id == channel.Id { + if testChannel.channel.ID == channel.ID { return true } } @@ -181,10 +181,10 @@ func TestMessangerApp(t *testing.T) { })) // add a topic to channel - params = &TestApiParams{ + params = &TestAPIParams{ restType: "POST", - query: "/content/channels/{channelId}/topics", - path: map[string]string{ "channelId": channel.Id }, + query: "/content/channels/{channelID}/topics", + path: map[string]string{ "channelID": channel.ID }, body: &Subject{ Data: "channeltopicdataB", DataType: "channeltopicdatatypeB", @@ -193,17 +193,17 @@ func TestMessangerApp(t *testing.T) { token: set.A.B.Token, } topic = &Topic{} - response = &TestApiResponse{ data: topic } - assert.NoError(t, TestApiRequest(AddChannelTopic, params, response)) + response = &TestAPIResponse{ data: topic } + assert.NoError(t, TestAPIRequest(AddChannelTopic, params, response)) // wait for test assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool{ 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 { - if testChannel.channel.Id == channel.Id { + if testChannel.channel.ID == channel.ID { for _, t := range testChannel.topics { - if t.topic.Id == topic.Id { + if t.topic.ID == topic.ID { return true } } @@ -215,10 +215,10 @@ func TestMessangerApp(t *testing.T) { })) // add a tag to channel topic - params = &TestApiParams{ + params = &TestAPIParams{ restType: "POST", - query: "/content/channels/{channelId}/topics/{topicId}/tags", - path: map[string]string{ "channelId": channel.Id, "topicId": topic.Id }, + query: "/content/channels/{channelID}/topics/{topicID}/tags", + path: map[string]string{ "channelID": channel.ID, "topicID": topic.ID }, body: &Subject{ Data: "channeltopictagdataB", DataType: "channeltopictagdatatypeB", @@ -227,19 +227,19 @@ func TestMessangerApp(t *testing.T) { token: set.B.Token, } tag = &Tag{} - response = &TestApiResponse{ data: tag } - assert.NoError(t, TestApiRequest(AddChannelTopicTag, params, response)) + response = &TestAPIResponse{ data: tag } + assert.NoError(t, TestAPIRequest(AddChannelTopicTag, params, response)) // wait for test assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool{ 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 { - if testChannel.channel.Id == channel.Id { + if testChannel.channel.ID == channel.ID { for _, testTopic := range testChannel.topics { - if testTopic.topic.Id == topic.Id { + if testTopic.topic.ID == topic.ID { for _, testTag := range testTopic.tags { - if testTag.Id == tag.Id { + if testTag.ID == tag.ID { return true } } @@ -253,21 +253,21 @@ func TestMessangerApp(t *testing.T) { })) // unshare channel with A - params = &TestApiParams{ + params = &TestAPIParams{ restType: "DELETE", - query: "/content/channels/{channelId}/cards/{cardId}", - path: map[string]string{ "cardId": set.B.A.CardId, "channelId": channel.Id }, + query: "/content/channels/{channelID}/cards/{cardID}", + path: map[string]string{ "cardID": set.B.A.CardID, "channelID": channel.ID }, tokenType: APP_TOKENAGENT, token: set.B.Token, } - response = &TestApiResponse{} - assert.NoError(t, TestApiRequest(ClearChannelCard, params, response)) + response = &TestAPIResponse{} + assert.NoError(t, TestAPIRequest(ClearChannelCard, params, response)) // wait for test 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 { - _, channelSet := contact.channels[channel.Id] + _, channelSet := contact.channels[channel.ID] if !channelSet { return true } diff --git a/net/server/internal/ucProfileUpdate_test.go b/net/server/internal/ucProfileUpdate_test.go index 7b9bfcb5..230a3393 100644 --- a/net/server/internal/ucProfileUpdate_test.go +++ b/net/server/internal/ucProfileUpdate_test.go @@ -31,13 +31,13 @@ func TestProfileUpdate(t *testing.T) { // reset revision bCardRev = GetTestRevision(set.B.Revisions).Card cCardRev = GetTestRevision(set.C.Revisions).Card - param["cardId"] = set.B.A.CardId - assert.NoError(t, ApiTestMsg(GetCard, "GET", "/contact/cards/{cardId}", + param["cardID"] = set.B.A.CardID + assert.NoError(t, APITestMsg(GetCard, "GET", "/contact/cards/{cardID}", ¶m, nil, APP_TOKENAGENT, set.B.Token, &card, nil)) bProfileRev = card.Data.NotifiedProfile - param["cardId"] = set.C.A.CardId - assert.NoError(t, ApiTestMsg(GetCard, "GET", "/contact/cards/{cardId}", + param["cardID"] = set.C.A.CardID + assert.NoError(t, APITestMsg(GetCard, "GET", "/contact/cards/{cardID}", ¶m, nil, APP_TOKENAGENT, set.C.Token, &card, nil)) cProfileRev = card.Data.NotifiedProfile @@ -48,7 +48,7 @@ func TestProfileUpdate(t *testing.T) { Location: "San Diago", Description: "databaggerr", }; - assert.NoError(t, ApiTestMsg(SetProfile, "PUT", "/profile/data", + assert.NoError(t, APITestMsg(SetProfile, "PUT", "/profile/data", nil, profileData, APP_TOKENAGENT, set.A.Token, &profile, nil)) assert.Equal(t, "databaggerr", profile.Description) @@ -58,51 +58,51 @@ func TestProfileUpdate(t *testing.T) { assert.NotEqual(t, cCardRev, GetTestRevision(set.C.Revisions).Card) // check B notified - param["cardId"] = set.B.A.CardId - assert.NoError(t, ApiTestMsg(GetCard, "GET", "/contact/cards/{cardId}", + param["cardID"] = set.B.A.CardID + assert.NoError(t, APITestMsg(GetCard, "GET", "/contact/cards/{cardID}", ¶m, nil, APP_TOKENAGENT, set.B.Token, &card, nil)) assert.NotEqual(t, bProfileRev, card.Data.NotifiedProfile) assert.NotEqual(t, card.Data.ProfileRevision, card.Data.NotifiedProfile) // check C notified - param["cardId"] = set.C.A.CardId - assert.NoError(t, ApiTestMsg(GetCard, "GET", "/contact/cards/{cardId}", + param["cardID"] = set.C.A.CardID + assert.NoError(t, APITestMsg(GetCard, "GET", "/contact/cards/{cardID}", ¶m, nil, APP_TOKENAGENT, set.C.Token, &card, nil)) assert.NotEqual(t, cProfileRev, card.Data.NotifiedProfile) assert.NotEqual(t, card.Data.ProfileRevision, card.Data.NotifiedProfile) // 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)) - assert.NoError(t, ApiTestMsg(AddCard, "POST", "/contact/cards", + assert.NoError(t, APITestMsg(AddCard, "POST", "/contact/cards", nil, &msg, 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.CardProfile.Name, "Namer") // sync profile - assert.NoError(t, ApiTestMsg(GetProfileMessage, "GET", "/profile/message", + assert.NoError(t, APITestMsg(GetProfileMessage, "GET", "/profile/message", nil, 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, 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.CardProfile.Name, "Namer") // set profile image image := "iVBORw0KGgoAAAANSUhEUgAAAaQAAAGkCAIAAADxLsZiAAAFzElEQVR4nOzWUY3jMBhG0e0qSEqoaIqiaEIoGAxh3gZAldid3nMI+JOiXP3bGOMfwLf7v3oAwAxiBySIHZAgdkCC2AEJYgckiB2QIHZAgtgBCWIHJIgdkCB2QILYAQliBySIHZAgdkCC2AEJYgckiB2QIHZAgtgBCWIHJIgdkCB2QILYAQliBySIHZAgdkCC2AEJYgckiB2QIHZAgtgBCWIHJGzTXnrtx7S3pnk+7qsnnMk3+ny+0dtcdkCC2AEJYgckiB2QIHZAgtgBCWIHJIgdkCB2QILYAQliBySIHZAgdkCC2AEJYgckiB2QIHZAgtgBCWIHJIgdkCB2QILYAQliBySIHZAgdkCC2AEJYgckiB2QIHZAgtgBCWIHJIgdkCB2QILYAQliBySIHZAgdkCC2AEJYgckiB2QIHZAgtgBCWIHJIgdkCB2QILYAQliBySIHZAgdkCC2AEJYgckiB2QIHZAgtgBCWIHJIgdkCB2QILYAQliBySIHZAgdkCC2AEJYgckiB2QIHZAgtgBCWIHJIgdkCB2QILYAQnbtJeej/u0t+Bb+Y/e5rIDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSbmOM1RsALueyAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyAhG31gD/stR+rJ5zv+bivnnAm34hfLjsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBhWz2Az/Laj9UT4BIuOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgITbGGP1BoDLueyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7ICEnwAAAP//DQ4epwV6rzkAAAAASUVORK5CYII=" - 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)) // 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) assert.NoError(t, err) diff --git a/net/server/internal/ucStaggardLoad_test.go b/net/server/internal/ucStaggardLoad_test.go index 2fd1b86a..a8e4e2b6 100644 --- a/net/server/internal/ucStaggardLoad_test.go +++ b/net/server/internal/ucStaggardLoad_test.go @@ -7,8 +7,8 @@ import ( ) func TestStaggardLoad(t *testing.T) { - var params *TestApiParams - var response *TestApiResponse + var params *TestAPIParams + var response *TestAPIResponse var channel *Channel var topic *Topic var topics *[]Topic @@ -30,7 +30,7 @@ func TestStaggardLoad(t *testing.T) { })) // add a channel - params = &TestApiParams{ + params = &TestAPIParams{ restType: "POST", query: "/content/channels", body: &Subject{ @@ -41,13 +41,13 @@ func TestStaggardLoad(t *testing.T) { token: set.A.Token, } channel = &Channel{} - response = &TestApiResponse{ data: channel } - assert.NoError(t, TestApiRequest(AddChannel, params, response)) + response = &TestAPIResponse{ data: channel } + assert.NoError(t, TestAPIRequest(AddChannel, params, response)) // wait for test assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool{ for _, c := range testApp.channels { - if c.channel.Id == channel.Id { + if c.channel.ID == channel.ID { return true } } @@ -57,10 +57,10 @@ func TestStaggardLoad(t *testing.T) { // add a topic to channel ids := []string{} for i := 0; i < 128; i++ { - params = &TestApiParams{ + params = &TestAPIParams{ restType: "POST", - query: "/content/channels/{channelId}/topics", - path: map[string]string{ "channelId": channel.Id }, + query: "/content/channels/{channelID}/topics", + path: map[string]string{ "channelID": channel.ID }, body: &Subject{ Data: strconv.Itoa(i), DataType: "channeltopicdatatypeA", @@ -69,15 +69,15 @@ func TestStaggardLoad(t *testing.T) { token: set.A.Token, } topic = &Topic{} - response = &TestApiResponse{ data: topic } - assert.NoError(t, TestApiRequest(AddChannelTopic, params, response)) - ids = append(ids, topic.Id); + response = &TestAPIResponse{ data: topic } + assert.NoError(t, TestAPIRequest(AddChannelTopic, params, response)) + ids = append(ids, topic.ID); } // wait for test assert.NoError(t, app.WaitFor(func(testApp *TestApp)bool{ for _, c := range testApp.channels { - if c.channel.Id == channel.Id { + if c.channel.ID == channel.ID { if len(c.topics) == 128 { return true } @@ -86,90 +86,90 @@ func TestStaggardLoad(t *testing.T) { return false })) - params = &TestApiParams { + params = &TestAPIParams { restType: "GET", - query: "/content/channels/{channelId}/topics", - path: map[string]string{ "channelId": channel.Id, "topicId": topic.Id }, + query: "/content/channels/{channelID}/topics", + path: map[string]string{ "channelID": channel.ID, "topicID": topic.ID }, tokenType: APP_TOKENAGENT, token: set.A.Token, } topics = &[]Topic{} - response = &TestApiResponse{ data: topics } - assert.NoError(t, TestApiRequest(GetChannelTopics, params, response)); + response = &TestAPIResponse{ data: topics } + assert.NoError(t, TestAPIRequest(GetChannelTopics, params, response)); assert.Equal(t, len(*topics), 128); - params = &TestApiParams { + params = &TestAPIParams { restType: "GET", - query: "/content/channels/{channelId}/topics?count=13", - path: map[string]string{ "channelId": channel.Id, "topicId": topic.Id }, + query: "/content/channels/{channelID}/topics?count=13", + path: map[string]string{ "channelID": channel.ID, "topicID": topic.ID }, tokenType: APP_TOKENAGENT, token: set.A.Token, } topics = &[]Topic{} - response = &TestApiResponse{ data: topics } - assert.NoError(t, TestApiRequest(GetChannelTopics, params, response)); + response = &TestAPIResponse{ data: topics } + assert.NoError(t, TestAPIRequest(GetChannelTopics, params, response)); assert.Equal(t, len(*topics), 13); //marker, _ := strconv.Atoi(response.header["Topic-Marker"][0]) //revision, _ := strconv.Atoi(response.header["Topic-Revision"][0]) - params = &TestApiParams { + params = &TestAPIParams { restType: "GET", - query: "/content/channels/{channelId}/topics?count=13&end=" + response.header["Topic-Marker"][0], - path: map[string]string{ "channelId": channel.Id, "topicId": topic.Id }, + query: "/content/channels/{channelID}/topics?count=13&end=" + response.header["Topic-Marker"][0], + path: map[string]string{ "channelID": channel.ID, "topicID": topic.ID }, tokenType: APP_TOKENAGENT, token: set.A.Token, } topics = &[]Topic{} - response = &TestApiResponse{ data: topics } - assert.NoError(t, TestApiRequest(GetChannelTopics, params, response)); + response = &TestAPIResponse{ data: topics } + assert.NoError(t, TestAPIRequest(GetChannelTopics, params, response)); assert.Equal(t, len(*topics), 13); marker := response.header["Topic-Marker"][0] revision := response.header["Topic-Revision"][0] - params = &TestApiParams { + params = &TestAPIParams { restType: "DELETE", - query: "/content/channels/{channelId}/topics/{topicId}", - path: map[string]string{ "channelId": channel.Id, "topicId": ids[13] }, + query: "/content/channels/{channelID}/topics/{topicID}", + path: map[string]string{ "channelID": channel.ID, "topicID": ids[13] }, tokenType: APP_TOKENAGENT, token: set.A.Token, } - response = &TestApiResponse{ } - assert.NoError(t, TestApiRequest(RemoveChannelTopic, params, response)); + response = &TestAPIResponse{ } + assert.NoError(t, TestAPIRequest(RemoveChannelTopic, params, response)); - params = &TestApiParams { + params = &TestAPIParams { restType: "GET", - query: "/content/channels/{channelId}/topics?begin=" + marker + "&revision=" + revision, - path: map[string]string{ "channelId": channel.Id, "topicId": topic.Id }, + query: "/content/channels/{channelID}/topics?begin=" + marker + "&revision=" + revision, + path: map[string]string{ "channelID": channel.ID, "topicID": topic.ID }, tokenType: APP_TOKENAGENT, token: set.A.Token, } topics = &[]Topic{} - response = &TestApiResponse{ data: topics } - assert.NoError(t, TestApiRequest(GetChannelTopics, params, response)); + response = &TestAPIResponse{ data: topics } + assert.NoError(t, TestAPIRequest(GetChannelTopics, params, response)); assert.Equal(t, 0, len(*topics)); - params = &TestApiParams { + params = &TestAPIParams { restType: "DELETE", - query: "/content/channels/{channelId}/topics/{topicId}", - path: map[string]string{ "channelId": channel.Id, "topicId": ids[108] }, + query: "/content/channels/{channelID}/topics/{topicID}", + path: map[string]string{ "channelID": channel.ID, "topicID": ids[108] }, tokenType: APP_TOKENAGENT, token: set.A.Token, } - response = &TestApiResponse{ } - assert.NoError(t, TestApiRequest(RemoveChannelTopic, params, response)); + response = &TestAPIResponse{ } + assert.NoError(t, TestAPIRequest(RemoveChannelTopic, params, response)); - params = &TestApiParams { + params = &TestAPIParams { restType: "GET", - query: "/content/channels/{channelId}/topics?begin=" + marker + "&revision=" + revision, - path: map[string]string{ "channelId": channel.Id, "topicId": topic.Id }, + query: "/content/channels/{channelID}/topics?begin=" + marker + "&revision=" + revision, + path: map[string]string{ "channelID": channel.ID, "topicID": topic.ID }, tokenType: APP_TOKENAGENT, token: set.A.Token, } topics = &[]Topic{} - response = &TestApiResponse{ data: topics } - assert.NoError(t, TestApiRequest(GetChannelTopics, params, response)); + response = &TestAPIResponse{ data: topics } + assert.NoError(t, TestAPIRequest(GetChannelTopics, params, response)); assert.Equal(t, 1, len(*topics)); } diff --git a/net/server/internal/ucTopicShare_test.go b/net/server/internal/ucTopicShare_test.go index ca6b2560..6b862457 100644 --- a/net/server/internal/ucTopicShare_test.go +++ b/net/server/internal/ucTopicShare_test.go @@ -28,46 +28,46 @@ func TestTopicShare(t *testing.T) { // add new channel channel = &Channel{} 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)) image := "iVBORw0KGgoAAAANSUhEUgAAAaQAAAGkCAIAAADxLsZiAAAFzElEQVR4nOzWUY3jMBhG0e0qSEqoaIqiaEIoGAxh3gZAldid3nMI+JOiXP3bGOMfwLf7v3oAwAxiBySIHZAgdkCC2AEJYgckiB2QIHZAgtgBCWIHJIgdkCB2QILYAQliBySIHZAgdkCC2AEJYgckiB2QIHZAgtgBCWIHJIgdkCB2QILYAQliBySIHZAgdkCC2AEJYgckiB2QIHZAgtgBCWIHJGzTXnrtx7S3pnk+7qsnnMk3+ny+0dtcdkCC2AEJYgckiB2QIHZAgtgBCWIHJIgdkCB2QILYAQliBySIHZAgdkCC2AEJYgckiB2QIHZAgtgBCWIHJIgdkCB2QILYAQliBySIHZAgdkCC2AEJYgckiB2QIHZAgtgBCWIHJIgdkCB2QILYAQliBySIHZAgdkCC2AEJYgckiB2QIHZAgtgBCWIHJIgdkCB2QILYAQliBySIHZAgdkCC2AEJYgckiB2QIHZAgtgBCWIHJIgdkCB2QILYAQliBySIHZAgdkCC2AEJYgckiB2QIHZAgtgBCWIHJIgdkCB2QILYAQnbtJeej/u0t+Bb+Y/e5rIDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSbmOM1RsALueyAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyAhG31gD/stR+rJ5zv+bivnnAm34hfLjsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBhWz2Az/Laj9UT4BIuOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgITbGGP1BoDLueyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7IAEsQMSxA5IEDsgQeyABLEDEsQOSBA7IEHsgASxAxLEDkgQOyBB7ICEnwAAAP//DQ4epwV6rzkAAAAASUVORK5CYII=" img, _ := base64.StdEncoding.DecodeString(image) subject = &Subject{ Data: "{ \"nested\" : { \"image\" : \"" + image + "\" } }", DataType: "nestedimage" } - params["channelId"] = channel.Id - assert.NoError(t, ApiTestMsg(SetChannelSubject, "PUT", "/content/channels/{channelId}/subject", + params["channelID"] = channel.ID + assert.NoError(t, APITestMsg(SetChannelSubject, "PUT", "/content/channels/{channelID}/subject", ¶ms, subject, APP_TOKENAGENT, set.A.Token, channel, nil)) - params["cardId"] = set.A.B.CardId - assert.NoError(t, ApiTestMsg(SetChannelCard, "PUT", "/content/channels/{channelId}/cards/{cardId}", + params["cardID"] = set.A.B.CardID + assert.NoError(t, APITestMsg(SetChannelCard, "PUT", "/content/channels/{channelID}/cards/{cardID}", ¶ms, nil, APP_TOKENAGENT, set.A.Token, nil, nil)) - params["cardId"] = set.A.C.CardId - assert.NoError(t, ApiTestMsg(SetChannelCard, "PUT", "/content/channels/{channelId}/cards/{cardId}", + params["cardID"] = set.A.C.CardID + assert.NoError(t, APITestMsg(SetChannelCard, "PUT", "/content/channels/{channelID}/cards/{cardID}", ¶ms, nil, APP_TOKENAGENT, set.A.Token, nil, nil)) // view channel detail = &ChannelDetail{} - assert.NoError(t, ApiTestMsg(GetChannelDetail, "GET", "/content/channels/{channelId}/detail", + assert.NoError(t, APITestMsg(GetChannelDetail, "GET", "/content/channels/{channelID}/detail", ¶ms, nil, APP_TOKENAGENT, set.A.Token, detail, nil)) assert.NotNil(t, detail); detail = &ChannelDetail{} - assert.NoError(t, ApiTestMsg(GetChannelDetail, "GET", "/content/channels/{channelId}/detail", + assert.NoError(t, APITestMsg(GetChannelDetail, "GET", "/content/channels/{channelID}/detail", ¶ms, nil, APP_TOKENCONTACT, set.B.A.Token, detail, nil)) assert.NotNil(t, channel.Data.ChannelDetail); detail = &ChannelDetail{} - assert.NoError(t, ApiTestMsg(GetChannelDetail, "GET", "/content/channels/{channelId}/detail", + assert.NoError(t, APITestMsg(GetChannelDetail, "GET", "/content/channels/{channelID}/detail", ¶ms, nil, APP_TOKENCONTACT, set.B.A.Token, detail, nil)) assert.NotNil(t, channel.Data.ChannelDetail); 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}", ¶ms, nil, APP_TOKENAGENT, set.A.Token, 0, 0) assert.NoError(t, err) assert.Equal(t, "image/png", header["Content-Type"][0]) 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}", ¶ms, nil, APP_TOKENCONTACT, set.B.A.Token, 0, 0) assert.NoError(t, err) assert.Equal(t, "image/png", header["Content-Type"][0]) 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}", ¶ms, nil, APP_TOKENCONTACT, set.C.A.Token, 0, 0) assert.NoError(t, err) assert.Equal(t, "image/png", header["Content-Type"][0]) @@ -77,31 +77,31 @@ func TestTopicShare(t *testing.T) { // add a topc topic = &Topic{} 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", ¶ms, subject, APP_TOKENAGENT, set.A.Token, topic, nil)) topic = &Topic{} 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", ¶ms, subject, APP_TOKENCONTACT, set.B.A.Token, topic, nil)) - params["topicId"] = topic.Id - assert.NoError(t, ApiTestMsg(SetChannelTopicConfirmed, "PUT", "/content/channels/{channelId}/topics/{topicId}/confirmed", + params["topicID"] = topic.ID + assert.NoError(t, APITestMsg(SetChannelTopicConfirmed, "PUT", "/content/channels/{channelID}/topics/{topicID}/confirmed", ¶ms, APP_TOPICCONFIRMED, APP_TOKENCONTACT, set.B.A.Token, nil, nil)) topic = &Topic{} 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", ¶ms, subject, APP_TOKENCONTACT, set.C.A.Token, topic, nil)) // add asset to topic assets := []Asset{} - params["topicId"] = topic.Id + params["topicID"] = topic.ID transforms, err := json.Marshal([]string{ "copy;photo" }) 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)), ¶ms, img, APP_TOKENCONTACT, set.C.A.Token, &assets, nil)) // view topics topics := &[]Topic{} - assert.NoError(t, ApiTestMsg(GetChannelTopics, "GET", "/content/channels/{channelId}/topics", + assert.NoError(t, APITestMsg(GetChannelTopics, "GET", "/content/channels/{channelID}/topics", ¶ms, nil, APP_TOKENAGENT, set.A.Token, topics, nil)) aRev = GetTestRevision(set.A.Revisions) @@ -110,7 +110,7 @@ func TestTopicShare(t *testing.T) { // add a tag to topic tag := Tag{} 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}", ¶ms, subject, APP_TOKENAGENT, set.A.Token, &tag, nil)) assert.NotEqual(t, aRev.Channel, GetTestRevision(set.A.Revisions).Channel) @@ -118,56 +118,56 @@ func TestTopicShare(t *testing.T) { // get tags for topic tags := &[]Tag{} - assert.NoError(t, ApiTestMsg(GetChannelTopicTags, "GET", "/content/channels/{channelId}/topics/{topicId}", + assert.NoError(t, APITestMsg(GetChannelTopicTags, "GET", "/content/channels/{channelID}/topics/{topicID}", ¶ms, nil, APP_TOKENCONTACT, set.C.A.Token, tags, nil)) assert.Equal(t, 1, len(*tags)) // delete topic tag - params["tagId"] = tag.Id - assert.NoError(t, ApiTestMsg(RemoveChannelTopicTag, "DELETE", "/content/channels/{channelId}/topics/{topicId}/tags/{tagId}", + params["tagID"] = tag.ID + assert.NoError(t, APITestMsg(RemoveChannelTopicTag, "DELETE", "/content/channels/{channelID}/topics/{topicID}/tags/{tagID}", ¶ms, nil, APP_TOKENAGENT, set.A.Token, nil, nil)) // get tags for topic tags = &[]Tag{} - assert.NoError(t, ApiTestMsg(GetChannelTopicTags, "GET", "/content/channels/{channelId}/topics/{topicId}", + assert.NoError(t, APITestMsg(GetChannelTopicTags, "GET", "/content/channels/{channelID}/topics/{topicID}", ¶ms, nil, APP_TOKENCONTACT, set.C.A.Token, tags, nil)) assert.Equal(t, 0, len(*tags)) // get list of assets assets = []Asset{} - assert.NoError(t, ApiTestMsg(GetChannelTopicAssets, "GET", "/content/channels/{channelId}/topics/{topicId}", + assert.NoError(t, APITestMsg(GetChannelTopicAssets, "GET", "/content/channels/{channelID}/topics/{topicID}", ¶ms, nil, APP_TOKENCONTACT, set.C.A.Token, &assets, nil)) assert.Equal(t, 2, len(assets)) // delete each asset for _, asset := range assets { - params["assetId"] = asset.AssetId - assert.NoError(t, ApiTestMsg(RemoveChannelTopicAsset, "DELETE", "/content/channels/{channelId}/topics/{topicId}/assets/{assetId}", + params["assetID"] = asset.AssetID + assert.NoError(t, APITestMsg(RemoveChannelTopicAsset, "DELETE", "/content/channels/{channelID}/topics/{topicID}/assets/{assetID}", ¶ms, nil, APP_TOKENCONTACT, set.C.A.Token, nil, nil)) } // get list of assets assets = []Asset{} - assert.NoError(t, ApiTestMsg(GetChannelTopicAssets, "GET", "/content/channels/{channelId}/topics/{topicId}", + assert.NoError(t, APITestMsg(GetChannelTopicAssets, "GET", "/content/channels/{channelID}/topics/{topicID}", ¶ms, nil, APP_TOKENCONTACT, set.C.A.Token, &assets, nil)) assert.Equal(t, 0, len(assets)) // add asset to topic assets = []Asset{} - params["topicId"] = topic.Id + params["topicID"] = topic.ID transforms, err = json.Marshal([]string{ "copy;photo" }) 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)), ¶ms, img, APP_TOKENCONTACT, set.C.A.Token, &assets, nil)) // add a tag to topic tag = Tag{} 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}", ¶ms, subject, APP_TOKENAGENT, set.A.Token, &tag, nil)) // remove channel - assert.NoError(t, ApiTestMsg(RemoveChannel, "DELETE", "/content/channels/{channelId}", + assert.NoError(t, APITestMsg(RemoveChannel, "DELETE", "/content/channels/{channelID}", ¶ms, nil, APP_TOKENAGENT, set.A.Token, nil, nil)) }