Commit 555bcc11 authored by Liang Ding's avatar Liang Ding

🎨 #12690

parent a63475a9
...@@ -20,7 +20,6 @@ package org.b3log.solo.cache; ...@@ -20,7 +20,6 @@ package org.b3log.solo.cache;
import org.b3log.latke.Keys; import org.b3log.latke.Keys;
import org.b3log.latke.ioc.Singleton; import org.b3log.latke.ioc.Singleton;
import org.b3log.latke.model.Role; import org.b3log.latke.model.Role;
import org.b3log.latke.model.User;
import org.b3log.solo.util.Solos; import org.b3log.solo.util.Solos;
import org.json.JSONObject; import org.json.JSONObject;
...@@ -31,7 +30,7 @@ import java.util.concurrent.ConcurrentHashMap; ...@@ -31,7 +30,7 @@ import java.util.concurrent.ConcurrentHashMap;
* User cache. * User cache.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.0.1, Sep 25, 2018 * @version 1.1.0.2, Mar 3, 2019
* @since 2.3.0 * @since 2.3.0
*/ */
@Singleton @Singleton
...@@ -42,11 +41,6 @@ public class UserCache { ...@@ -42,11 +41,6 @@ public class UserCache {
*/ */
private final Map<String, JSONObject> idCache = new ConcurrentHashMap<>(); private final Map<String, JSONObject> idCache = new ConcurrentHashMap<>();
/**
* Email, User.
*/
private final Map<String, JSONObject> emailCache = new ConcurrentHashMap<>();
/** /**
* Admin user. * Admin user.
*/ */
...@@ -85,21 +79,6 @@ public class UserCache { ...@@ -85,21 +79,6 @@ public class UserCache {
return Solos.clone(user); return Solos.clone(user);
} }
/**
* Gets a user by the specified user email.
*
* @param userEmail the specified user email
* @return user, returns {@code null} if not found
*/
public JSONObject getUserByEmail(final String userEmail) {
final JSONObject user = emailCache.get(userEmail);
if (null == user) {
return null;
}
return Solos.clone(user);
}
/** /**
* Adds or updates the specified user. * Adds or updates the specified user.
* *
...@@ -107,7 +86,6 @@ public class UserCache { ...@@ -107,7 +86,6 @@ public class UserCache {
*/ */
public void putUser(final JSONObject user) { public void putUser(final JSONObject user) {
idCache.put(user.optString(Keys.OBJECT_ID), Solos.clone(user)); idCache.put(user.optString(Keys.OBJECT_ID), Solos.clone(user));
emailCache.put(user.optString(User.USER_EMAIL), Solos.clone(user));
} }
/** /**
...@@ -122,9 +100,6 @@ public class UserCache { ...@@ -122,9 +100,6 @@ public class UserCache {
} }
idCache.remove(id); idCache.remove(id);
final String email = user.optString(User.USER_EMAIL);
emailCache.remove(email);
} }
/** /**
...@@ -132,7 +107,6 @@ public class UserCache { ...@@ -132,7 +107,6 @@ public class UserCache {
*/ */
public void clear() { public void clear() {
idCache.clear(); idCache.clear();
emailCache.clear();
adminCache.clear(); adminCache.clear();
} }
} }
...@@ -24,7 +24,7 @@ import org.json.JSONObject; ...@@ -24,7 +24,7 @@ import org.json.JSONObject;
* This class defines all comment model relevant keys. * This class defines all comment model relevant keys.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.2.0.0, Sep 21, 2018 * @version 1.2.0.1, Mar 3, 2019
* @since 0.3.1 * @since 0.3.1
*/ */
public final class Comment { public final class Comment {
...@@ -49,11 +49,6 @@ public final class Comment { ...@@ -49,11 +49,6 @@ public final class Comment {
*/ */
public static final String COMMENT_NAME = "commentName"; public static final String COMMENT_NAME = "commentName";
/**
* Key of comment email.
*/
public static final String COMMENT_EMAIL = "commentEmail";
/** /**
* Key of comment URL. * Key of comment URL.
*/ */
......
...@@ -96,29 +96,6 @@ public class UserRepository extends AbstractRepository { ...@@ -96,29 +96,6 @@ public class UserRepository extends AbstractRepository {
return getFirst(new Query().setFilter(new PropertyFilter(User.USER_NAME, FilterOperator.EQUAL, userName))); return getFirst(new Query().setFilter(new PropertyFilter(User.USER_NAME, FilterOperator.EQUAL, userName)));
} }
/**
* Gets a user by the specified email.
*
* @param email the specified email
* @return user, returns {@code null} if not found
* @throws RepositoryException repository exception
*/
public JSONObject getByEmail(final String email) throws RepositoryException {
JSONObject ret = userCache.getUserByEmail(email);
if (null != ret) {
return ret;
}
ret = getFirst(new Query().setFilter(new PropertyFilter(User.USER_EMAIL, FilterOperator.EQUAL, email.toLowerCase().trim())));
if (null == ret) {
return null;
}
userCache.putUser(ret);
return ret;
}
/** /**
* Gets the administrator user. * Gets the administrator user.
* *
......
...@@ -64,9 +64,10 @@ public final class V310_320 { ...@@ -64,9 +64,10 @@ public final class V310_320 {
Connection connection = Connections.getConnection(); Connection connection = Connections.getConnection();
Statement statement = connection.createStatement(); Statement statement = connection.createStatement();
// 删除 userEmail 字段,移除邮件相关功能 https://github.com/b3log/solo/issues/12690 // 移除邮件相关功能 https://github.com/b3log/solo/issues/12690
final String tablePrefix = Latkes.getLocalProperty("jdbc.tablePrefix") + "_"; final String tablePrefix = Latkes.getLocalProperty("jdbc.tablePrefix") + "_";
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "article` DROP COLUMN `userEmail`"); statement.executeUpdate("ALTER TABLE `" + tablePrefix + "article` DROP COLUMN `userEmail`");
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "comment` DROP COLUMN `commentEmail`");
statement.close(); statement.close();
connection.commit(); connection.commit();
connection.close(); connection.close();
......
...@@ -19,7 +19,6 @@ package org.b3log.solo.util; ...@@ -19,7 +19,6 @@ package org.b3log.solo.util;
import jodd.http.HttpRequest; import jodd.http.HttpRequest;
import jodd.http.HttpResponse; import jodd.http.HttpResponse;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang.RandomStringUtils; import org.apache.commons.lang.RandomStringUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.b3log.latke.Keys; import org.b3log.latke.Keys;
...@@ -474,14 +473,12 @@ public final class Solos { ...@@ -474,14 +473,12 @@ public final class Solos {
} }
/** /**
* Gets the Gravatar URL for the specified email with the specified size. * Gets the default user avatar URL..
* *
* @param email the specified email * @return default user avatar URL
* @param size the specified size
* @return the Gravatar URL
*/ */
public static String getGravatarURL(final String email, final String size) { public static String getDefaultAvatar() {
return GRAVATAR + DigestUtils.md5Hex(email) + "?s=" + size; return Latkes.getStaticServePath() + "/images/default-user-thumbnail.png";
} }
/** /**
......
...@@ -122,7 +122,6 @@ public abstract class AbstractTestCase { ...@@ -122,7 +122,6 @@ public abstract class AbstractTestCase {
public void init() throws Exception { public void init() throws Exception {
final InitService initService = getInitService(); final InitService initService = getInitService();
final JSONObject requestJSONObject = new JSONObject(); final JSONObject requestJSONObject = new JSONObject();
requestJSONObject.put(User.USER_EMAIL, "test@gmail.com");
requestJSONObject.put(User.USER_NAME, "Solo"); requestJSONObject.put(User.USER_NAME, "Solo");
requestJSONObject.put(UserExt.USER_B3_KEY, "pass"); requestJSONObject.put(UserExt.USER_B3_KEY, "pass");
initService.init(requestJSONObject); initService.init(requestJSONObject);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment