aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/server/TwitterManager.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/juick/server/TwitterManager.java')
-rw-r--r--src/main/java/com/juick/server/TwitterManager.java44
1 files changed, 18 insertions, 26 deletions
diff --git a/src/main/java/com/juick/server/TwitterManager.java b/src/main/java/com/juick/server/TwitterManager.java
index d799bb17..0cb247fe 100644
--- a/src/main/java/com/juick/server/TwitterManager.java
+++ b/src/main/java/com/juick/server/TwitterManager.java
@@ -18,6 +18,7 @@ package com.juick.server;
import com.juick.Message;
import com.juick.User;
+import com.juick.server.api.SystemActivity;
import com.juick.service.UserService;
import com.juick.service.component.*;
import com.juick.service.CrosspostService;
@@ -85,41 +86,32 @@ public class TwitterManager implements NotificationListener {
}
@Override
- public void processMessageEvent(MessageEvent messageEvent) {
- Message msg = messageEvent.getMessage();
- if (MessageUtils.isPM(msg) || MessageUtils.isReply(msg) || msg.isService()) {
- return;
- }
- if (StringUtils.isNotEmpty(crosspostService.getTwitterName(msg.getUser().getUid()))) {
- if (msg.getTags().stream().noneMatch(t -> t.getName().equals("notwitter"))) {
- twitterPost(msg);
+ public void processSystemEvent(SystemEvent systemEvent) {
+ var activity = systemEvent.getActivity();
+ var msg = activity.getMessage();
+ if (activity.getType().equals(SystemActivity.ActivityType.message)) {
+ if (MessageUtils.isPM(msg) || MessageUtils.isReply(msg) || msg.isService()) {
+ return;
+ }
+ if (StringUtils.isNotEmpty(crosspostService.getTwitterName(msg.getUser().getUid()))) {
+ if (msg.getTags().stream().noneMatch(t -> t.getName().equals("notwitter"))) {
+ twitterPost(msg);
+ }
+ }
+ } else if (activity.getType().equals(SystemActivity.ActivityType.like)) {
+ if (activity.getFrom().getName().equals(serviceUsername)) {
+ processTop(msg);
}
}
}
@Override
- public void processSubscribeEvent(SubscribeEvent subscribeEvent) {
-
- }
-
- @Override
- public void processLikeEvent(LikeEvent likeEvent) {
-
- }
-
- @Override
public void processPingEvent(PingEvent pingEvent) {
}
- @Override
- public void processMessageReadEvent(MessageReadEvent messageReadEvent) {
-
- }
-
- @Override
- public void processTopEvent(TopEvent topEvent) {
- Message jmsg = SerializationUtils.clone(topEvent.getMessage());
+ private void processTop(com.juick.Message message) {
+ Message jmsg = SerializationUtils.clone(message);
jmsg.setUser(serviceUser);
twitterPost(jmsg);
}