添加锁定PC的设置,当离线时自动解除

This commit is contained in:
heavyrian2012
2026-02-23 11:50:32 +08:00
parent efd9d5519f
commit 8f74e54c88
3 changed files with 18 additions and 2 deletions
@@ -78,8 +78,7 @@ import static io.moquette.BrokerConstants.*;
import static io.moquette.server.Constants.MAX_CHATROOM_MESSAGE_QUEUE; import static io.moquette.server.Constants.MAX_CHATROOM_MESSAGE_QUEUE;
import static io.moquette.server.Constants.MAX_MESSAGE_QUEUE; import static io.moquette.server.Constants.MAX_MESSAGE_QUEUE;
import static cn.wildfirechat.pojos.MyInfoType.*; import static cn.wildfirechat.pojos.MyInfoType.*;
import static win.liyufan.im.UserSettingScope.kUserSettingAddFriendStrategy; import static win.liyufan.im.UserSettingScope.*;
import static win.liyufan.im.UserSettingScope.kUserSettingPCOnline;
public class MemoryMessagesStore implements IMessagesStore { public class MemoryMessagesStore implements IMessagesStore {
private static final String MESSAGES_MAP = "messages_map"; private static final String MESSAGES_MAP = "messages_map";
@@ -3025,6 +3024,13 @@ public class MemoryMessagesStore implements IMessagesStore {
return; return;
} }
if(!online && (session.isPcClient()) || session.isPadClient()) {
WFCMessage.UserSettingEntry lockSetting = getUserSetting(session.getUsername(), UserSettingScopeLockPC, session.getClientID());
if(lockSetting != null && "1".equals(lockSetting.getValue())) {
updateUserSettings(session.getUsername(), WFCMessage.ModifyUserSettingReq.newBuilder().setScope(UserSettingScopeLockPC).setKey(session.getClientID()).setValue("0").build(), null);
}
}
String pcValue = null; String pcValue = null;
String padValue = null; String padValue = null;
for (MemorySessionStore.Session s : m_Server.getStore().sessionsStore().sessionForUser(session.username)) { for (MemorySessionStore.Session s : m_Server.getStore().sessionsStore().sessionForUser(session.username)) {
@@ -93,6 +93,15 @@ public class MemorySessionStore implements ISessionsStore {
return unReceivedMsgs; return unReceivedMsgs;
} }
public boolean isPcClient() {
return platform == ProtoConstants.Platform.Platform_Windows || platform == ProtoConstants.Platform.Platform_OSX || platform == ProtoConstants.Platform.Platform_LINUX;
}
public boolean isPadClient() {
return platform == ProtoConstants.Platform.Platform_iPad || platform == ProtoConstants.Platform.Platform_APad || platform == ProtoConstants.Platform.Platform_HarmonyPad;
}
public int getPushType() { public int getPushType() {
return pushType; return pushType;
} }
@@ -22,4 +22,5 @@ public interface UserSettingScope {
int kUserSettingPrivacySearchable = 27; int kUserSettingPrivacySearchable = 27;
int kUserSettingAddFriendStrategy = 28; int kUserSettingAddFriendStrategy = 28;
int kUserSettingScopeSyncBadge = 29; int kUserSettingScopeSyncBadge = 29;
int UserSettingScopeLockPC = 30;
} }