From 71c29cc99d1b3f71247b81bc42d30f8b52dad240 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 4 Apr 2018 22:20:52 +0300 Subject: server: PMs in email * also introduces MessageUtils.isReply and MessageUtils.isPM --- .../src/main/java/com/juick/components/Notifications.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'juick-notifications/src/main/java/com/juick/components') diff --git a/juick-notifications/src/main/java/com/juick/components/Notifications.java b/juick-notifications/src/main/java/com/juick/components/Notifications.java index a43d985c..410debd4 100644 --- a/juick-notifications/src/main/java/com/juick/components/Notifications.java +++ b/juick-notifications/src/main/java/com/juick/components/Notifications.java @@ -81,18 +81,16 @@ public class Notifications implements NotificationClientListener, AutoCloseable, @Override public void onApplicationEvent(@Nonnull MessageEvent event) { com.juick.Message jmsg = event.getMessage(); - boolean isPM = jmsg.getMid() == 0; - boolean isReply = jmsg.getRid() > 0; User pmTo = jmsg.getTo(); final List users = new ArrayList<>(); - if (isPM) { + if (MessageUtils.isPM(jmsg)) { users.addAll(rest.exchange(String.format("http://api.juick.com/notifications?uid=%d", pmTo.getUid()), HttpMethod.GET, null, new ParameterizedTypeReference>() { }).getBody()); } else { - if (isReply) { + if (MessageUtils.isReply(jmsg)) { users.addAll(rest.exchange(String.format("http://api.juick.com/notifications?uid=%d&mid=%d&rid=%d", jmsg.getUser().getUid(), jmsg.getMid(), jmsg.getRid()), HttpMethod.GET, null, new ParameterizedTypeReference>() { -- cgit v1.2.3