From 771a95b92bf589e8462b5cb9eb8e02bf7bf5bb63 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 8 Apr 2022 15:06:01 +0300 Subject: XMPP: log invalid JIDs --- src/main/java/com/juick/XMPPManager.java | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/juick/XMPPManager.java b/src/main/java/com/juick/XMPPManager.java index a7146352..6343378c 100644 --- a/src/main/java/com/juick/XMPPManager.java +++ b/src/main/java/com/juick/XMPPManager.java @@ -382,14 +382,19 @@ public class XMPPManager implements NotificationListener { public void processLike(User liker, com.juick.model.Message jmsg, List users) { if (!userService.isInBLAny(jmsg.getUser().getUid(), liker.getUid())) { userService.getJIDsbyUID(jmsg.getUser().getUid()).forEach(authorJid -> { - Message xmppMessage = new Message(); - xmppMessage.setFrom(jid); - xmppMessage.setTo(Jid.of(authorJid)); - xmppMessage.setType(Message.Type.CHAT); - xmppMessage.addExtension(jmsg); - xmppMessage.setBody(String.format("%s recommended your post #%d. %s", - liker.getName(), jmsg.getMid(), PlainTextFormatter.formatUrl(jmsg))); - xmpp.send(ClientMessage.from(xmppMessage)); + try { + Jid toJid = Jid.of(authorJid); + Message xmppMessage = new Message(); + xmppMessage.setFrom(jid); + xmppMessage.setTo(toJid); + xmppMessage.setType(Message.Type.CHAT); + xmppMessage.addExtension(jmsg); + xmppMessage.setBody(String.format("%s recommended your post #%d. %s", + liker.getName(), jmsg.getMid(), PlainTextFormatter.formatUrl(jmsg))); + xmpp.send(ClientMessage.from(xmppMessage)); + } catch (IllegalArgumentException e) { + logger.warn("{}: {}", authorJid, e.getMessage()); + } }); } -- cgit v1.2.3