diff options
Diffstat (limited to 'src/main/java/com/juick/server/XMPPManager.java')
-rw-r--r-- | src/main/java/com/juick/server/XMPPManager.java | 39 |
1 files changed, 17 insertions, 22 deletions
diff --git a/src/main/java/com/juick/server/XMPPManager.java b/src/main/java/com/juick/server/XMPPManager.java index a41e6053..a0390507 100644 --- a/src/main/java/com/juick/server/XMPPManager.java +++ b/src/main/java/com/juick/server/XMPPManager.java @@ -20,6 +20,7 @@ package com.juick.server; import com.juick.User; import com.juick.formatters.PlainTextFormatter; import com.juick.model.CommandResult; +import com.juick.server.api.SystemActivity; import com.juick.server.www.WebApp; import com.juick.server.xmpp.iq.MessageQuery; import com.juick.service.MessagesService; @@ -337,9 +338,20 @@ public class XMPPManager implements NotificationListener { } @Override - public void processMessageEvent(MessageEvent event) { - com.juick.Message msg = event.getMessage(); - List<User> subscribers = event.getUsers(); + public void processSystemEvent(SystemEvent systemEvent) { + var activity = systemEvent.getActivity(); + var type = activity.getType(); + if (type.equals(SystemActivity.ActivityType.message)) { + processMessage(activity.getMessage(), activity.getTo()); + } else if (type.equals(SystemActivity.ActivityType.like)) { + if (systemEvent.getActivity().getFrom().equals(serviceUser)) { + processTop(systemEvent.getActivity().getMessage()); + } else { + processLike(activity.getFrom(), activity.getMessage(), activity.getTo()); + } + } + } + private void processMessage(com.juick.Message msg, List<User> subscribers) { if (msg.isService()) { return; } @@ -376,17 +388,7 @@ public class XMPPManager implements NotificationListener { return ClientMessage.from(reply); } - @Override - public void processSubscribeEvent(SubscribeEvent subscribeEvent) { - - } - - @Override - public void processLikeEvent(LikeEvent likeEvent) { - List<User> users = likeEvent.getSubscribers(); - com.juick.Message jmsg = likeEvent.getMessage(); - User liker = likeEvent.getUser(); - + public void processLike(User liker, com.juick.Message jmsg, List<User> users) { if (!userService.isInBLAny(jmsg.getUser().getUid(), liker.getUid())) { userService.getJIDsbyUID(jmsg.getUser().getUid()).forEach(authorJid -> { Message xmppMessage = new Message(); @@ -454,14 +456,7 @@ public class XMPPManager implements NotificationListener { }); } - @Override - public void processMessageReadEvent(MessageReadEvent messageReadEvent) { - - } - - @Override - public void processTopEvent(TopEvent topEvent) { - com.juick.Message message = topEvent.getMessage(); + public void processTop(com.juick.Message message) { try { commandsManager.processCommand(serviceUser, String.format("! #%d", message.getMid()), URI.create(StringUtils.EMPTY)); } catch (Exception e) { |