Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6f5b021c89 | ||
|
|
f8f225d741 | ||
|
|
546110f6d3 | ||
|
|
c7dbf45af6 |
+1
-1
@@ -5,7 +5,7 @@
|
||||
<relativePath>../</relativePath>
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
<groupId>cn.wildfirechat</groupId>
|
||||
<version>0.80</version>
|
||||
<version>0.81</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>moquette-broker</artifactId>
|
||||
|
||||
@@ -94,13 +94,9 @@ public class PushServer {
|
||||
pushMessage.deviceToken = session.getDeviceToken();
|
||||
pushMessage.unReceivedMsg = badge;
|
||||
pushMessage.userId = session.getUsername();
|
||||
if (session.getPlatform() == ProtoConstants.Platform.Platform_iOS
|
||||
|| session.getPlatform() == ProtoConstants.Platform.Platform_Android
|
||||
|| session.getPlatform() == ProtoConstants.Platform.Platform_iPad
|
||||
|| session.getPlatform() == ProtoConstants.Platform.Platform_APad) {
|
||||
if (session.getPlatform() == ProtoConstants.Platform.Platform_iOS || session.getPlatform() == ProtoConstants.Platform.Platform_Android) {
|
||||
String url = androidPushServerUrl;
|
||||
if (session.getPlatform() == ProtoConstants.Platform.Platform_iOS
|
||||
|| session.getPlatform() == ProtoConstants.Platform.Platform_iPad) {
|
||||
if (session.getPlatform() == ProtoConstants.Platform.Platform_iOS) {
|
||||
url = iOSPushServerUrl;
|
||||
pushMessage.voipDeviceToken = session.getVoipDeviceToken();
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public class UploadDeviceTokenHandler extends IMHandler<WFCMessage.UploadDeviceT
|
||||
MemorySessionStore.Session session = m_sessionsStore.getSession(clientID);
|
||||
session.setPlatform(request.getPlatform());
|
||||
session.setAppName(request.getAppName());
|
||||
if ((request.getPlatform() == ProtoConstants.Platform.Platform_iOS || request.getPlatform() == ProtoConstants.Platform.Platform_iPad) && request.getPushType() == 2) {
|
||||
if (request.getPlatform() == ProtoConstants.Platform.Platform_iOS && request.getPushType() == 2) {
|
||||
session.setVoipDeviceToken(request.getDeviceToken());
|
||||
m_sessionsStore.updateSessionToken(session, true);
|
||||
} else {
|
||||
|
||||
@@ -914,20 +914,24 @@ public class DatabaseStore {
|
||||
return false;
|
||||
}
|
||||
|
||||
void persistUserMessage(final String userId, final long messageId, final long messageSeq, final int messageContentType) {
|
||||
void persistUserMessage(final String userId, final long messageId, final long messageSeq, int type, String target, int line, boolean directing, final int messageContentType) {
|
||||
mScheduler.execute(()->{
|
||||
Connection connection = null;
|
||||
PreparedStatement statement = null;
|
||||
try {
|
||||
connection = DBUtil.getConnection();
|
||||
|
||||
String sql = "insert into " + getUserMessageTable(userId) + " (`_mid`, `_uid`, `_seq`, `_cont_type`) values(?, ?, ?, ?)";
|
||||
String sql = "insert into " + getUserMessageTable(userId) + " (`_mid`, `_uid`, `_seq`, `_type`, `_target`, `_line`, `_directing`, `_cont_type`) values(?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
|
||||
statement = connection.prepareStatement(sql);
|
||||
int index = 1;
|
||||
statement.setLong(index++, messageId);
|
||||
statement.setString(index++, userId);
|
||||
statement.setLong(index++, messageSeq);
|
||||
statement.setInt(index++, type);
|
||||
statement.setString(index++, target);
|
||||
statement.setInt(index++, line);
|
||||
statement.setInt(index++, directing ? 1 :0);
|
||||
statement.setInt(index++, messageContentType);
|
||||
int count = statement.executeUpdate();
|
||||
LOG.info("Update rows {}", count);
|
||||
@@ -1573,8 +1577,6 @@ public class DatabaseStore {
|
||||
sql = "update t_user_session set `_deleted` = ?, `_token` = ?, `_voip_token` = ?, `_dt` = ? where `_uid`=? and (`_platform` = ? or `_platform` = ? or `_platform` = ?) and `_cid` <> ? and `_deleted` = 0";
|
||||
} else if(platform == ProtoConstants.Platform.Platform_iOS || platform == ProtoConstants.Platform.Platform_Android) {
|
||||
sql = "update t_user_session set `_deleted` = ?, `_token` = ?, `_voip_token` = ?, `_dt` = ? where `_uid`=? and (`_platform` = ? or `_platform` = ?) and `_cid` <> ? and `_deleted` = 0";
|
||||
} else if(platform == ProtoConstants.Platform.Platform_iPad || platform == ProtoConstants.Platform.Platform_APad) {
|
||||
sql = "update t_user_session set `_deleted` = ?, `_token` = ?, `_voip_token` = ?, `_dt` = ? where `_uid`=? and (`_platform` = ? or `_platform` = ?) and `_cid` <> ? and `_deleted` = 0";
|
||||
} else {
|
||||
sql = "update t_user_session set `_deleted` = ?, `_token` = ?, `_voip_token` = ?, `_dt` = ? where `_uid`=? and `_platform` = ? and `_cid` <> ? and `_deleted` = 0";
|
||||
}
|
||||
@@ -1596,9 +1598,6 @@ public class DatabaseStore {
|
||||
} else if(platform == ProtoConstants.Platform.Platform_iOS || platform == ProtoConstants.Platform.Platform_Android) {
|
||||
statement.setInt(index++, ProtoConstants.Platform.Platform_iOS);
|
||||
statement.setInt(index++, ProtoConstants.Platform.Platform_Android);
|
||||
} else if(platform == ProtoConstants.Platform.Platform_iPad || platform == ProtoConstants.Platform.Platform_APad) {
|
||||
statement.setInt(index++, ProtoConstants.Platform.Platform_iPad);
|
||||
statement.setInt(index++, ProtoConstants.Platform.Platform_APad);
|
||||
} else {
|
||||
statement.setInt(index++, platform);
|
||||
}
|
||||
|
||||
@@ -866,7 +866,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
}
|
||||
|
||||
@Override
|
||||
public long insertUserMessages(String sender, int conversationType, String target, int line, int messageContentType, String user, long messageId) {
|
||||
public long insertUserMessages(String sender, int conversationType, String target, int line, int messageContentType, String user, long messageId, boolean directing) {
|
||||
// messageId是全局的,messageSeq是跟个人相关的,理论上messageId的增长数度远远大于seq。
|
||||
// 考虑到一种情况,当服务器发生变化,用户发生迁移后,messageSeq还需要保持有序。 要么把Seq持久化,要么在迁移后Seq取一个肯定比以前更大的数字(这个数字就是messageId)
|
||||
// 这里选择使用后面一种情况
|
||||
@@ -906,7 +906,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
mWriteLock.unlock();
|
||||
}
|
||||
|
||||
databaseStore.persistUserMessage(user, messageId, messageSeq, messageContentType);
|
||||
databaseStore.persistUserMessage(user, messageId, messageSeq, conversationType, target, line, directing, messageContentType);
|
||||
return messageSeq;
|
||||
}
|
||||
|
||||
@@ -2313,6 +2313,24 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
|
||||
}
|
||||
|
||||
public void forceCleanOnlineStatus(String userId, String clientId) {
|
||||
if (m_Server.isShutdowning()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!mMultiPlatformNotification || m_Server.getStore().sessionsStore().isMultiEndpointSupported()) {
|
||||
WFCMessage.UserSettingEntry pcentry = getUserSetting(userId, kUserSettingPCOnline, "PC");
|
||||
if (pcentry != null && !StringUtil.isNullOrEmpty(pcentry.getValue()) && pcentry.getValue().contains(clientId)) {
|
||||
updateUserSettings(userId, WFCMessage.ModifyUserSettingReq.newBuilder().setScope(kUserSettingPCOnline).setKey("PC").setValue("").build(), clientId);
|
||||
}
|
||||
|
||||
WFCMessage.UserSettingEntry padentry = getUserSetting(userId, kUserSettingPCOnline, "Pad");
|
||||
if (padentry != null && !StringUtil.isNullOrEmpty(padentry.getValue()) && padentry.getValue().contains(clientId)) {
|
||||
updateUserSettings(userId, WFCMessage.ModifyUserSettingReq.newBuilder().setScope(kUserSettingPCOnline).setKey("Pad").setValue("").build(), clientId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUserOnlineSetting(MemorySessionStore.Session session, boolean online) {
|
||||
if(!mMultiPlatformNotification) {
|
||||
@@ -2327,7 +2345,6 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
}
|
||||
|
||||
String pcValue = null;
|
||||
String padValue = null;
|
||||
for (MemorySessionStore.Session s : m_Server.getStore().sessionsStore().sessionForUser(session.username)) {
|
||||
if (s.getDeleted() != 0 || !m_Server.getConnectionsManager().isConnected(s.getClientID())) {
|
||||
continue;
|
||||
@@ -2339,10 +2356,6 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
case Platform_OSX:
|
||||
pcValue = System.currentTimeMillis() + "|" + s.getPlatform() + "|" + s.getClientID() + "|" + s.getPhoneName();
|
||||
break;
|
||||
case Platform_iPad:
|
||||
case Platform_APad:
|
||||
padValue = System.currentTimeMillis() + "|" + s.getPlatform() + "|" + s.getClientID() + "|" + s.getPhoneName();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -2358,17 +2371,6 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
updateUserSettings(session.username, WFCMessage.ModifyUserSettingReq.newBuilder().setScope(kUserSettingPCOnline).setKey("PC").setValue("").build(), session.clientID);
|
||||
}
|
||||
}
|
||||
|
||||
WFCMessage.UserSettingEntry padentry = getUserSetting(session.getUsername(), kUserSettingPCOnline, "Pad");
|
||||
if (padValue != null) {
|
||||
if (padentry == null || StringUtil.isNullOrEmpty(padentry.getValue())) {
|
||||
updateUserSettings(session.username, WFCMessage.ModifyUserSettingReq.newBuilder().setScope(kUserSettingPCOnline).setKey("Pad").setValue(padValue).build(), session.clientID);
|
||||
}
|
||||
} else {
|
||||
if (padentry != null && !StringUtil.isNullOrEmpty(padentry.getValue())) {
|
||||
updateUserSettings(session.username, WFCMessage.ModifyUserSettingReq.newBuilder().setScope(kUserSettingPCOnline).setKey("Pad").setValue("").build(), session.clientID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -407,10 +407,6 @@ public class MemorySessionStore implements ISessionsStore {
|
||||
if (s.getPlatform() == ProtoConstants.Platform.Platform_OSX || s.getPlatform() == ProtoConstants.Platform.Platform_Windows || platform == ProtoConstants.Platform.Platform_LINUX) {
|
||||
remove = true;
|
||||
}
|
||||
} else if(platform == ProtoConstants.Platform.Platform_iPad || platform == ProtoConstants.Platform.Platform_APad) {
|
||||
if (s.getPlatform() == ProtoConstants.Platform.Platform_iPad || s.getPlatform() == ProtoConstants.Platform.Platform_APad) {
|
||||
remove = true;
|
||||
}
|
||||
} else {
|
||||
if (s.getPlatform() ==platform) {
|
||||
remove = true;
|
||||
@@ -729,14 +725,13 @@ public class MemorySessionStore implements ISessionsStore {
|
||||
if (session != null) {
|
||||
if(!operator.equals(session.getUsername())) {
|
||||
LOG.error("kickoffPCClient failure, user {} don't have client {}", operator, pcClientId);
|
||||
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||
mServer.getProcessor().getMessagesStore().forceCleanOnlineStatus(operator, pcClientId);
|
||||
return ErrorCode.ERROR_CODE_SUCCESS;
|
||||
}
|
||||
if (session.getPlatform() == ProtoConstants.Platform.Platform_LINUX
|
||||
|| session.getPlatform() == ProtoConstants.Platform.Platform_WEB
|
||||
|| session.getPlatform() == ProtoConstants.Platform.Platform_Windows
|
||||
|| session.getPlatform() == ProtoConstants.Platform.Platform_OSX
|
||||
|| session.getPlatform() == ProtoConstants.Platform.Platform_iPad
|
||||
|| session.getPlatform() == ProtoConstants.Platform.Platform_APad
|
||||
) {
|
||||
|| session.getPlatform() == ProtoConstants.Platform.Platform_OSX) {
|
||||
databaseStore.updateSessionDeleted(operator, pcClientId, 1);
|
||||
sessions.remove(pcClientId);
|
||||
mServer.getProcessor().kickoffSession(session);
|
||||
@@ -746,6 +741,7 @@ public class MemorySessionStore implements ISessionsStore {
|
||||
}
|
||||
} else {
|
||||
LOG.error("Can't find the session for client <{}>", pcClientId);
|
||||
mServer.getProcessor().getMessagesStore().forceCleanOnlineStatus(operator, pcClientId);
|
||||
}
|
||||
return ErrorCode.ERROR_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ public interface IMessagesStore {
|
||||
Set<String> getAllEnds();
|
||||
WFCMessage.PullMessageResult fetchMessage(String user, String exceptClientId, long fromMessageId, int pullType);
|
||||
WFCMessage.PullMessageResult loadRemoteMessages(String user, WFCMessage.Conversation conversation, long beforeUid, int count, Collection<Integer> contentTypes);
|
||||
long insertUserMessages(String sender, int conversationType, String target, int line, int messageContentType, String userId, long messageId);
|
||||
long insertUserMessages(String sender, int conversationType, String target, int line, int messageContentType, String userId, long messageId, boolean directing);
|
||||
WFCMessage.GroupInfo createGroup(String operator, WFCMessage.GroupInfo groupInfo, List<WFCMessage.GroupMember> memberList, String memberExtra, boolean isAdmin);
|
||||
ErrorCode addGroupMembers(String operator, boolean isAdmin, String groupId, List<WFCMessage.GroupMember> memberList, String extra);
|
||||
ErrorCode kickoffGroupMembers(String operator, boolean isAdmin, String groupId, List<String> memberList);
|
||||
@@ -140,6 +140,8 @@ public interface IMessagesStore {
|
||||
|
||||
ErrorCode modifyUserInfo(String userId, WFCMessage.ModifyMyInfoRequest request) throws Exception;
|
||||
|
||||
void forceCleanOnlineStatus(String userId, String clientId);
|
||||
|
||||
void updateUserOnlineSetting(MemorySessionStore.Session session, boolean online);
|
||||
|
||||
ErrorCode modifyUserStatus(String userId, int status);
|
||||
|
||||
@@ -160,7 +160,7 @@ public class MessagesPublisher {
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
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, boolean directing) {
|
||||
if (persistFlag == Transparent) {
|
||||
publishTransparentMessage2Receivers(messageId, receivers, pullType, exceptClientId);
|
||||
return;
|
||||
@@ -191,7 +191,7 @@ public class MessagesPublisher {
|
||||
}
|
||||
long messageSeq;
|
||||
if (pullType != ProtoConstants.PullType.Pull_ChatRoom) {
|
||||
messageSeq = m_messagesStore.insertUserMessages(sender, conversationType, target, line, messageContentType, user, messageId);
|
||||
messageSeq = m_messagesStore.insertUserMessages(sender, conversationType, target, line, messageContentType, user, messageId, directing);
|
||||
} else {
|
||||
messageSeq = m_messagesStore.insertChatroomMessages(user, line, messageId);
|
||||
}
|
||||
@@ -213,9 +213,7 @@ public class MessagesPublisher {
|
||||
if (targetSession.getPlatform() == ProtoConstants.Platform.Platform_WEB
|
||||
|| targetSession.getPlatform() == ProtoConstants.Platform.Platform_Windows
|
||||
|| targetSession.getPlatform() == ProtoConstants.Platform.Platform_LINUX
|
||||
|| targetSession.getPlatform() == ProtoConstants.Platform.Platform_OSX
|
||||
|| targetSession.getPlatform() == ProtoConstants.Platform.Platform_iPad
|
||||
|| targetSession.getPlatform() == ProtoConstants.Platform.Platform_APad) {
|
||||
|| targetSession.getPlatform() == ProtoConstants.Platform.Platform_OSX) {
|
||||
boolean targetIsActive = this.connectionDescriptors.isConnected(targetSession.getClientSession().clientID);
|
||||
if (targetIsActive) {
|
||||
isPcOnline = true;
|
||||
@@ -646,7 +644,7 @@ public class MessagesPublisher {
|
||||
message.getConversation().getType(), message.getConversation().getTarget(), message.getConversation().getLine(),
|
||||
messageId,
|
||||
receivers,
|
||||
pushContent, message.getContent().getPushData(), exceptClientId, pullType, message.getContent().getType(), message.getServerTimestamp(), message.getContent().getMentionedType(), message.getContent().getMentionedTargetList(), message.getContent().getPersistFlag());
|
||||
pushContent, message.getContent().getPushData(), exceptClientId, pullType, message.getContent().getType(), message.getServerTimestamp(), message.getContent().getMentionedType(), message.getContent().getMentionedTargetList(), message.getContent().getPersistFlag(), message.hasToUser() || !message.getToList().isEmpty());
|
||||
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
<groupId>cn.wildfirechat</groupId>
|
||||
<version>0.80</version>
|
||||
<version>0.81</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<!--<relativePath>../pom.xml</relativePath>-->
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
<groupId>cn.wildfirechat</groupId>
|
||||
<version>0.80</version>
|
||||
<version>0.81</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>distribution</artifactId>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
|
||||
<packaging>pom</packaging>
|
||||
<version>0.80</version>
|
||||
<version>0.81</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.80</version>
|
||||
<version>0.81</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user