aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2024-05-24 14:29:55 +0300
committerGravatar Vitaly Takmazov2024-05-24 14:29:55 +0300
commitdfa030a3765c5b5e43e263234155d344f5c6186e (patch)
tree53da933dddb3fffb9b7674d43a28190ed3cc79f7 /src/main/java/com
parent65d5b915104fc79a3e8425466b6e2b88c1f35828 (diff)
Do not allow unverified users to comment messages
Diffstat (limited to 'src/main/java/com')
-rw-r--r--src/main/java/com/juick/CommandsManager.java5
-rw-r--r--src/main/java/com/juick/model/User.java2
-rw-r--r--src/main/java/com/juick/service/TelegramService.java2
3 files changed, 7 insertions, 2 deletions
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<String, Set<Tag>> 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<Long> getTelegramIdentifiers(List<User> users);