Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d400b74bff | ||
|
|
3d7220d79c | ||
|
|
4bcf784a6d | ||
|
|
6d021568d3 | ||
|
|
44f54ecd17 | ||
|
|
4cd0349911 | ||
|
|
9ad78f2fb8 | ||
|
|
b284d10d0f | ||
|
|
4fd87eb605 | ||
|
|
f39fd3abd5 | ||
|
|
db25a6ae04 | ||
|
|
edbed585ce | ||
|
|
9ca69d7318 | ||
|
|
eeaa9eefdf | ||
|
|
92c9d761ed |
@@ -100,6 +100,11 @@ message.group_mute_exception_types 401,402,403,404,405,407,408,410,411
|
||||
## 用户被全局禁言时允许发送的消息类型
|
||||
message.global_mute_exception_types 401,402,403,404,405,407,408,410,411
|
||||
|
||||
## 消息转发功能开启时,开关是否不转发server api接口消息。
|
||||
## 当为true时,不转发server api发送的消息;当为false时,转发server api发送的消息。
|
||||
message.no_forward_admin_message false
|
||||
|
||||
|
||||
##禁止搜索用户
|
||||
friend.disable_search false
|
||||
|
||||
@@ -215,6 +220,10 @@ server.multi_platform_notification true
|
||||
# 如果这里改为false,客户端那边需要同步修改pc在线默认通知状态,方法是client的setDefaultSilentWhenPcOnline函数。
|
||||
server.mobile_default_silent_when_pc_online true
|
||||
|
||||
## 客户端是否支持kickoff事件。当客户端被其他端登录踢出时,如果此开关为false时,客户端协议栈上报secret_mismatch。如果此开关为ture时,客户端协议栈上报kicked_off。
|
||||
## 客户端被踢时上报kicked_off是在2021.9.15之后才加上的。如果客户端协议栈全部为此日期之后的版本才可以打开此开关。
|
||||
server.client_support_kickoff_event false
|
||||
|
||||
#*********************************************************************
|
||||
# Push server configuration
|
||||
#*********************************************************************
|
||||
@@ -255,6 +264,11 @@ push.ios.server.address http://localhost:8085/ios/push
|
||||
##需要转发的消息类型,当有多个时以英文逗号分割。如果转发所有消息,请注释掉配置或者设置为空
|
||||
#message.forward.types 1,2,3
|
||||
|
||||
##提醒消息转发地址,@全体用户和@某个用户消息会回调此地址。此转发不受${message.forward.types}限制。
|
||||
##注意回调是单线程回调,接收服务必须在同一内网,且异步处理快速返回,否则会有延迟问题!!
|
||||
#message.mentionmsg.forward.url http://localhost:8888/im_event/message
|
||||
|
||||
|
||||
##设备信息转发地址
|
||||
##注意回调是单线程回调,接收服务必须在同一内网,且异步处理快速返回,否则会有延迟问题!!
|
||||
#things_message.forward.url http://localhost:8888/im_event/things/message
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<relativePath>../</relativePath>
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
<groupId>cn.wildfirechat</groupId>
|
||||
<version>0.70</version>
|
||||
<version>0.72</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>moquette-broker</artifactId>
|
||||
|
||||
@@ -32,6 +32,7 @@ public class PushMessage {
|
||||
public String voipDeviceToken;
|
||||
public boolean isHiddenDetail;
|
||||
public String language;
|
||||
public long messageId;
|
||||
|
||||
public PushMessage(String sender, int conversationType, String target, int line, int messageContentType, long serverTime, String senderName, String targetName, int unReceivedMsg, int mentionedType, boolean isHiddenDetail, String language) {
|
||||
this.sender = sender;
|
||||
@@ -49,6 +50,10 @@ public class PushMessage {
|
||||
this.pushMessageType = PushServer.PushMessageType.PUSH_MESSAGE_TYPE_VOIP_BYE;
|
||||
} else if(cntType == 401) {
|
||||
this.pushMessageType = PushServer.PushMessageType.PUSH_MESSAGE_TYPE_VOIP_ANSWER;
|
||||
} else if(cntType == 80) {
|
||||
this.pushMessageType = PushServer.PushMessageType.PUSH_MESSAGE_TYPE_RECALLED;
|
||||
} else if(cntType == 81) {
|
||||
this.pushMessageType = PushServer.PushMessageType.PUSH_MESSAGE_TYPE_DELETED;
|
||||
} else {
|
||||
this.pushMessageType = PushServer.PushMessageType.PUSH_MESSAGE_TYPE_NORMAL;
|
||||
}
|
||||
|
||||
@@ -35,6 +35,8 @@ public class PushServer {
|
||||
int PUSH_MESSAGE_TYPE_VOIP_BYE = 2;
|
||||
int PUSH_MESSAGE_TYPE_FRIEND_REQUEST = 3;
|
||||
int PUSH_MESSAGE_TYPE_VOIP_ANSWER = 4;
|
||||
int PUSH_MESSAGE_TYPE_RECALLED = 5;
|
||||
int PUSH_MESSAGE_TYPE_DELETED = 6;
|
||||
}
|
||||
|
||||
private static PushServer INSTANCE = new PushServer();
|
||||
|
||||
@@ -18,6 +18,8 @@ import cn.wildfirechat.pojos.OutputGetIMTokenData;
|
||||
import com.xiaoleilu.loServer.handler.Response;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import win.liyufan.im.IMTopic;
|
||||
|
||||
import java.util.Base64;
|
||||
@@ -25,7 +27,7 @@ import java.util.Base64;
|
||||
@Route(APIPath.User_Get_Token)
|
||||
@HttpMethod("POST")
|
||||
public class GetIMTokenAction extends AdminAction {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(GetIMTokenAction.class);
|
||||
@Override
|
||||
public boolean isTransactionAction() {
|
||||
return false;
|
||||
@@ -49,6 +51,8 @@ public class GetIMTokenAction extends AdminAction {
|
||||
}
|
||||
String token = Base64.getEncoder().encodeToString(data);
|
||||
|
||||
LOG.info("get im token success {},{},{}", userId, input.getClientId(), token.substring(0, Math.min(10, token.length())));
|
||||
|
||||
return new Result(errorCode1, new OutputGetIMTokenData(userId, token));
|
||||
} else {
|
||||
return new Result(errorCode1);
|
||||
|
||||
@@ -128,10 +128,13 @@ public final class BrokerConstants {
|
||||
|
||||
public static final String MESSAGE_Forward_Url = "message.forward.url";
|
||||
public static final String MESSAGE_Forward_Types = "message.forward.types";
|
||||
public static final String MESSAGE_MentionMsg_Forward_Url = "message.mentionmsg.forward.url";
|
||||
|
||||
|
||||
public static final String SERVER_MULTI_ENDPOINT = "server.multi_endpoint";
|
||||
public static final String SERVER_MULTI_PLATFROM_NOTIFICATION = "server.multi_platform_notification";
|
||||
public static final String SERVER_MOBILE_DEFAULT_SILENT_WHEN_PC_ONLINE = "server.mobile_default_silent_when_pc_online";
|
||||
public static final String SERVER_CLIENT_SUPPORT_KICKOFF_EVENT = "server.client_support_kickoff_event";
|
||||
|
||||
public static final String MESSAGE_ROAMING = "message.roaming";
|
||||
public static final String MESSAGE_Remote_History_Message = "message.remote_history_message";
|
||||
@@ -142,6 +145,8 @@ public final class BrokerConstants {
|
||||
|
||||
public static final String MESSAGE_Blacklist_Strategy = "message.blacklist.strategy";
|
||||
|
||||
public static final String MESSAGE_NO_Forward_Admin_Message = "message.no_forward_admin_message";
|
||||
|
||||
public static final String FRIEND_Disable_Search = "friend.disable_search";
|
||||
public static final String FRIEND_Disable_NickName_Search = "friend.disable_nick_name_search";
|
||||
public static final String FRIEND_Disable_Friend_Request = "friend.disable_friend_request";
|
||||
|
||||
@@ -33,7 +33,9 @@ public class SendMessageHandler extends IMHandler<WFCMessage.Message> {
|
||||
private int mSensitiveType = 0; //命中敏感词时,0 失败,1 吞掉, 2 敏感词替换成*。
|
||||
private String mForwardUrl = null;
|
||||
private Set<Integer> mForwardMessageTypes = new HashSet<>();
|
||||
private String mMentionForwardUrl = null;
|
||||
private int mBlacklistStrategy = 0; //黑名单中时,0失败,1吞掉。
|
||||
private boolean mNoForwardAdminMessage = false;
|
||||
|
||||
private String mRemoteSensitiveServerUrl = null;
|
||||
private Set<Integer> mRemoteSensitiveMessageTypes;
|
||||
@@ -42,10 +44,8 @@ public class SendMessageHandler extends IMHandler<WFCMessage.Message> {
|
||||
public SendMessageHandler() {
|
||||
super();
|
||||
|
||||
String forwardUrl = mServer.getConfig().getProperty(BrokerConstants.MESSAGE_Forward_Url);
|
||||
if (!StringUtil.isNullOrEmpty(forwardUrl)) {
|
||||
mForwardUrl = forwardUrl;
|
||||
|
||||
mForwardUrl = mServer.getConfig().getProperty(BrokerConstants.MESSAGE_Forward_Url);
|
||||
if (!StringUtil.isNullOrEmpty(mForwardUrl)) {
|
||||
String forwardTypes = mServer.getConfig().getProperty(BrokerConstants.MESSAGE_Forward_Types);
|
||||
if (!StringUtil.isNullOrEmpty(forwardTypes)) {
|
||||
String[] tss = forwardTypes.split(",");
|
||||
@@ -55,6 +55,8 @@ public class SendMessageHandler extends IMHandler<WFCMessage.Message> {
|
||||
}
|
||||
}
|
||||
|
||||
mMentionForwardUrl = mServer.getConfig().getProperty(BrokerConstants.MESSAGE_MentionMsg_Forward_Url);
|
||||
|
||||
try {
|
||||
mSensitiveType = Integer.parseInt(mServer.getConfig().getProperty(BrokerConstants.SENSITIVE_Filter_Type));
|
||||
} catch (Exception e) {
|
||||
@@ -86,6 +88,13 @@ public class SendMessageHandler extends IMHandler<WFCMessage.Message> {
|
||||
Utility.printExecption(LOG, e);
|
||||
}
|
||||
|
||||
try {
|
||||
mNoForwardAdminMessage = Boolean.parseBoolean(mServer.getConfig().getProperty(BrokerConstants.MESSAGE_NO_Forward_Admin_Message, "false"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Utility.printExecption(LOG, e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -161,10 +170,14 @@ public class SendMessageHandler extends IMHandler<WFCMessage.Message> {
|
||||
}
|
||||
message = message.toBuilder().setFromUser(fromUser).setMessageId(messageId).setServerTimestamp(timestamp).build();
|
||||
|
||||
if (mForwardUrl != null && (mForwardMessageTypes.isEmpty() || mForwardMessageTypes.contains(message.getContent().getType()))) {
|
||||
if (!StringUtil.isNullOrEmpty(mForwardUrl) && (mForwardMessageTypes.isEmpty() || mForwardMessageTypes.contains(message.getContent().getType())) && !(isAdmin && mNoForwardAdminMessage)) {
|
||||
publisher.forwardMessage(message, mForwardUrl);
|
||||
}
|
||||
|
||||
if(!StringUtil.isNullOrEmpty(mMentionForwardUrl) && message.hasContent() && message.getContent().getMentionedType() != 0 && !(isAdmin && mNoForwardAdminMessage)) {
|
||||
publisher.forwardMessage(message, mMentionForwardUrl);
|
||||
}
|
||||
|
||||
if (!isAdmin) {
|
||||
if(StringUtil.isNullOrEmpty(mRemoteSensitiveServerUrl)) {
|
||||
Set<String> matched = m_messagesStore.handleSensitiveWord(message.getContent().getSearchableContent());
|
||||
|
||||
@@ -121,6 +121,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
private volatile long lastUpdateSensitiveTime = 0;
|
||||
|
||||
private ConcurrentHashMap<String, Boolean> userGlobalSlientMap = new ConcurrentHashMap<>();
|
||||
private ConcurrentHashMap<String, Boolean> userVoipSlientMap = new ConcurrentHashMap<>();
|
||||
private ConcurrentHashMap<String, Boolean> userPushHiddenDetail = new ConcurrentHashMap<>();
|
||||
private ConcurrentHashMap<String, Boolean> userConvSlientMap = new ConcurrentHashMap<>();
|
||||
|
||||
@@ -639,6 +640,17 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
}
|
||||
}
|
||||
|
||||
if(fromMessageId == 1) { //lite mode
|
||||
if(maps == null || maps.isEmpty()) {
|
||||
head = 0;
|
||||
} else {
|
||||
head = maps.lastKey();
|
||||
}
|
||||
builder.setCurrent(head);
|
||||
builder.setHead(head);
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
mReadLock.lock();
|
||||
int size = 0;
|
||||
try {
|
||||
@@ -2041,7 +2053,20 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
|
||||
String recalledContent = json.toJSONString();
|
||||
|
||||
message = message.toBuilder().setContent(WFCMessage.MessageContent.newBuilder().setContent(operatorId).setType(80).setData(ByteString.copyFrom(String.valueOf(messageUid).getBytes())).setExtra(recalledContent)).build();
|
||||
JSONObject pushData = new JSONObject();
|
||||
pushData.put("messageUid", messageUid);
|
||||
|
||||
message = message.toBuilder().setContent(WFCMessage.MessageContent.newBuilder()
|
||||
.setContent(operatorId)
|
||||
.clearSearchableContent()
|
||||
.clearPushContent()
|
||||
.setPersistFlag(1)
|
||||
.setExpireDuration(0)
|
||||
.setMentionedType(0)
|
||||
.setType(80)
|
||||
.setData(ByteString.copyFrom(String.valueOf(messageUid).getBytes()))
|
||||
.setPushData(pushData.toJSONString())
|
||||
.setExtra(recalledContent)).build();
|
||||
messageBundle.setMessage(message);
|
||||
messageBundle.setFromClientId(clientId);
|
||||
|
||||
@@ -3378,6 +3403,8 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
userConvSlientMap.remove(key);
|
||||
} else if(request.getScope() == UserSettingScope.kUserSettingGlobalSilent) {
|
||||
userGlobalSlientMap.remove(userId);
|
||||
} else if(request.getScope() == UserSettingScope.kUserSettingVoipSilent) {
|
||||
userVoipSlientMap.remove(userId);
|
||||
} else if(request.getScope() == UserSettingScope.kUserSettingHiddenNotificationDetail) {
|
||||
userPushHiddenDetail.remove(userId);
|
||||
}
|
||||
@@ -3408,6 +3435,21 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
return slient;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getUserVoipSilent(String userId) {
|
||||
Boolean slient = userVoipSlientMap.get(userId);
|
||||
if (slient == null) {
|
||||
WFCMessage.UserSettingEntry entry = getUserSetting(userId, UserSettingScope.kUserSettingVoipSilent, null);
|
||||
if (entry == null || !entry.getValue().equals("1")) {
|
||||
slient = false;
|
||||
} else {
|
||||
slient = true;
|
||||
}
|
||||
userVoipSlientMap.put(userId, slient);
|
||||
}
|
||||
return slient;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getUserPushHiddenDetail(String userId) {
|
||||
Boolean hidden = userPushHiddenDetail.get(userId);
|
||||
|
||||
@@ -39,6 +39,7 @@ public class MemorySessionStore implements ISessionsStore {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(MemorySessionStore.class);
|
||||
|
||||
private boolean supportMultiEndpoint = false;
|
||||
private boolean clientSupportKickoff = false;
|
||||
|
||||
public static class Session implements Comparable<Session>{
|
||||
final String clientID;
|
||||
@@ -280,7 +281,14 @@ public class MemorySessionStore implements ISessionsStore {
|
||||
this.databaseStore = databaseStore;
|
||||
|
||||
try {
|
||||
supportMultiEndpoint = Boolean.parseBoolean(server.getConfig().getProperty(BrokerConstants.SERVER_MULTI_ENDPOINT));
|
||||
supportMultiEndpoint = Boolean.parseBoolean(server.getConfig().getProperty(BrokerConstants.SERVER_MULTI_ENDPOINT, "false"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Utility.printExecption(LOG, e);
|
||||
}
|
||||
|
||||
try {
|
||||
clientSupportKickoff = Boolean.parseBoolean(server.getConfig().getProperty(BrokerConstants.SERVER_CLIENT_SUPPORT_KICKOFF_EVENT, "false"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Utility.printExecption(LOG, e);
|
||||
@@ -456,20 +464,32 @@ public class MemorySessionStore implements ISessionsStore {
|
||||
|
||||
if (session != null && session.getDeleted() == 0) {
|
||||
LOG.error("already exists a session for client <{}>, bad condition", clientID);
|
||||
throw new IllegalArgumentException("Can't create a session with the ID of an already existing" + clientID);
|
||||
return ErrorCode.ERROR_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
if (session != null && session.getDeleted() > 0) {
|
||||
return ErrorCode.ERROR_CODE_SECRECT_KEY_MISMATCH;
|
||||
if(clientSupportKickoff) {
|
||||
return ErrorCode.ERROR_CODE_KICKED_OFF;
|
||||
} else {
|
||||
return ErrorCode.ERROR_CODE_SECRECT_KEY_MISMATCH;
|
||||
}
|
||||
}
|
||||
|
||||
ClientSession clientSession = new ClientSession(clientID, this);
|
||||
session = databaseStore.getSession(username, clientID, clientSession);
|
||||
|
||||
if (session == null || session.getDeleted() > 0) {
|
||||
if (session == null) {
|
||||
return ErrorCode.ERROR_CODE_SECRECT_KEY_MISMATCH;
|
||||
}
|
||||
|
||||
if(session.getDeleted() > 0) {
|
||||
if(clientSupportKickoff) {
|
||||
return ErrorCode.ERROR_CODE_KICKED_OFF;
|
||||
} else {
|
||||
return ErrorCode.ERROR_CODE_SECRECT_KEY_MISMATCH;
|
||||
}
|
||||
}
|
||||
|
||||
sessions.put(clientID, session);
|
||||
ConcurrentSkipListSet<String> sessionSet = getUserSessionSet(username);
|
||||
sessionSet.add(clientID);
|
||||
@@ -511,7 +531,7 @@ public class MemorySessionStore implements ISessionsStore {
|
||||
if (session.getUsername().equals(username)) {
|
||||
return session;
|
||||
} else {
|
||||
cleanSession(clientID);
|
||||
cleanSession(null, clientID);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -719,9 +739,9 @@ public class MemorySessionStore implements ISessionsStore {
|
||||
|
||||
|
||||
@Override
|
||||
public void disableSession(String clientId) {
|
||||
public void disableSession(String userId, String clientId) {
|
||||
Session session = sessions.get(clientId);
|
||||
if (session != null && session.getDeleted() == 0) {
|
||||
if (session != null && session.getDeleted() == 0 && (userId == null || session.getUsername().equals(userId))) {
|
||||
databaseStore.updateSessionDeleted(session.getUsername(), clientId, 1);
|
||||
ConcurrentSkipListSet<String> sessionSet = getUserSessionSet(session.username);
|
||||
sessionSet.remove(clientId);
|
||||
@@ -730,7 +750,7 @@ public class MemorySessionStore implements ISessionsStore {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanSession(String clientID) {
|
||||
public void cleanSession(String userId, String clientID) {
|
||||
LOG.info("Fooooooooo <{}>", clientID);
|
||||
|
||||
Session session = sessions.get(clientID);
|
||||
@@ -738,6 +758,11 @@ public class MemorySessionStore implements ISessionsStore {
|
||||
LOG.error("Can't find the session for client <{}>", clientID);
|
||||
return;
|
||||
}
|
||||
|
||||
if(userId != null && !session.getUsername().equals(userId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ConcurrentSkipListSet<String> sessionSet = getUserSessionSet(session.username);
|
||||
sessionSet.remove(clientID);
|
||||
|
||||
|
||||
@@ -80,6 +80,7 @@ public class Server {
|
||||
}
|
||||
|
||||
private ServerAcceptor m_acceptor;
|
||||
private long startTime;
|
||||
|
||||
private boolean m_shutdowning = false;
|
||||
|
||||
@@ -102,6 +103,10 @@ public class Server {
|
||||
System.out.println(BANNER);
|
||||
}
|
||||
|
||||
public Server() {
|
||||
startTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public static void start(String[] args) throws IOException {
|
||||
instance = new Server();
|
||||
final IConfig config = defaultConfig();
|
||||
@@ -513,4 +518,7 @@ public class Server {
|
||||
public ThreadPoolExecutorWrapper getCallbackScheduler() {
|
||||
return callbackScheduler;
|
||||
}
|
||||
public long getRunTime() {
|
||||
return (System.currentTimeMillis() - startTime)/1000;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,19 +109,19 @@ public class ClientSession {
|
||||
}
|
||||
|
||||
|
||||
public void disconnect(boolean cleanSession, boolean disableSession) {
|
||||
public void disconnect(String userId, boolean cleanSession, boolean disableSession) {
|
||||
if (cleanSession) {
|
||||
LOG.info("Client disconnected. Removing its subscriptions. ClientId={}", clientID);
|
||||
// cleanup topic subscriptions
|
||||
cleanSession();
|
||||
cleanSession(userId);
|
||||
} else if(disableSession) {
|
||||
LOG.info("Client disconnected. disable session. ClientId={}", clientID);
|
||||
m_sessionsStore.disableSession(this.clientID);
|
||||
m_sessionsStore.disableSession(userId, this.clientID);
|
||||
}
|
||||
}
|
||||
|
||||
public void cleanSession() {
|
||||
m_sessionsStore.cleanSession(this.clientID);
|
||||
public void cleanSession(String userId) {
|
||||
m_sessionsStore.cleanSession(userId, this.clientID);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -195,6 +195,7 @@ public interface IMessagesStore {
|
||||
long updateUserSettings(String userId, WFCMessage.ModifyUserSettingReq request, String clientId);
|
||||
void clearUserSettings(String userId);
|
||||
boolean getUserGlobalSilent(String userId);
|
||||
boolean getUserVoipSilent(String userId);
|
||||
|
||||
boolean getUserPushHiddenDetail(String userId);
|
||||
boolean getUserConversationSilent(String userId, WFCMessage.Conversation conversation);
|
||||
|
||||
@@ -150,8 +150,8 @@ public interface ISessionsStore {
|
||||
*/
|
||||
int getSecondPhaseAckPendingMessages(String clientID);
|
||||
|
||||
void disableSession(String clientId);
|
||||
void cleanSession(String clientID);
|
||||
void disableSession(String userId, String clientId);
|
||||
void cleanSession(String userId, String clientID);
|
||||
|
||||
boolean isMultiEndpointSupported();
|
||||
|
||||
|
||||
@@ -160,9 +160,9 @@ public class MessagesPublisher {
|
||||
}
|
||||
}
|
||||
|
||||
private void publish2Receivers(String sender, int conversationType, String target, int line, long messageHead, Collection<String> receivers, String pushContent, String pushData, String exceptClientId, int pullType, int messageContentType, long serverTime, int mentionType, List<String> mentionTargets, int persistFlag) {
|
||||
private void publish2Receivers(String sender, int conversationType, String target, int line, long messageId, Collection<String> receivers, String pushContent, String pushData, String exceptClientId, int pullType, int messageContentType, long serverTime, int mentionType, List<String> mentionTargets, int persistFlag) {
|
||||
if (persistFlag == Transparent) {
|
||||
publishTransparentMessage2Receivers(messageHead, receivers, pullType, exceptClientId);
|
||||
publishTransparentMessage2Receivers(messageId, receivers, pullType, exceptClientId);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -174,7 +174,7 @@ public class MessagesPublisher {
|
||||
WFCMessage.Robot robot = m_messagesStore.getRobot(user);
|
||||
if (robot != null && !StringUtil.isNullOrEmpty(robot.getCallback())) {
|
||||
if (message == null) {
|
||||
message = m_messagesStore.getMessage(messageHead);
|
||||
message = m_messagesStore.getMessage(messageId);
|
||||
}
|
||||
final WFCMessage.Message finalMsg = message;
|
||||
Server.getServer().getCallbackScheduler().execute(() -> {
|
||||
@@ -191,9 +191,9 @@ public class MessagesPublisher {
|
||||
}
|
||||
long messageSeq;
|
||||
if (pullType != ProtoConstants.PullType.Pull_ChatRoom) {
|
||||
messageSeq = m_messagesStore.insertUserMessages(sender, conversationType, target, line, messageContentType, user, messageHead);
|
||||
messageSeq = m_messagesStore.insertUserMessages(sender, conversationType, target, line, messageContentType, user, messageId);
|
||||
} else {
|
||||
messageSeq = m_messagesStore.insertChatroomMessages(user, line, messageHead);
|
||||
messageSeq = m_messagesStore.insertChatroomMessages(user, line, messageId);
|
||||
}
|
||||
|
||||
Collection<Session> sessions = m_sessionsStore.sessionForUser(user);
|
||||
@@ -253,12 +253,18 @@ public class MessagesPublisher {
|
||||
}
|
||||
|
||||
boolean isSilent;
|
||||
boolean isVoipSilent;
|
||||
boolean isNoDisturb;
|
||||
boolean isConvSilent = false;
|
||||
if (pullType == ProtoConstants.PullType.Pull_ChatRoom) {
|
||||
isSilent = true;
|
||||
isConvSilent = true;
|
||||
isVoipSilent = true;
|
||||
isNoDisturb = true;
|
||||
} else {
|
||||
isSilent = false;
|
||||
isVoipSilent = false;
|
||||
isNoDisturb = false;
|
||||
|
||||
if (!user.equals(sender)) {
|
||||
WFCMessage.Conversation conversation;
|
||||
@@ -278,14 +284,19 @@ public class MessagesPublisher {
|
||||
isSilent = true;
|
||||
}
|
||||
|
||||
if (m_messagesStore.getUserVoipSilent(user)) {
|
||||
LOG.info("The user {} is voip sliented", user);
|
||||
isVoipSilent = true;
|
||||
}
|
||||
|
||||
if (!isSilent && isPcOnline && m_messagesStore.getSilentWhenPcOnline(user)) {
|
||||
LOG.info("The user {} pc online and silent when pc online", user);
|
||||
isSilent = true;
|
||||
}
|
||||
|
||||
if (!isSilent && m_messagesStore.isUserNoDisturbing(user)) {
|
||||
if (m_messagesStore.isUserNoDisturbing(user)) {
|
||||
LOG.info("The user {} is no disturbing", user);
|
||||
isSilent = true;
|
||||
isNoDisturb = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,8 +342,9 @@ public class MessagesPublisher {
|
||||
isConvSilent = false;
|
||||
}
|
||||
}
|
||||
boolean isVoip = messageContentType == 402 || messageContentType == 400 || messageContentType == 401 || messageContentType == 406;
|
||||
|
||||
if ((StringUtil.isNullOrEmpty(pushContent) && messageContentType != 402 && messageContentType != 400 && messageContentType != 401 && messageContentType != 406)) {
|
||||
if (StringUtil.isNullOrEmpty(pushContent) && StringUtil.isNullOrEmpty(pushData) && !isVoip) {
|
||||
LOG.info("push content is empty and contenttype is {}", messageContentType);
|
||||
continue;
|
||||
}
|
||||
@@ -342,16 +354,26 @@ public class MessagesPublisher {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isConvSilent) {
|
||||
if (isConvSilent && !isVoip) {
|
||||
LOG.info("Silent of user or conversation");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isSilent) {
|
||||
if (isSilent && !isVoip) {
|
||||
LOG.info("Silent of user");
|
||||
continue;
|
||||
}
|
||||
|
||||
if(isVoip && isVoipSilent) {
|
||||
LOG.info("voip silent of user");
|
||||
continue;
|
||||
}
|
||||
|
||||
if(isNoDisturb) {
|
||||
LOG.info("no disturb of user");
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean isHiddenDetail = m_messagesStore.getUserPushHiddenDetail(user);
|
||||
|
||||
if(!nameLoaded) {
|
||||
@@ -367,7 +389,7 @@ public class MessagesPublisher {
|
||||
name = fd.getAlias();
|
||||
}
|
||||
}
|
||||
this.messageSender.sendPush(sender, conversationType, target, line, messageHead, targetSession.getClientID(), pushContent, pushData, messageContentType, serverTime, name, targetName, targetSession.getUnReceivedMsgs(), curMentionType, isHiddenDetail, targetSession.getLanguage());
|
||||
this.messageSender.sendPush(sender, conversationType, target, line, messageId, targetSession.getClientID(), pushContent, pushData, messageContentType, serverTime, name, targetName, targetSession.getUnReceivedMsgs(), curMentionType, isHiddenDetail, targetSession.getLanguage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -37,11 +37,12 @@ class PersistentQueueMessageSender {
|
||||
this.connectionDescriptorStore = connectionDescriptorStore;
|
||||
}
|
||||
|
||||
void sendPush(String sender, int conversationType, String target, int line, long messageHead, String deviceId, String pushContent, String pushData, int messageContentType, long serverTime, String senderName, String targetName, int unReceivedMsg, int mentionType, boolean isHiddenDetail, String language) {
|
||||
void sendPush(String sender, int conversationType, String target, int line, long messageId, String deviceId, String pushContent, String pushData, int messageContentType, long serverTime, String senderName, String targetName, int unReceivedMsg, int mentionType, boolean isHiddenDetail, String language) {
|
||||
LOG.info("Send push to {}, message from {}", deviceId, sender);
|
||||
PushMessage pushMessage = new PushMessage(sender, conversationType, target, line, messageContentType, serverTime, senderName, targetName, unReceivedMsg, mentionType, isHiddenDetail, language);
|
||||
pushMessage.pushContent = pushContent;
|
||||
pushMessage.pushData = pushData;
|
||||
pushMessage.messageId = messageId;
|
||||
PushServer.getServer().pushMessage(pushMessage, deviceId, pushContent);
|
||||
}
|
||||
|
||||
|
||||
@@ -44,12 +44,14 @@ import io.netty.handler.timeout.IdleStateHandler;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import win.liyufan.im.HttpUtils;
|
||||
import win.liyufan.im.IMTopic;
|
||||
import win.liyufan.im.Utility;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import static cn.wildfirechat.common.ErrorCode.ERROR_CODE_SUCCESS;
|
||||
import static io.moquette.spi.impl.InternalRepublisher.createPublishForQos;
|
||||
import static cn.wildfirechat.common.IMExceptionEvent.EventType.EVENT_CALLBACK_Exception;
|
||||
import static io.moquette.spi.impl.Utils.readBytesAndRewind;
|
||||
@@ -582,7 +584,7 @@ public class ProtocolProcessor {
|
||||
|
||||
//disconnect the session
|
||||
|
||||
m_sessionsStore.sessionForClient(clientID).disconnect(isDup, isRetain);
|
||||
m_sessionsStore.sessionForClient(clientID).disconnect(session.getUsername(), isDup, isRetain);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -107,8 +107,12 @@ public class DBUtil {
|
||||
}
|
||||
|
||||
Flyway flyway = Flyway.configure().dataSource(comboPooledDataSource).locations(migrateLocation).baselineOnMigrate(true).load();
|
||||
if(!IsEmbedDB && (flyway.info().current() == null || flyway.info().current().getVersion().getMajor().intValue() < 43)) {
|
||||
System.out.println("数据库执行初始化或升级需要较长时间,可能长达数分钟或更长,请耐心等待,不要中断。。。");
|
||||
if(!IsEmbedDB) {
|
||||
if(flyway.info().current() == null) {
|
||||
System.out.println("数据库执行初始化需要较长时间,可能长达数分钟或更长,请耐心等待,不要中断。。。");
|
||||
} else if(flyway.info().current().getVersion().getMajor().intValue() < 43) {
|
||||
System.out.println("数据库执行升级需要较长时间,可能长达数分钟或更长,请耐心等待,不要中断。。。");
|
||||
}
|
||||
}
|
||||
flyway.migrate();
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
package win.liyufan.im;
|
||||
|
||||
import io.moquette.server.Server;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Properties;
|
||||
|
||||
@@ -34,6 +36,8 @@ public class GitRepositoryState {
|
||||
public final String buildTime;
|
||||
public final String buildHost;
|
||||
public final String buildVersion;
|
||||
public final long runTime;
|
||||
|
||||
|
||||
private GitRepositoryState(Properties properties) {
|
||||
this.tags = String.valueOf(properties.get("git.tags"));
|
||||
@@ -58,6 +62,7 @@ public class GitRepositoryState {
|
||||
this.buildTime = String.valueOf(properties.get("git.build.time"));
|
||||
this.buildHost = String.valueOf(properties.get("git.build.host"));
|
||||
this.buildVersion = String.valueOf(properties.get("git.build.version"));
|
||||
this.runTime = Server.getServer().getRunTime();
|
||||
}
|
||||
|
||||
public static GitRepositoryState getGitRepositoryState() throws IOException {
|
||||
|
||||
@@ -80,4 +80,6 @@ public interface IMTopic {
|
||||
|
||||
String LoadRemoteMessagesTopic = "LRM";
|
||||
String KickoffPCClientTopic = "KPCC";
|
||||
|
||||
String ClearSessionTopic = "CST";
|
||||
}
|
||||
|
||||
@@ -10,4 +10,9 @@ public interface UserSettingScope {
|
||||
int kUserSettingPCOnline = 10;
|
||||
int kUserSettingMuteWhenPCOnline = 15;
|
||||
int kUserSettingNoDisturbing = 17;
|
||||
int kUserSettingConversationClearMessage = 18;
|
||||
int kUserSettingConversationDraft = 19;
|
||||
int kUserSettingDisableSyncDraft = 20;
|
||||
int kUserSettingVoipSilent = 21;
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
<groupId>cn.wildfirechat</groupId>
|
||||
<version>0.70</version>
|
||||
<version>0.72</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ public enum ErrorCode {
|
||||
|
||||
//Auth error
|
||||
ERROR_CODE_TOKEN_ERROR(6, "token error"),
|
||||
ERROR_CODE_KICKED_OFF(7, "kicked off"),
|
||||
ERROR_CODE_USER_FORBIDDEN(8, "user forbidden"),
|
||||
|
||||
//Message error
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<!--<relativePath>../pom.xml</relativePath>-->
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
<groupId>cn.wildfirechat</groupId>
|
||||
<version>0.70</version>
|
||||
<version>0.72</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>distribution</artifactId>
|
||||
|
||||
@@ -94,6 +94,12 @@ message.blacklist_exception_types 401,402,403,404,405,407,408,410,411
|
||||
message.group_mute_exception_types 401,402,403,404,405,407,408,410,411
|
||||
## 用户被全局禁言时允许发送的消息类型
|
||||
message.global_mute_exception_types 401,402,403,404,405,407,408,410,411
|
||||
|
||||
## 消息转发功能开启时,开关是否不转发server api接口消息。
|
||||
## 当为true时,不转发server api发送的消息;当为false时,转发server api发送的消息。
|
||||
message.no_forward_admin_message false
|
||||
|
||||
|
||||
##禁止搜索用户
|
||||
friend.disable_search false
|
||||
|
||||
@@ -212,6 +218,10 @@ server.multi_platform_notification true
|
||||
# 如果这里改为false,客户端那边需要同步修改pc在线默认通知状态,方法是client的setDefaultSilentWhenPcOnline函数。
|
||||
server.mobile_default_silent_when_pc_online true
|
||||
|
||||
## 客户端是否支持kickoff事件。当客户端被其他端登录踢出时,如果此开关为false时,客户端协议栈上报secret_mismatch。如果此开关为ture时,客户端协议栈上报kicked_off。
|
||||
## 客户端被踢时上报kicked_off是在2021.9.15之后才加上的。如果客户端协议栈全部为此日期之后的版本才可以打开此开关。
|
||||
server.client_support_kickoff_event false
|
||||
|
||||
#*********************************************************************
|
||||
# Push server configuration
|
||||
#*********************************************************************
|
||||
@@ -252,6 +262,11 @@ push.ios.server.address http://localhost:8085/ios/push
|
||||
##需要转发的消息类型,当有多个时以英文逗号分割。如果转发所有消息,请注释掉配置或者设置为空
|
||||
#message.forward.types 1,2,3
|
||||
|
||||
##提醒消息转发地址,@全体用户和@某个用户消息会回调此地址。此转发不受${message.forward.types}限制。
|
||||
##注意回调是单线程回调,接收服务必须在同一内网,且异步处理快速返回,否则会有延迟问题!!
|
||||
#message.mentionmsg.forward.url http://localhost:8888/im_event/message
|
||||
|
||||
|
||||
##设备信息转发地址
|
||||
##注意回调是单线程回调,接收服务必须在同一内网,且异步处理快速返回,否则会有延迟问题!!
|
||||
#things_message.forward.url http://localhost:8087/im_event/things/message
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
|
||||
<packaging>pom</packaging>
|
||||
<version>0.70</version>
|
||||
<version>0.72</version>
|
||||
<name>Wildfire Chat</name>
|
||||
<description>Wildfire Chat Server</description>
|
||||
<inceptionYear>2019</inceptionYear>
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
<groupId>cn.wildfirechat</groupId>
|
||||
<version>0.70</version>
|
||||
<version>0.72</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user