mirror of
https://github.com/balzack/databag.git
synced 2025-02-14 20:49:16 +00:00
syncing articles
This commit is contained in:
parent
15c1e44b24
commit
eff8279ce4
@ -3,6 +3,7 @@ package databag
|
|||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
"errors"
|
"errors"
|
||||||
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -62,7 +63,28 @@ func (a *TestApp) UpdateProfile() (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *TestApp) UpdateArticle() (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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user