解决广播没有发送消息给未登录用户的问题

This commit is contained in:
heavyrian2012
2023-12-02 23:03:00 +08:00
parent 90e89978aa
commit 594103e06b
5 changed files with 26 additions and 5 deletions
+3
View File
@@ -126,6 +126,9 @@ message.global_mute_exception_types 401,402,403,404,405,407,408,410,411
## 离线用户推送过期天数,0是永不过期,建议配置为7天。
message.push_expired_days 7
## 群发消息(包括server api群发和全局频道群发)时,目标用户是否来自于t_user表。如果使用野火托管用户信息,请设置为true,否则设置为false。
message.broadcast.target_from_user_table true
## 消息转发功能开启时,开关是否不转发server api接口消息。
## 当为true时,不转发server api发送的消息;当为false时,转发server api发送的消息。
message.no_forward_admin_message false
@@ -156,6 +156,9 @@ public final class BrokerConstants {
public static final String MESSAGE_Push_Expired_Days = "message.push_expired_days";
public static final String MESSAGE_Forward_With_Client_Info = "message.forward_with_client_info";
public static final String BROADCAST_Target_From_User_Table = "message.broadcast.target_from_user_table";
public static final String ROBOT_Callback_With_Client_Info = "robot.callback_with_client_info";
public static final String CHANNEL_Callback_With_Client_Info = "channel.callback_with_client_info";
@@ -3000,17 +3000,20 @@ public class DatabaseStore {
return outList;
}
Set<String> getAllEnds() {
Set<String> getAllEnds(boolean fromUserTable) {
Connection connection = null;
PreparedStatement statement = null;
ResultSet rs = null;
try {
connection = DBUtil.getConnection();
String sql = "select distinct(`_uid`) from t_user_session where `_deleted` = 0";
String sql;
if(fromUserTable) {
sql = "select distinct(`_uid`) from t_user_session";
} else {
sql = "select distinct(`_uid`) from t_user where `_deleted` = 0 and `_type` <> 1 and `_type` <> 2";
}
statement = connection.prepareStatement(sql);
rs = statement.executeQuery();
Set<String> out = new HashSet<>();
while (rs.next()) {
@@ -192,6 +192,8 @@ public class MemoryMessagesStore implements IMessagesStore {
private boolean keepDisplayNameWhenDestroyUser = true;
private String mRecallForwardUrl = null;
private boolean mBroadcastTargetFromUserTable = false;
private boolean mForwardMessageWithClientInfo = false;
private boolean mRobotCallbackWithClientInfo = false;
private boolean mChannelCallbackWithClientInfo = false;
@@ -560,6 +562,13 @@ public class MemoryMessagesStore implements IMessagesStore {
} catch (Exception e) {
}
try {
mBroadcastTargetFromUserTable = Boolean.parseBoolean(server.getConfig().getProperty(BrokerConstants.BROADCAST_Target_From_User_Table, "false"));
} catch (Exception e) {
}
try {
mRobotCallbackWithClientInfo = Boolean.parseBoolean(server.getConfig().getProperty(BrokerConstants.ROBOT_Callback_With_Client_Info, "false"));
} catch (Exception e) {
@@ -748,7 +757,7 @@ public class MemoryMessagesStore implements IMessagesStore {
@Override
public Set<String> getAllEnds() {
return databaseStore.getAllEnds();
return databaseStore.getAllEnds(mBroadcastTargetFromUserTable);
}
@Override
public WFCMessage.PullMessageResult fetchMessage(String user, String exceptClientId, long fromMessageId, int pullType) {
@@ -124,6 +124,9 @@ message.global_mute_exception_types 401,402,403,404,405,407,408,410,411
## 离线用户推送过期天数,0是永不过期,建议配置为7天。
message.push_expired_days 7
## 群发消息(包括server api群发和全局频道群发)时,目标用户是否来自于t_user表。如果使用野火托管用户信息,请设置为true,否则设置为false。
message.broadcast.target_from_user_table true
## 消息转发功能开启时,开关是否不转发server api接口消息。
## 当为true时,不转发server api发送的消息;当为false时,转发server api发送的消息。
message.no_forward_admin_message false