Przeglądaj źródła

添加推送过期配置

heavyrian2012 2 lat temu
rodzic
commit
4e6188ee32

+ 3 - 0
broker/config/wildfirechat.conf

@@ -123,6 +123,9 @@ 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
 
+## 离线用户推送过期天数,0是永不过期,建议配置为7天。
+message.push_expired_days 7
+
 ## 消息转发功能开启时,开关是否不转发server api接口消息。
 ## 当为true时,不转发server api发送的消息;当为false时,转发server api发送的消息。
 message.no_forward_admin_message false

+ 2 - 0
broker/src/main/java/io/moquette/BrokerConstants.java

@@ -153,6 +153,8 @@ public final class BrokerConstants {
 
     public static final String MESSAGE_NO_Forward_Admin_Message = "message.no_forward_admin_message";
 
+    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 ROBOT_Callback_With_Client_Info = "robot.callback_with_client_info";
     public static final String CHANNEL_Callback_With_Client_Info = "channel.callback_with_client_info";

+ 13 - 0
broker/src/main/java/io/moquette/persistence/MemoryMessagesStore.java

@@ -145,6 +145,8 @@ public class MemoryMessagesStore implements IMessagesStore {
     private long mFriendRequestExpiration = 7 * 24 * 60 * 60 * 1000;
     private boolean mFriendRobotAutoAccept = true;
 
+    private long mPushExpiredTimes = 604800000L;
+
     private boolean mMultiPlatformNotification = false;
     private boolean mMobileDefaultSilentWhenPCOnline = true;
     private boolean mDisableStrangerChat = false;
@@ -306,6 +308,12 @@ public class MemoryMessagesStore implements IMessagesStore {
         } catch (Exception e) {
         }
 
+        try {
+            mPushExpiredTimes = Long.parseLong(m_Server.getConfig().getProperty(BrokerConstants.MESSAGE_Push_Expired_Days, "7")) * 86400000L;
+            if(mPushExpiredTimes == 0) mPushExpiredTimes = Long.MAX_VALUE;
+        } catch (Exception e) {
+        }
+
         try {
             mChatroomRejoinWhenActive = Boolean.parseBoolean(m_Server.getConfig().getProperty(BrokerConstants.CHATROOM_Rejoin_When_Active));
         } catch (Exception e) {
@@ -4329,6 +4337,11 @@ public class MemoryMessagesStore implements IMessagesStore {
         return mFriendRobotAutoAccept;
     }
 
+    @Override
+    public long getPushExpiredTimes() {
+        return mPushExpiredTimes;
+    }
+
     @Override
     public List<Integer> getClientForbiddenSendTypes() {
         return mForbiddenClientSendTypes;

+ 2 - 0
broker/src/main/java/io/moquette/spi/IMessagesStore.java

@@ -244,6 +244,8 @@ public interface IMessagesStore {
 
     boolean isRobotAutoAcceptFriendRequest();
 
+    long getPushExpiredTimes();
+
     List<Integer> getClientForbiddenSendTypes();
     List<Integer> getBlackListExceptionTypes();
     List<Integer> getGroupMuteExceptionTypes();

+ 1 - 1
broker/src/main/java/io/moquette/spi/impl/MessagesPublisher.java

@@ -235,7 +235,7 @@ public class MessagesPublisher {
 
             for (Session targetSession : sessions) {
                 //超过7天不活跃的用户忽略
-                if(System.currentTimeMillis() - targetSession.getLastActiveTime() > 7 * 24 * 60 * 60 * 1000) {
+                if(System.currentTimeMillis() - targetSession.getLastActiveTime() > m_messagesStore.getPushExpiredTimes()) {
                     continue;
                 }
 

+ 3 - 0
distribution/src/main/resources/wildfirechat.conf

@@ -121,6 +121,9 @@ 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
 
+## 离线用户推送过期天数,0是永不过期,建议配置为7天。
+message.push_expired_days 7
+
 ## 消息转发功能开启时,开关是否不转发server api接口消息。
 ## 当为true时,不转发server api发送的消息;当为false时,转发server api发送的消息。
 message.no_forward_admin_message false