aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src
diff options
context:
space:
mode:
Diffstat (limited to 'juick-server/src')
-rw-r--r--juick-server/src/main/java/com/juick/server/TopManager.java29
1 files changed, 17 insertions, 12 deletions
diff --git a/juick-server/src/main/java/com/juick/server/TopManager.java b/juick-server/src/main/java/com/juick/server/TopManager.java
index 0f2373b4..918e5ace 100644
--- a/juick-server/src/main/java/com/juick/server/TopManager.java
+++ b/juick-server/src/main/java/com/juick/server/TopManager.java
@@ -18,6 +18,7 @@
package com.juick.server;
import com.juick.Message;
+import com.juick.Tag;
import com.juick.User;
import com.juick.service.MessagesService;
import com.juick.service.UserService;
@@ -33,6 +34,8 @@ import org.springframework.web.client.HttpClientErrorException;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
+import java.util.List;
+import java.util.stream.Collectors;
@Component
public class TopManager {
@@ -59,21 +62,23 @@ public class TopManager {
@Scheduled(fixedRate = 3600000)
public void updateTop() {
messagesService.getPopularCandidates().forEach(m -> {
+ Message jmsg = messagesService.getMessage(m);
logger.info("added {} to popular", m);
messagesService.setMessagePopular(m, 1);
- Message jmsg = messagesService.getMessage(m);
- String status = MessageUtils.getMessageHashTags(jmsg) + StringUtils.defaultString(jmsg.getText());
- String link = "https://juick.com/" + jmsg.getMid();
- try {
- facebookPageManager.post(status, link);
- } catch (HttpClientErrorException ex) {
- HttpStatus statusCode = ex.getStatusCode();
- String responseString = ex.getResponseBodyAsString();
- logger.warn("facebook error {}: {}", statusCode.value(), responseString);
+ List<String> tags = jmsg.getTags().stream().map(Tag::getName).map(String::toLowerCase).collect(Collectors.toList());
+ if (!tags.contains("juick")) {
+ String status = MessageUtils.getMessageHashTags(jmsg) + StringUtils.defaultString(jmsg.getText());
+ String link = "https://juick.com/" + jmsg.getMid();
+ try {
+ facebookPageManager.post(status, link);
+ } catch (HttpClientErrorException ex) {
+ HttpStatus statusCode = ex.getStatusCode();
+ String responseString = ex.getResponseBodyAsString();
+ logger.warn("facebook error {}: {}", statusCode.value(), responseString);
+ }
+ jmsg.setUser(serviceUser);
+ crosspostManager.twitterPost(jmsg);
}
- jmsg.setUser(serviceUser);
- crosspostManager.twitterPost(jmsg);
-
});
}
}