From dfa030a3765c5b5e43e263234155d344f5c6186e Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 24 May 2024 14:29:55 +0300 Subject: Do not allow unverified users to comment messages --- src/main/assets/scripts.js | 2 +- src/main/java/com/juick/CommandsManager.java | 5 ++++- src/main/java/com/juick/model/User.java | 2 +- src/main/java/com/juick/service/TelegramService.java | 2 ++ 4 files changed, 8 insertions(+), 3 deletions(-) (limited to 'src/main') diff --git a/src/main/assets/scripts.js b/src/main/assets/scripts.js index 3c83bba4..38406c2a 100644 --- a/src/main/assets/scripts.js +++ b/src/main/assets/scripts.js @@ -315,10 +315,10 @@ function showCommentForm(mid, rid) { .then(result => { if (result.newMessage) { window.location.hash = `#${result.newMessage.rid}` + window.location.reload() } else { alert(result.text) } - window.location.reload() }).catch(error => { alert(error.message) }) diff --git a/src/main/java/com/juick/CommandsManager.java b/src/main/java/com/juick/CommandsManager.java index d389deaa..a0f6e5e5 100644 --- a/src/main/java/com/juick/CommandsManager.java +++ b/src/main/java/com/juick/CommandsManager.java @@ -545,7 +545,7 @@ public class CommandsManager { } } Pair> messageTags = tagService.fromString(txt); - if (user.getUid() == msg.get().getUser().getUid() && rid == 0 && messageTags.getRight().size() > 0) { + if (user.getUid() == msg.get().getUser().getUid() && rid == 0 && !messageTags.getRight().isEmpty()) { var updatedTags = tagService.updateTags(mid, messageTags.getRight()); if (!CollectionUtils.isEqualCollection(updatedTags, msg.get().getTags())) { messagesService.setReadOnly(msg.get().getMid(), TagUtils.hasTag(updatedTags, "readonly")); @@ -554,6 +554,9 @@ public class CommandsManager { return CommandResult.fromString("Tags are NOT updated (5 tags maximum?)"); } } else { + if (!user.isVerified()) { + return CommandResult.fromString("Please, verify your account at https://juick.com/settings"); + } if (!messagesService.canViewThread(mid, user.getUid())) { return CommandResult.fromString("Message unavailable"); } diff --git a/src/main/java/com/juick/model/User.java b/src/main/java/com/juick/model/User.java index 438b208f..7b0b7099 100644 --- a/src/main/java/com/juick/model/User.java +++ b/src/main/java/com/juick/model/User.java @@ -241,7 +241,7 @@ public class User implements Serializable { @XmlTransient public boolean isVerified() { - return verified; + return verified || !uri.toString().isEmpty(); } public void setVerified(boolean verified) { diff --git a/src/main/java/com/juick/service/TelegramService.java b/src/main/java/com/juick/service/TelegramService.java index 16ba531d..71c9b9e3 100644 --- a/src/main/java/com/juick/service/TelegramService.java +++ b/src/main/java/com/juick/service/TelegramService.java @@ -18,6 +18,7 @@ package com.juick.service; import com.juick.model.User; +import org.springframework.cache.annotation.CacheEvict; import java.util.List; @@ -32,6 +33,7 @@ public interface TelegramService { boolean createTelegramUser(long tgID, String tgName); + @CacheEvict(value = "users_by_name", allEntries = true) boolean deleteTelegramUser(Integer uid); List getTelegramIdentifiers(List users); -- cgit v1.2.3