diff --git a/broker/config/wildfirechat.conf b/broker/config/wildfirechat.conf index a0cabb3d..ead437b5 100755 --- a/broker/config/wildfirechat.conf +++ b/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 diff --git a/broker/src/main/java/io/moquette/BrokerConstants.java b/broker/src/main/java/io/moquette/BrokerConstants.java index 4b1e493a..89c93f0d 100755 --- a/broker/src/main/java/io/moquette/BrokerConstants.java +++ b/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"; diff --git a/broker/src/main/java/io/moquette/persistence/MemoryMessagesStore.java b/broker/src/main/java/io/moquette/persistence/MemoryMessagesStore.java index 1a36b8df..7b6d9478 100755 --- a/broker/src/main/java/io/moquette/persistence/MemoryMessagesStore.java +++ b/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 getClientForbiddenSendTypes() { return mForbiddenClientSendTypes; diff --git a/broker/src/main/java/io/moquette/spi/IMessagesStore.java b/broker/src/main/java/io/moquette/spi/IMessagesStore.java index a40ef573..f7400984 100755 --- a/broker/src/main/java/io/moquette/spi/IMessagesStore.java +++ b/broker/src/main/java/io/moquette/spi/IMessagesStore.java @@ -244,6 +244,8 @@ public interface IMessagesStore { boolean isRobotAutoAcceptFriendRequest(); + long getPushExpiredTimes(); + List getClientForbiddenSendTypes(); List getBlackListExceptionTypes(); List getGroupMuteExceptionTypes(); diff --git a/broker/src/main/java/io/moquette/spi/impl/MessagesPublisher.java b/broker/src/main/java/io/moquette/spi/impl/MessagesPublisher.java index 76829c9f..ef2e87a9 100755 --- a/broker/src/main/java/io/moquette/spi/impl/MessagesPublisher.java +++ b/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; } diff --git a/distribution/src/main/resources/wildfirechat.conf b/distribution/src/main/resources/wildfirechat.conf index 59b58773..ce68aff6 100755 --- a/distribution/src/main/resources/wildfirechat.conf +++ b/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