Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c74cddc387 | ||
|
|
b2e4fd9546 | ||
|
|
9e8c364642 | ||
|
|
8127ec03ad |
+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.74</version>
|
<version>0.75</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>moquette-broker</artifactId>
|
<artifactId>moquette-broker</artifactId>
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
package io.moquette.imhandler;
|
package io.moquette.imhandler;
|
||||||
|
|
||||||
import cn.wildfirechat.proto.WFCMessage;
|
import cn.wildfirechat.proto.WFCMessage;
|
||||||
|
import com.xiaoleilu.hutool.system.UserInfo;
|
||||||
import io.moquette.persistence.MemorySessionStore;
|
import io.moquette.persistence.MemorySessionStore;
|
||||||
import io.moquette.spi.impl.Qos1PublishHandler;
|
import io.moquette.spi.impl.Qos1PublishHandler;
|
||||||
import io.moquette.spi.impl.security.TokenAuthenticator;
|
import io.moquette.spi.impl.security.TokenAuthenticator;
|
||||||
@@ -21,6 +22,11 @@ public class GetTokenHandler extends IMHandler<WFCMessage.GetTokenRequest> {
|
|||||||
@Override
|
@Override
|
||||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, boolean isAdmin, WFCMessage.GetTokenRequest request, Qos1PublishHandler.IMCallback callback) {
|
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, boolean isAdmin, WFCMessage.GetTokenRequest request, Qos1PublishHandler.IMCallback callback) {
|
||||||
MemorySessionStore.Session session = m_sessionsStore.updateOrCreateUserSession(fromUser, clientID, request.getPlatform());
|
MemorySessionStore.Session session = m_sessionsStore.updateOrCreateUserSession(fromUser, clientID, request.getPlatform());
|
||||||
|
WFCMessage.User userInfo = m_messagesStore.getUserInfo(fromUser);
|
||||||
|
if(userInfo != null && userInfo.getType() == 1) {
|
||||||
|
return ErrorCode.ERROR_CODE_ROBOT_NO_TOKEN;
|
||||||
|
}
|
||||||
|
|
||||||
TokenAuthenticator authenticator = new TokenAuthenticator();
|
TokenAuthenticator authenticator = new TokenAuthenticator();
|
||||||
String strToken = authenticator.generateToken(fromUser);
|
String strToken = authenticator.generateToken(fromUser);
|
||||||
String result = strToken + "|" + session.getSecret() + "|" + session.getDbSecret();
|
String result = strToken + "|" + session.getSecret() + "|" + session.getDbSecret();
|
||||||
|
|||||||
@@ -58,8 +58,7 @@ public class HandleFriendRequestHandler extends IMHandler<WFCMessage.HandleFrien
|
|||||||
builder.setFromUser(request.getTargetUid());
|
builder.setFromUser(request.getTargetUid());
|
||||||
builder.setConversation(WFCMessage.Conversation.newBuilder().setTarget(fromUser).setLine(0).setType(ProtoConstants.ConversationType.ConversationType_Private).build());
|
builder.setConversation(WFCMessage.Conversation.newBuilder().setTarget(fromUser).setLine(0).setType(ProtoConstants.ConversationType.ConversationType_Private).build());
|
||||||
builder.setContent(contentBuilder);
|
builder.setContent(contentBuilder);
|
||||||
timestamp = System.currentTimeMillis();
|
builder.setServerTimestamp(++timestamp);
|
||||||
builder.setServerTimestamp(timestamp);
|
|
||||||
|
|
||||||
messageId = MessageShardingUtil.generateId();
|
messageId = MessageShardingUtil.generateId();
|
||||||
builder.setMessageId(messageId);
|
builder.setMessageId(messageId);
|
||||||
@@ -74,10 +73,8 @@ public class HandleFriendRequestHandler extends IMHandler<WFCMessage.HandleFrien
|
|||||||
builder.setContent(contentBuilder);
|
builder.setContent(contentBuilder);
|
||||||
messageId = MessageShardingUtil.generateId();
|
messageId = MessageShardingUtil.generateId();
|
||||||
builder.setMessageId(messageId);
|
builder.setMessageId(messageId);
|
||||||
timestamp = System.currentTimeMillis();
|
builder.setServerTimestamp(++timestamp);
|
||||||
builder.setServerTimestamp(timestamp);
|
|
||||||
saveAndPublish(request.getTargetUid(), null, builder.build());
|
saveAndPublish(request.getTargetUid(), null, builder.build());
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
+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.74</version>
|
<version>0.75</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,9 @@ public enum ErrorCode {
|
|||||||
ERROR_CODE_ALREADY_FRIENDS(23, "already friends"),
|
ERROR_CODE_ALREADY_FRIENDS(23, "already friends"),
|
||||||
|
|
||||||
ERROR_CODE_RECALL_TIME_EXPIRED(24, "time expired"),
|
ERROR_CODE_RECALL_TIME_EXPIRED(24, "time expired"),
|
||||||
|
ERROR_CODE_LOCK_ALREADY_LOCKED(25, "already locked"),
|
||||||
|
ERROR_CODE_NOT_YOUR_LOCKED(26, "unload failure, not your lock"),
|
||||||
|
ERROR_CODE_ROBOT_NO_TOKEN(27, "robot no token"),
|
||||||
ERROR_CODE_CONFERENCE_ROOM_NOT_EXIST(60, "conference room not exist"),
|
ERROR_CODE_CONFERENCE_ROOM_NOT_EXIST(60, "conference room not exist"),
|
||||||
|
|
||||||
ERROR_CODE_USER_NOT_PREPARED(238, "user not prepared"),
|
ERROR_CODE_USER_NOT_PREPARED(238, "user not prepared"),
|
||||||
|
|||||||
@@ -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.74</version>
|
<version>0.75</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.74</version>
|
<version>0.75</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.74</version>
|
<version>0.75</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user