Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2fdf11006d | ||
|
|
4a2d7a4cc5 | ||
|
|
0513da8993 |
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
<relativePath>../</relativePath>
|
<relativePath>../</relativePath>
|
||||||
<artifactId>wildfirechat-parent</artifactId>
|
<artifactId>wildfirechat-parent</artifactId>
|
||||||
<groupId>cn.wildfirechat</groupId>
|
<groupId>cn.wildfirechat</groupId>
|
||||||
<version>0.72</version>
|
<version>0.73</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>moquette-broker</artifactId>
|
<artifactId>moquette-broker</artifactId>
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the Wildfire Chat package.
|
||||||
|
* (c) Heavyrain2012 <[email protected]>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.moquette.imhandler;
|
||||||
|
|
||||||
|
import cn.wildfirechat.common.ErrorCode;
|
||||||
|
import cn.wildfirechat.proto.WFCMessage;
|
||||||
|
import com.hazelcast.util.StringUtil;
|
||||||
|
import com.xiaoleilu.loServer.model.FriendData;
|
||||||
|
import io.moquette.spi.impl.Qos1PublishHandler;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import win.liyufan.im.IMTopic;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Handler(value = IMTopic.ClearSessionTopic)
|
||||||
|
public class DisconnectHandler extends IMHandler<Byte> {
|
||||||
|
@Override
|
||||||
|
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, boolean isAdmin, Byte request, Qos1PublishHandler.IMCallback callback) {
|
||||||
|
if (request == 8) {
|
||||||
|
m_sessionsStore.cleanSession(fromUser, clientID);
|
||||||
|
} else if(request == 1) {
|
||||||
|
m_sessionsStore.disableSession(fromUser, clientID);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ErrorCode.ERROR_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,6 +19,7 @@ import win.liyufan.im.I18n;
|
|||||||
import win.liyufan.im.IMTopic;
|
import win.liyufan.im.IMTopic;
|
||||||
import win.liyufan.im.MessageShardingUtil;
|
import win.liyufan.im.MessageShardingUtil;
|
||||||
|
|
||||||
|
import static cn.wildfirechat.common.ErrorCode.ERROR_CODE_ALREADY_FRIENDS;
|
||||||
import static cn.wildfirechat.common.ErrorCode.ERROR_CODE_SUCCESS;
|
import static cn.wildfirechat.common.ErrorCode.ERROR_CODE_SUCCESS;
|
||||||
|
|
||||||
@Handler(IMTopic.HandleFriendRequestTopic)
|
@Handler(IMTopic.HandleFriendRequestTopic)
|
||||||
@@ -86,6 +87,10 @@ public class HandleFriendRequestHandler extends IMHandler<WFCMessage.HandleFrien
|
|||||||
publisher.publishNotification(IMTopic.NotifyFriendTopic, fromUser, heads[1]);
|
publisher.publishNotification(IMTopic.NotifyFriendTopic, fromUser, heads[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(errorCode == ERROR_CODE_ALREADY_FRIENDS) {
|
||||||
|
errorCode = ERROR_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
return errorCode;
|
return errorCode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2856,7 +2856,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
public ErrorCode handleFriendRequest(String userId, WFCMessage.HandleFriendRequest request, WFCMessage.Message.Builder msgBuilder, long[] heads, boolean isAdmin) {
|
public ErrorCode handleFriendRequest(String userId, WFCMessage.HandleFriendRequest request, WFCMessage.Message.Builder msgBuilder, long[] heads, boolean isAdmin) {
|
||||||
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
|
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
|
||||||
|
|
||||||
|
boolean alreadyFriend = false;
|
||||||
if(!isAdmin && request.getStatus() == ProtoConstants.FriendRequestStatus.RequestStatus_Accepted) {
|
if(!isAdmin && request.getStatus() == ProtoConstants.FriendRequestStatus.RequestStatus_Accepted) {
|
||||||
MultiMap<String, FriendData> friendsMap = hzInstance.getMultiMap(USER_FRIENDS);
|
MultiMap<String, FriendData> friendsMap = hzInstance.getMultiMap(USER_FRIENDS);
|
||||||
|
|
||||||
@@ -2868,10 +2868,9 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
for (FriendData fd : friends) {
|
for (FriendData fd : friends) {
|
||||||
if (fd.getFriendUid().equals(request.getTargetUid())) {
|
if (fd.getFriendUid().equals(request.getTargetUid())) {
|
||||||
if (fd.getState() == 0) {
|
if (fd.getState() == 0) {
|
||||||
return ErrorCode.ERROR_CODE_ALREADY_FRIENDS;
|
alreadyFriend = true;
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2950,7 +2949,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (existRequest != null) {
|
if (existRequest != null) {
|
||||||
if (mFriendRequestExpiration > 0 && System.currentTimeMillis() - existRequest.getUpdateDt() > mFriendRequestExpiration) {
|
if (!alreadyFriend && mFriendRequestExpiration > 0 && System.currentTimeMillis() - existRequest.getUpdateDt() > mFriendRequestExpiration) {
|
||||||
return ErrorCode.ERROR_CODE_FRIEND_REQUEST_EXPIRED;
|
return ErrorCode.ERROR_CODE_FRIEND_REQUEST_EXPIRED;
|
||||||
} else {
|
} else {
|
||||||
existRequest = existRequest.toBuilder().setStatus(request.getStatus()).setUpdateDt(System.currentTimeMillis()).build();
|
existRequest = existRequest.toBuilder().setStatus(request.getStatus()).setUpdateDt(System.currentTimeMillis()).build();
|
||||||
@@ -2976,7 +2975,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(request.getStatus() == ProtoConstants.FriendRequestStatus.RequestStatus_Accepted){
|
if(!alreadyFriend && request.getStatus() == ProtoConstants.FriendRequestStatus.RequestStatus_Accepted){
|
||||||
MultiMap<String, FriendData> friendsMap = hzInstance.getMultiMap(USER_FRIENDS);
|
MultiMap<String, FriendData> friendsMap = hzInstance.getMultiMap(USER_FRIENDS);
|
||||||
FriendData friendData1 = new FriendData(userId, request.getTargetUid(), "", request.getExtra(), 0, 0, System.currentTimeMillis());
|
FriendData friendData1 = new FriendData(userId, request.getTargetUid(), "", request.getExtra(), 0, 0, System.currentTimeMillis());
|
||||||
databaseStore.persistOrUpdateFriendData(friendData1);
|
databaseStore.persistOrUpdateFriendData(friendData1);
|
||||||
@@ -2997,6 +2996,9 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
|
|
||||||
callbackRelationEvent(userId, request.getTargetUid(), 0, "1");
|
callbackRelationEvent(userId, request.getTargetUid(), 0, "1");
|
||||||
}
|
}
|
||||||
|
if(alreadyFriend) {
|
||||||
|
return ErrorCode.ERROR_CODE_ALREADY_FRIENDS;
|
||||||
|
}
|
||||||
return ErrorCode.ERROR_CODE_SUCCESS;
|
return ErrorCode.ERROR_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>wildfirechat-parent</artifactId>
|
<artifactId>wildfirechat-parent</artifactId>
|
||||||
<groupId>cn.wildfirechat</groupId>
|
<groupId>cn.wildfirechat</groupId>
|
||||||
<version>0.72</version>
|
<version>0.73</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<!--<relativePath>../pom.xml</relativePath>-->
|
<!--<relativePath>../pom.xml</relativePath>-->
|
||||||
<artifactId>wildfirechat-parent</artifactId>
|
<artifactId>wildfirechat-parent</artifactId>
|
||||||
<groupId>cn.wildfirechat</groupId>
|
<groupId>cn.wildfirechat</groupId>
|
||||||
<version>0.72</version>
|
<version>0.73</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>distribution</artifactId>
|
<artifactId>distribution</artifactId>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
<artifactId>wildfirechat-parent</artifactId>
|
<artifactId>wildfirechat-parent</artifactId>
|
||||||
|
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<version>0.72</version>
|
<version>0.73</version>
|
||||||
<name>Wildfire Chat</name>
|
<name>Wildfire Chat</name>
|
||||||
<description>Wildfire Chat Server</description>
|
<description>Wildfire Chat Server</description>
|
||||||
<inceptionYear>2019</inceptionYear>
|
<inceptionYear>2019</inceptionYear>
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>wildfirechat-parent</artifactId>
|
<artifactId>wildfirechat-parent</artifactId>
|
||||||
<groupId>cn.wildfirechat</groupId>
|
<groupId>cn.wildfirechat</groupId>
|
||||||
<version>0.72</version>
|
<version>0.73</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user