Compare commits

...
7 Commits
Author SHA1 Message Date
heavyrain2012 1f9824b283 version to 0.70 2021-09-04 11:23:40 +08:00
heavyrain2012 c7e20632a8 解决单个敏感词无法过滤的问题 2021-09-02 11:55:09 +08:00
heavyrain2012 81a2ab8239 更新命名 2021-09-01 14:48:11 +08:00
heavyrain2012 f62e3f3cef 添加设置用户关系中的附加信息 2021-09-01 14:39:59 +08:00
heavyrain2012 5ce8165514 fix word spell 2021-09-01 13:46:57 +08:00
heavyrain2012 106756ded4 修改敏感词替换错误问题 2021-09-01 13:44:49 +08:00
imndx 3f93be0ece update readme 2021-08-15 10:48:05 +08:00
14 changed files with 148 additions and 8 deletions
-1
View File
@@ -90,4 +90,3 @@
## License
1. Under the Creative Commons Attribution-NoDerivs 3.0 Unported license. See the [LICENSE](https://github.com/wildfirechat/server/blob/wildfirechat/LICENSE) file for details.
2. Under the Anti 996 License. See the [Anti 996 LICENSE](https://github.com/wildfirechat/server/blob/wildfirechat/LICENSE_996) file for details.
+1 -1
View File
@@ -5,7 +5,7 @@
<relativePath>../</relativePath>
<artifactId>wildfirechat-parent</artifactId>
<groupId>cn.wildfirechat</groupId>
<version>0.69</version>
<version>0.70</version>
</parent>
<artifactId>moquette-broker</artifactId>
@@ -0,0 +1,39 @@
/*
* This file is part of the Wildfire Chat package.
* (c) Heavyrain2012 <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
package com.xiaoleilu.loServer.action.admin;
import cn.wildfirechat.common.APIPath;
import cn.wildfirechat.common.ErrorCode;
import cn.wildfirechat.pojos.InputUpdateFriendExtra;
import com.xiaoleilu.loServer.RestResult;
import com.xiaoleilu.loServer.annotation.HttpMethod;
import com.xiaoleilu.loServer.annotation.Route;
import com.xiaoleilu.loServer.handler.Request;
import com.xiaoleilu.loServer.handler.Response;
import io.netty.handler.codec.http.FullHttpRequest;
@Route(APIPath.Friend_Set_Extra)
@HttpMethod("POST")
public class FriendExtraPutAction extends AdminAction {
@Override
public boolean isTransactionAction() {
return true;
}
@Override
public boolean action(Request request, Response response) {
if (request.getNettyRequest() instanceof FullHttpRequest) {
InputUpdateFriendExtra input = getRequestBody(request.getNettyRequest(), InputUpdateFriendExtra.class);
ErrorCode errorCode = messagesStore.setFriendExtraRequest(input.getOperator(), input.getTargetId(), input.getExtra(), new long[1]);
setResponseContent(RestResult.resultOf(errorCode), response);
}
return true;
}
}
@@ -3079,6 +3079,43 @@ public class MemoryMessagesStore implements IMessagesStore {
return ErrorCode.ERROR_CODE_SUCCESS;
}
@Override
public ErrorCode setFriendExtraRequest(String fromUser, String targetUserId, String extra, long[] heads){
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
MultiMap<String, FriendData> friendsMap = hzInstance.getMultiMap(USER_FRIENDS);
FriendData friendData = null;
Collection<FriendData> friends = friendsMap.get(fromUser);
if (friends == null || friends.size() == 0) {
friends = loadFriend(friendsMap, fromUser);
}
for (FriendData fd:friends) {
if (fd.getFriendUid().equals(targetUserId)) {
friendData = fd;
break;
}
}
if (friendData == null) {
friendData = new FriendData();
friendData.setUserId(fromUser);
friendData.setFriendUid(targetUserId);
}
friendData.setExtra(extra);
friendData.setTimestamp(System.currentTimeMillis());
databaseStore.persistOrUpdateFriendData(friendData);
heads[0] = friendData.getTimestamp();
friendsMap.remove(fromUser);
callbackRelationEvent(fromUser, targetUserId, 3, extra);
return ErrorCode.ERROR_CODE_SUCCESS;
}
@Override
public ErrorCode handleJoinChatroom(String userId, String clientId, String chatroomId) {
IMap<String, WFCMessage.ChatroomInfo> chatroomInfoMap = m_Server.getHazelcastInstance().getMap(CHATROOMS);
@@ -182,6 +182,7 @@ public interface IMessagesStore {
ErrorCode SyncFriendRequestUnread(String userId, long unreadDt, long[] head);
ErrorCode isAllowUserMessage(String fromUser, String userId);
ErrorCode setFriendAliasRequest(String fromUser, String targetUserId, String alias, long[] head);
ErrorCode setFriendExtraRequest(String fromUser, String targetUserId, String extra, long[] head);
ErrorCode handleJoinChatroom(String userId, String clientId, String chatroomId);
ErrorCode handleQuitChatroom(String userId, String clientId, String chatroomId);
@@ -31,11 +31,12 @@ public class SensitiveFilter {
return sensitiveWords;
}
String originalText = text;
text = text.toLowerCase();
for(int i=0;i<text.length();i++){
int sensitiveWordLength = getSensitiveWordLength(text, i, matchType);
if(sensitiveWordLength>0){
String sensitiveWord = text.substring(i, i + sensitiveWordLength);
String sensitiveWord = originalText.substring(i, i + sensitiveWordLength);
sensitiveWords.add(sensitiveWord);
if(matchType==MatchType.MIN_MATCH){
break;
@@ -93,7 +94,7 @@ public class SensitiveFilter {
Iterator<String> iterator = sensitiveWords.iterator();
while (iterator.hasNext()){
currentWord=iterator.next();
if(currentWord==null||currentWord.trim().length()<2){ //敏感词长度必须大于等于2
if(currentWord==null||currentWord.trim().length()<1){ //敏感词长度必须大于等于1
continue;
}
currentMap=sensitiveWordsMap;
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>wildfirechat-parent</artifactId>
<groupId>cn.wildfirechat</groupId>
<version>0.69</version>
<version>0.70</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -39,6 +39,7 @@ public interface APIPath {
String Blacklist_Get_List = "/admin/blacklist/list";
String Friend_Get_Alias = "/admin/friend/get_alias";
String Friend_Set_Alias = "/admin/friend/set_alias";
String Friend_Set_Extra = "/admin/friend/set_extra";
String Friend_Send_Request = "/admin/friend/send_request";
String Friend_Get_Requests = "/admin/friend/get_requests";
String Relation_Get = "/admin/relation/get";
@@ -0,0 +1,40 @@
/*
* This file is part of the Wildfire Chat package.
* (c) Heavyrain2012 <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
package cn.wildfirechat.pojos;
public class InputUpdateFriendExtra {
private String operator;
private String targetId;
private String extra;
public String getTargetId() {
return targetId;
}
public void setTargetId(String targetId) {
this.targetId = targetId;
}
public String getOperator() {
return operator;
}
public void setOperator(String operator) {
this.operator = operator;
}
public String getExtra() {
return extra;
}
public void setExtra(String extra) {
this.extra = extra;
}
}
+1 -1
View File
@@ -6,7 +6,7 @@
<!--<relativePath>../pom.xml</relativePath>-->
<artifactId>wildfirechat-parent</artifactId>
<groupId>cn.wildfirechat</groupId>
<version>0.69</version>
<version>0.70</version>
</parent>
<artifactId>distribution</artifactId>
+1 -1
View File
@@ -12,7 +12,7 @@
<artifactId>wildfirechat-parent</artifactId>
<packaging>pom</packaging>
<version>0.69</version>
<version>0.70</version>
<name>Wildfire Chat</name>
<description>Wildfire Chat Server</description>
<inceptionYear>2019</inceptionYear>
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>wildfirechat-parent</artifactId>
<groupId>cn.wildfirechat</groupId>
<version>0.69</version>
<version>0.70</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -381,6 +381,15 @@ public class Main {
System.exit(-1);
}
String friendExtra = "hello friend extra";
IMResult<Void> setExtraResult = RelationAdmin.updateFriendExtra("ff1", "ff2", friendExtra);
if (setExtraResult != null && setExtraResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
System.out.println("set friend extra success");
} else {
System.out.println("set friend extra failure");
System.exit(-1);
}
IMResult<RelationPojo> getRelation = RelationAdmin.getRelation("ff1", "ff2");
if (getRelation != null && getRelation.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
System.out.println("get friend relation success");
@@ -388,6 +397,11 @@ public class Main {
System.out.println("get friend relation failure");
System.exit(-1);
}
if(!friendExtra.equals(getRelation.getResult().extra)) {
System.out.println("set friend extra failure");
System.exit(-1);
}
}
//***********************************************
//**** 群组相关功能
@@ -56,6 +56,14 @@ public class RelationAdmin {
return AdminHttpUtils.httpJsonPost(path, input, OutputGetAlias.class);
}
public static IMResult<Void> updateFriendExtra(String operator, String targetId, String extra) throws Exception {
String path = APIPath.Friend_Set_Extra;
InputUpdateFriendExtra input = new InputUpdateFriendExtra();
input.setOperator(operator);
input.setTargetId(targetId);
input.setExtra(extra);
return AdminHttpUtils.httpJsonPost(path, input, Void.class);
}
public static IMResult<Void> sendFriendRequest(String userId, String targetId, String reason, boolean force) throws Exception {
String path = APIPath.Friend_Send_Request;
InputAddFriendRequest input = new InputAddFriendRequest();