diff options
author | Vitaly Takmazov | 2019-09-02 23:46:32 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2019-09-02 23:46:32 +0300 |
commit | 90bb1f4e864bc104a50bf43b207df9ad40cd1dc9 (patch) | |
tree | a1923db995aae45fc567ee4943590829c4b7ce12 /src | |
parent | 29461cff6d0135544fbffae3104e50e3ebab2ba1 (diff) |
Do not send likes from service user
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/com/juick/server/TelegramBotManager.java | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/main/java/com/juick/server/TelegramBotManager.java b/src/main/java/com/juick/server/TelegramBotManager.java index 66362c19..9e53fbe1 100644 --- a/src/main/java/com/juick/server/TelegramBotManager.java +++ b/src/main/java/com/juick/server/TelegramBotManager.java @@ -96,6 +96,8 @@ public class TelegramBotManager implements NotificationListener { private ApplicationEventPublisher applicationEventPublisher; @Value("${upload_tmp_dir:#{systemEnvironment['TEMP'] ?: '/tmp'}}") private String tmpDir; + @Value("${service_user:juick}") + private String serviceUser; private static final String MSG_LINK = "🔗"; @@ -423,17 +425,19 @@ public class TelegramBotManager implements NotificationListener { @Override public void processLikeEvent(LikeEvent likeEvent) { User liker = likeEvent.getUser(); - com.juick.Message message = likeEvent.getMessage(); - List<User> subscribers = likeEvent.getSubscribers(); - logger.info("Like received in tg listener"); - if (!userService.isInBLAny(message.getUser().getUid(), liker.getUid())) { - telegramService.getTelegramIdentifiers(Collections.singletonList(message.getUser())) - .forEach(c -> telegramNotify(c, String.format("%s recommends your [post](%s)", + if (!liker.getName().equals(serviceUser)) { + com.juick.Message message = likeEvent.getMessage(); + List<User> subscribers = likeEvent.getSubscribers(); + logger.info("Like received in tg listener"); + if (!userService.isInBLAny(message.getUser().getUid(), liker.getUid())) { + telegramService.getTelegramIdentifiers(Collections.singletonList(message.getUser())) + .forEach(c -> telegramNotify(c, String.format("%s recommends your [post](%s)", + MessageUtils.getMarkdownUser(liker), formatUrl(message)), new com.juick.Message())); + } + telegramService.getTelegramIdentifiers(subscribers) + .forEach(c -> telegramNotify(c, String.format("%s recommends you someone's [post](%s)", MessageUtils.getMarkdownUser(liker), formatUrl(message)), new com.juick.Message())); } - telegramService.getTelegramIdentifiers(subscribers) - .forEach(c -> telegramNotify(c, String.format("%s recommends you someone's [post](%s)", - MessageUtils.getMarkdownUser(liker), formatUrl(message)), new com.juick.Message())); } @Override |