aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main/java/com/juick
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2017-06-20 09:41:28 +0300
committerGravatar Vitaly Takmazov2017-06-20 15:43:58 +0300
commit7d75cabd9ea4c80348d5e98ac08347a204c60fc4 (patch)
treef46239dcf07bf3c1fe523faed998bc057fb7fe98 /juick-server/src/main/java/com/juick
parentc803d6ac3db2a76508058812accd3b1748caab69 (diff)
mail wip
Diffstat (limited to 'juick-server/src/main/java/com/juick')
-rw-r--r--juick-server/src/main/java/com/juick/server/util/HttpUtils.java2
-rw-r--r--juick-server/src/main/java/com/juick/service/UserService.java2
-rw-r--r--juick-server/src/main/java/com/juick/service/UserServiceImpl.java15
3 files changed, 18 insertions, 1 deletions
diff --git a/juick-server/src/main/java/com/juick/server/util/HttpUtils.java b/juick-server/src/main/java/com/juick/server/util/HttpUtils.java
index c305093c..31a68962 100644
--- a/juick-server/src/main/java/com/juick/server/util/HttpUtils.java
+++ b/juick-server/src/main/java/com/juick/server/util/HttpUtils.java
@@ -81,7 +81,7 @@ public class HttpUtils {
throw new Exception("Wrong file type");
}
- attachmentFName = UUID.randomUUID().toString() + "." + attachmentType;
+ attachmentFName = DigestUtils.md5Hex(UUID.randomUUID().toString()) + "." + attachmentType;
fos = new FileOutputStream(Paths.get(tmpDir, attachmentFName).toString());
byte[] buffer = new byte[10240];
int len;
diff --git a/juick-server/src/main/java/com/juick/service/UserService.java b/juick-server/src/main/java/com/juick/service/UserService.java
index 661f386c..7f4bb1fe 100644
--- a/juick-server/src/main/java/com/juick/service/UserService.java
+++ b/juick-server/src/main/java/com/juick/service/UserService.java
@@ -30,6 +30,8 @@ public interface UserService {
User getFullyUserByName(String username);
+ User getUserByEmail(String email);
+
List<User> getFullyUsersByNames(Collection<String> usernames);
User getUserByJID(String jid);
diff --git a/juick-server/src/main/java/com/juick/service/UserServiceImpl.java b/juick-server/src/main/java/com/juick/service/UserServiceImpl.java
index 0b8ed13b..1fc72525 100644
--- a/juick-server/src/main/java/com/juick/service/UserServiceImpl.java
+++ b/juick-server/src/main/java/com/juick/service/UserServiceImpl.java
@@ -141,6 +141,21 @@ public class UserServiceImpl extends BaseJdbcService implements UserService {
return null;
}
+ @Override
+ @Transactional(readOnly = true)
+ public User getUserByEmail(String email) {
+ if (StringUtils.isNotBlank(email)) {
+ List<User> list = getJdbcTemplate().query(
+ "SELECT id, nick, banned, lang FROM users WHERE id = (SELECT user_id FROM emails WHERE email = ?)",
+ new UserMapper(),
+ email);
+
+ if (!list.isEmpty())
+ return list.get(0);
+ }
+ return AnonymousUser.INSTANCE;
+ }
+
@Transactional(readOnly = true)
@Override
public List<User> getFullyUsersByNames(final Collection<String> usernames) {