Skip to content

Commit bfaff61

Browse files
committed
🎨 推送失败判断
1 parent 4abef7b commit bfaff61

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

‎cron/pushcron.go‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,11 @@ func pushArticles() {
7171
},
7272
}
7373
result := &map[string]interface{}{}
74-
gorequest.New().Post("https://rhythm.b3log.org/api/article").SendMap(requestJSON).
74+
_, _, errs := gorequest.New().Post("https://rhythm.b3log.org/api/article").SendMap(requestJSON).
7575
Set("user-agent", util.UserAgent).Timeout(30 * time.Second).EndStruct(result)
76-
logger.Tracef("%+v", result)
76+
if nil != errs && time.Duration(7*24*time.Hour) > article.UpdatedAt.Sub(article.PushedAt) {
77+
continue
78+
}
7779

7880
article.PushedAt = article.UpdatedAt
7981
service.Article.UpdatePushedAt(article)
@@ -124,9 +126,11 @@ func pushComments() {
124126
},
125127
}
126128
result := &map[string]interface{}{}
127-
gorequest.New().Post("https://rhythm.b3log.org/api/comment").SendMap(requestJSON).
129+
_, _, errs := gorequest.New().Post("https://rhythm.b3log.org/api/comment").SendMap(requestJSON).
128130
Set("user-agent", util.UserAgent).Timeout(30 * time.Second).EndStruct(result)
129-
logger.Tracef("%+v", result)
131+
if nil != errs && time.Duration(7*24*time.Hour) > comment.UpdatedAt.Sub(comment.PushedAt) {
132+
continue
133+
}
130134

131135
comment.PushedAt = comment.UpdatedAt
132136
service.Comment.UpdatePushedAt(comment)

0 commit comments

Comments
 (0)