From eff8279ce447c2c4f988ebafb5495eb4f40d7e0f Mon Sep 17 00:00:00 2001 From: Roland Osborne Date: Mon, 21 Feb 2022 15:00:26 -0800 Subject: [PATCH] syncing articles --- net/server/internal/testApp.go | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/net/server/internal/testApp.go b/net/server/internal/testApp.go index cf808030..b89efbd1 100644 --- a/net/server/internal/testApp.go +++ b/net/server/internal/testApp.go @@ -3,6 +3,7 @@ package databag import ( "time" "errors" + "strconv" "sync" "encoding/json" "net/http" @@ -62,7 +63,28 @@ func (a *TestApp) UpdateProfile() (err error) { } func (a *TestApp) UpdateArticle() (err error) { - PrintMsg("update article") + var articles []Article + if a.revision.Article == 0 { + params := &TestApiParams{ query: "/articles", tokenType: APP_TOKENAPP, 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?revision=" + revision, tokenType: APP_TOKENAPP, 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) + } else { + a.articles[article.Id] = article + } + } return }