Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d6f5614f49 | ||
|
|
9ed4ab7e08 | ||
|
|
4da3d3421d | ||
|
|
40ef9abd35 | ||
|
|
6f5b021c89 | ||
|
|
f8f225d741 | ||
|
|
546110f6d3 | ||
|
|
c7dbf45af6 | ||
|
|
1434dafd36 | ||
|
|
0d8a6e64ea | ||
|
|
d96c201aec | ||
|
|
d901707691 | ||
|
|
f456a4cc65 | ||
|
|
c4bd706272 | ||
|
|
503768c04b | ||
|
|
7ca3abe12d | ||
|
|
cb09026408 | ||
|
|
fab381a351 |
@@ -32,7 +32,8 @@ host 0.0.0.0
|
||||
##本地绑定端口
|
||||
local_port 80
|
||||
|
||||
##是否使用内置DB。0使用mysql;1使用h2db。
|
||||
## 是否使用内置DB。0使用mysql;1使用h2db。
|
||||
## MySQL需要把事物隔离级别改成"Read committed",使用命令来修改"set global transaction_isolation='read-committed';",其他数据库默认已经是这个级别不用修改
|
||||
embed.db 1
|
||||
|
||||
## 是否自动清理历史消息记录,当为true时,IM服务会定时扫描t_messages_x和t_user_messages_x表,清除掉3年前的历史消息。
|
||||
|
||||
+4
-4
@@ -5,7 +5,7 @@
|
||||
<relativePath>../</relativePath>
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
<groupId>cn.wildfirechat</groupId>
|
||||
<version>0.79</version>
|
||||
<version>0.82</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>moquette-broker</artifactId>
|
||||
@@ -27,18 +27,18 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-core</artifactId>
|
||||
<version>2.17.0</version>
|
||||
<version>2.17.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-api</artifactId>
|
||||
<version>2.17.0</version>
|
||||
<version>2.17.1</version>
|
||||
</dependency>
|
||||
<!--用于与slf4j保持桥接-->
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-slf4j-impl</artifactId>
|
||||
<version>2.17.0</version>
|
||||
<version>2.17.1</version>
|
||||
</dependency>
|
||||
<!-- slf4j核心包-->
|
||||
<dependency>
|
||||
|
||||
@@ -63,6 +63,7 @@ public class GetGroupMembersAction extends AdminAction {
|
||||
pm.setAlias(member.getAlias());
|
||||
pm.setType(member.getType());
|
||||
pm.setExtra(member.getExtra());
|
||||
pm.setCreateDt(member.getCreateDt());
|
||||
out.getMembers().add(pm);
|
||||
}
|
||||
result = RestResult.ok(out);
|
||||
|
||||
@@ -70,6 +70,7 @@ abstract public class ChannelAction extends Action {
|
||||
try {
|
||||
ts = Long.parseLong(timestamp);
|
||||
} catch (Exception e) {
|
||||
LOG.error("Channel timestamp:{} invalid", timestamp);
|
||||
e.printStackTrace();
|
||||
Utility.printExecption(LOG, e, IMExceptionEvent.EventType.CHANNEL_API_Exception);
|
||||
return ErrorCode.ERROR_CODE_API_NOT_SIGNED;
|
||||
@@ -81,7 +82,7 @@ abstract public class ChannelAction extends Action {
|
||||
|
||||
channelInfo = messagesStore.getChannelInfo(cid);
|
||||
if (channelInfo == null) {
|
||||
return ErrorCode.INVALID_PARAMETER;
|
||||
return ErrorCode.ERROR_CODE_CHANNEL_NO_EXIST;
|
||||
}
|
||||
|
||||
if (StringUtil.isNullOrEmpty(channelInfo.getSecret())) {
|
||||
|
||||
@@ -14,16 +14,12 @@ import cn.wildfirechat.pojos.InputGetUserInfo;
|
||||
import cn.wildfirechat.pojos.InputOutputUserInfo;
|
||||
import cn.wildfirechat.proto.ProtoConstants;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import com.google.gson.Gson;
|
||||
import com.xiaoleilu.loServer.RestResult;
|
||||
import com.xiaoleilu.loServer.action.admin.AdminAction;
|
||||
import com.xiaoleilu.loServer.action.robot.RobotAction;
|
||||
import com.xiaoleilu.loServer.annotation.HttpMethod;
|
||||
import com.xiaoleilu.loServer.annotation.Route;
|
||||
import com.xiaoleilu.loServer.handler.Request;
|
||||
import com.xiaoleilu.loServer.handler.Response;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
|
||||
@Route(APIPath.Channel_User_Info)
|
||||
|
||||
@@ -12,7 +12,6 @@ package com.xiaoleilu.loServer.action.channel;
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import cn.wildfirechat.pojos.SendChannelMessageData;
|
||||
import cn.wildfirechat.proto.ProtoConstants;
|
||||
import com.google.gson.Gson;
|
||||
import com.xiaoleilu.loServer.RestResult;
|
||||
import com.xiaoleilu.loServer.annotation.HttpMethod;
|
||||
import com.xiaoleilu.loServer.annotation.Route;
|
||||
@@ -24,7 +23,6 @@ import cn.wildfirechat.pojos.SendMessageResult;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import win.liyufan.im.IMTopic;
|
||||
|
||||
|
||||
@@ -67,6 +67,7 @@ public class GetGroupMembersAction extends RobotAction {
|
||||
pm.setAlias(member.getAlias());
|
||||
pm.setType(member.getType());
|
||||
pm.setExtra(member.getExtra());
|
||||
pm.setCreateDt(member.getCreateDt());
|
||||
out.getMembers().add(pm);
|
||||
}
|
||||
if(!isInGroup) {
|
||||
|
||||
@@ -33,7 +33,7 @@ public class LoadRemoteMessagesHandler extends IMHandler<WFCMessage.LoadRemoteMe
|
||||
}
|
||||
|
||||
if (request.getConversation().getType() == ProtoConstants.ConversationType.ConversationType_Channel) {
|
||||
if (!m_messagesStore.checkUserInChannel(fromUser, request.getConversation().getTarget())) {
|
||||
if (!m_messagesStore.canSendMessageInChannel(fromUser, request.getConversation().getTarget())) {
|
||||
return ErrorCode.ERROR_CODE_NOT_IN_CHANNEL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,11 @@ public class RouteHandler extends IMHandler<WFCMessage.RouteRequest> {
|
||||
}
|
||||
|
||||
if (session == null || session.getDeleted() > 0) {
|
||||
if(session == null) {
|
||||
LOG.error("Session for <{}, {}> not exist", fromUser, clientID);
|
||||
} else {
|
||||
LOG.error("Session for <{}, {}> deleted", fromUser, clientID);
|
||||
}
|
||||
return ErrorCode.ERROR_CODE_SECRECT_KEY_MISMATCH;
|
||||
}
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@ public class SendMessageHandler extends IMHandler<WFCMessage.Message> {
|
||||
}
|
||||
} else if (message.getConversation().getType() == ProtoConstants.ConversationType.ConversationType_Channel) {
|
||||
if(!m_messagesStore.getGroupMuteExceptionTypes().contains(message.getContent().getType())) {
|
||||
if (!m_messagesStore.checkUserInChannel(fromUser, message.getConversation().getTarget())) {
|
||||
if (!m_messagesStore.canSendMessageInChannel(fromUser, message.getConversation().getTarget())) {
|
||||
return ErrorCode.ERROR_CODE_NOT_IN_CHANNEL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -48,7 +48,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static cn.wildfirechat.common.IMExceptionEvent.EventType.EVENT_CALLBACK_Exception;
|
||||
import static cn.wildfirechat.proto.ProtoConstants.ChannelState.Channel_State_Mask_Deleted;
|
||||
import static cn.wildfirechat.proto.ProtoConstants.ChannelState.*;
|
||||
import static cn.wildfirechat.proto.ProtoConstants.ChannelUpdateEventType.*;
|
||||
import static cn.wildfirechat.proto.ProtoConstants.ChatroomMemberUpdateEventType.Chatroom_Member_Event_Join;
|
||||
import static cn.wildfirechat.proto.ProtoConstants.ChatroomMemberUpdateEventType.Chatroom_Member_Event_Leave;
|
||||
@@ -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) {
|
||||
@@ -2326,39 +2344,31 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
return;
|
||||
}
|
||||
|
||||
if (session.getPlatform() == Platform_LINUX || session.getPlatform() == Platform_Windows || session.getPlatform() == Platform_OSX) {
|
||||
updateUserSettings(session.username, WFCMessage.ModifyUserSettingReq.newBuilder().setScope(kUserSettingPCOnline).setKey("PC").setValue(online ? (System.currentTimeMillis() + "|" + session.getPlatform() + "|" + session.getClientID() + "|" + session.getPhoneName()) : "").build(), session.clientID);
|
||||
} else {
|
||||
String value = null;
|
||||
for (MemorySessionStore.Session s : m_Server.getStore().sessionsStore().sessionForUser(session.username)) {
|
||||
if (s.getDeleted() != 0 || !m_Server.getConnectionsManager().isConnected(s.getClientID())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (s.getPlatform()) {
|
||||
case Platform_LINUX:
|
||||
case Platform_Windows:
|
||||
case Platform_OSX:
|
||||
value = System.currentTimeMillis() + "|" + s.getPlatform() + "|" + s.getClientID() + "|" + s.getPhoneName();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (value != null) {
|
||||
break;
|
||||
}
|
||||
String pcValue = null;
|
||||
for (MemorySessionStore.Session s : m_Server.getStore().sessionsStore().sessionForUser(session.username)) {
|
||||
if (s.getDeleted() != 0 || !m_Server.getConnectionsManager().isConnected(s.getClientID())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
WFCMessage.UserSettingEntry pcentry = getUserSetting(session.getUsername(), kUserSettingPCOnline, "PC");
|
||||
if (value != null) {
|
||||
if (pcentry == null || StringUtil.isNullOrEmpty(pcentry.getValue())) {
|
||||
updateUserSettings(session.username, WFCMessage.ModifyUserSettingReq.newBuilder().setScope(kUserSettingPCOnline).setKey("PC").setValue(value).build(), session.clientID);
|
||||
}
|
||||
} else {
|
||||
if (pcentry != null && !StringUtil.isNullOrEmpty(pcentry.getValue())) {
|
||||
updateUserSettings(session.username, WFCMessage.ModifyUserSettingReq.newBuilder().setScope(kUserSettingPCOnline).setKey("PC").setValue("").build(), session.clientID);
|
||||
}
|
||||
switch (s.getPlatform()) {
|
||||
case Platform_LINUX:
|
||||
case Platform_Windows:
|
||||
case Platform_OSX:
|
||||
pcValue = System.currentTimeMillis() + "|" + s.getPlatform() + "|" + s.getClientID() + "|" + s.getPhoneName();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
WFCMessage.UserSettingEntry pcentry = getUserSetting(session.getUsername(), kUserSettingPCOnline, "PC");
|
||||
if (pcValue != null) {
|
||||
if (pcentry == null || StringUtil.isNullOrEmpty(pcentry.getValue())) {
|
||||
updateUserSettings(session.username, WFCMessage.ModifyUserSettingReq.newBuilder().setScope(kUserSettingPCOnline).setKey("PC").setValue(pcValue).build(), session.clientID);
|
||||
}
|
||||
} else {
|
||||
if (pcentry != null && !StringUtil.isNullOrEmpty(pcentry.getValue())) {
|
||||
updateUserSettings(session.username, WFCMessage.ModifyUserSettingReq.newBuilder().setScope(kUserSettingPCOnline).setKey("PC").setValue("").build(), session.clientID);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2478,7 +2488,21 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
IMap<String, WFCMessage.User> mUserMap = hzInstance.getMap(USERS);
|
||||
WFCMessage.User us = mUserMap.get(userId);
|
||||
if (us != null) {
|
||||
us = WFCMessage.User.newBuilder().setUid(userId).setUpdateDt(System.currentTimeMillis()).setDisplayName("").setName(userId).setDeleted(1).build();
|
||||
us = WFCMessage.User.newBuilder()
|
||||
.setUid(userId)
|
||||
.setUpdateDt(System.currentTimeMillis())
|
||||
.setName(userId)
|
||||
.setDeleted(1)
|
||||
.clearDisplayName()
|
||||
.clearAddress()
|
||||
.clearCompany()
|
||||
.clearEmail()
|
||||
.clearExtra()
|
||||
.clearMobile()
|
||||
.clearPortrait()
|
||||
.clearSocial()
|
||||
.build();
|
||||
|
||||
try {
|
||||
databaseStore.updateUser(us);
|
||||
} catch (Exception e) {
|
||||
@@ -3751,6 +3775,34 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
return mIMap.get(channelId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSendMessageInChannel(String user, String channelId) {
|
||||
IMap<String, WFCMessage.ChannelInfo> mIMap = m_Server.getHazelcastInstance().getMap(CHANNELS);
|
||||
WFCMessage.ChannelInfo info = mIMap.get(channelId);
|
||||
if(info == null || info.getStatus() == Channel_State_Mask_Deleted) {
|
||||
return false;
|
||||
}
|
||||
if(user.equals(info.getOwner())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if((info.getStatus() & Channel_State_Mask_Global) > 0 || (info.getStatus() & Channel_State_Mask_Message_Unsubscribed) > 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Collection<String> channelMembers = getChannelListener(channelId);
|
||||
if (channelMembers == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Collection<String> chatroomMembers = getChannelListener(channelId);
|
||||
if (chatroomMembers == null || !chatroomMembers.contains(user)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkUserInChannel(String user, String channelId) {
|
||||
Collection<String> channelMembers = getChannelListener(channelId);
|
||||
|
||||
@@ -723,6 +723,11 @@ public class MemorySessionStore implements ISessionsStore {
|
||||
public ErrorCode kickoffPCClient(String operator, String pcClientId) {
|
||||
Session session = sessions.get(pcClientId);
|
||||
if (session != null) {
|
||||
if(!operator.equals(session.getUsername())) {
|
||||
LOG.error("kickoffPCClient failure, user {} don't have client {}", operator, pcClientId);
|
||||
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
|
||||
@@ -731,8 +736,12 @@ public class MemorySessionStore implements ISessionsStore {
|
||||
sessions.remove(pcClientId);
|
||||
mServer.getProcessor().kickoffSession(session);
|
||||
} else {
|
||||
LOG.error("session {} is not pc client:{}", pcClientId, session.getPlatform());
|
||||
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||
}
|
||||
} 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);
|
||||
@@ -211,6 +213,7 @@ public interface IMessagesStore {
|
||||
List<WFCMessage.ChannelInfo> searchChannel(String keyword, boolean buzzy, int page);
|
||||
ErrorCode listenChannel(String operator, String channelId, boolean listen);
|
||||
WFCMessage.ChannelInfo getChannelInfo(String channelId);
|
||||
boolean canSendMessageInChannel(String user, String channelId);
|
||||
boolean checkUserInChannel(String user, String channelId);
|
||||
Collection<String> getChannelSubscriber(String channelId);
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -644,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());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -622,14 +622,15 @@ public class ProtocolProcessor {
|
||||
if(session != null) {
|
||||
session.refreshLastActiveTime();
|
||||
forwardOnlineStatusEvent(username, clientID, session.getPlatform(), clearSession ? UserOnlineStatus.LOGOUT : UserOnlineStatus.OFFLINE, session.getAppName());
|
||||
m_messagesStore.updateUserOnlineSetting(session, false);
|
||||
}
|
||||
|
||||
ConnectionDescriptor oldConnDescr = new ConnectionDescriptor(clientID, channel);
|
||||
if(connectionDescriptors.removeConnection(oldConnDescr)) {
|
||||
m_interceptor.notifyClientConnectionLost(clientID, username);
|
||||
}
|
||||
|
||||
if(session != null) {
|
||||
m_messagesStore.updateUserOnlineSetting(session, false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
<groupId>cn.wildfirechat</groupId>
|
||||
<version>0.79</version>
|
||||
<version>0.82</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -32,6 +32,8 @@ public interface APIPath {
|
||||
String User_Put_Setting = "/admin/user/put_setting";
|
||||
String User_Get_Setting = "/admin/user/get_setting";
|
||||
String User_Kickoff_Client = "/admin/user/kickoff_client";
|
||||
String User_Online_Count = "/admin/user/online_count";
|
||||
String User_Online_List = "/admin/user/online_list";
|
||||
|
||||
String Friend_Update_Status = "/admin/friend/status";
|
||||
String Friend_Get_List = "/admin/friend/list";
|
||||
@@ -47,6 +49,7 @@ public interface APIPath {
|
||||
String Msg_Send = "/admin/message/send";
|
||||
String Msg_Recall = "/admin/message/recall";
|
||||
String Msg_Delete = "/admin/message/delete";
|
||||
String Msg_Update = "/admin/message/update";
|
||||
String Msg_Broadcast = "/admin/message/broadcast";
|
||||
String Msg_Multicast = "/admin/message/multicast";
|
||||
String Msg_RecallBroadCast = "/admin/message/recall_broadcast";
|
||||
|
||||
@@ -49,6 +49,7 @@ public enum ErrorCode {
|
||||
ERROR_CODE_WS_NOT_CONFIGURED_CORRECTLY(28, "ws not configured correctly"),
|
||||
ERROR_CODE_CONFERENCE_ROOM_NOT_EXIST(60, "conference room not exist"),
|
||||
|
||||
ERROR_CODE_CHANNEL_NO_EXIST(236, "channel no exist"),
|
||||
ERROR_CODE_CHANNEL_NO_SECRET(237, "channel no secret"),
|
||||
ERROR_CODE_USER_NOT_PREPARED(238, "user not prepared"),
|
||||
ERROR_CODE_API_NOT_SIGNED(239, "api not signed or sign parameter not completion"),
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package cn.wildfirechat.pojos;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class GetOnlineUserCountResult extends ArrayList<GetOnlineUserCountResult.Node> {
|
||||
public static class Node {
|
||||
public int node;
|
||||
public int count;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package cn.wildfirechat.pojos;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class GetOnlineUserRequest {
|
||||
public int nodeId;
|
||||
public int offset;
|
||||
public int count;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package cn.wildfirechat.pojos;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class GetOnlineUserResult {
|
||||
public static class UserClient {
|
||||
public String userId;
|
||||
public String clientId;
|
||||
public int platform;
|
||||
}
|
||||
|
||||
ArrayList<GetOnlineUserResult.UserClient> userClients;
|
||||
public int totalCount;
|
||||
public int offset;
|
||||
}
|
||||
@@ -13,6 +13,7 @@ public class PojoGroupMember {
|
||||
String alias;
|
||||
int type;
|
||||
String extra;
|
||||
long createDt;
|
||||
|
||||
public String getMember_id() {
|
||||
return member_id;
|
||||
@@ -45,4 +46,12 @@ public class PojoGroupMember {
|
||||
public void setExtra(String extra) {
|
||||
this.extra = extra;
|
||||
}
|
||||
|
||||
public long getCreateDt() {
|
||||
return createDt;
|
||||
}
|
||||
|
||||
public void setCreateDt(long createDt) {
|
||||
this.createDt = createDt;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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 cn.wildfirechat.pojos;
|
||||
|
||||
public class UpdateMessageContentData {
|
||||
private String operator;
|
||||
private long messageUid;
|
||||
private MessagePayload payload;
|
||||
private int distribute;
|
||||
private int updateTimestamp;
|
||||
|
||||
public String getOperator() {
|
||||
return operator;
|
||||
}
|
||||
|
||||
public void setOperator(String operator) {
|
||||
this.operator = operator;
|
||||
}
|
||||
|
||||
public long getMessageUid() {
|
||||
return messageUid;
|
||||
}
|
||||
|
||||
public void setMessageUid(long messageUid) {
|
||||
this.messageUid = messageUid;
|
||||
}
|
||||
|
||||
public MessagePayload getPayload() {
|
||||
return payload;
|
||||
}
|
||||
|
||||
public void setPayload(MessagePayload payload) {
|
||||
this.payload = payload;
|
||||
}
|
||||
|
||||
public int getDistribute() {
|
||||
return distribute;
|
||||
}
|
||||
|
||||
public void setDistribute(int distribute) {
|
||||
this.distribute = distribute;
|
||||
}
|
||||
|
||||
public int getUpdateTimestamp() {
|
||||
return updateTimestamp;
|
||||
}
|
||||
|
||||
public void setUpdateTimestamp(int updateTimestamp) {
|
||||
this.updateTimestamp = updateTimestamp;
|
||||
}
|
||||
}
|
||||
@@ -48,6 +48,8 @@ public class ProtoConstants {
|
||||
int Platform_WEB = 5;
|
||||
int Platform_WX = 6;
|
||||
int Platform_LINUX = 7;
|
||||
int Platform_iPad = 8;
|
||||
int Platform_APad = 9;
|
||||
}
|
||||
|
||||
//message NotifyMessage & PullMessageRequest -> type
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<!--<relativePath>../pom.xml</relativePath>-->
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
<groupId>cn.wildfirechat</groupId>
|
||||
<version>0.79</version>
|
||||
<version>0.82</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>distribution</artifactId>
|
||||
|
||||
@@ -28,7 +28,8 @@ host 0.0.0.0
|
||||
##本地绑定端口
|
||||
local_port 80
|
||||
|
||||
##是否使用内置DB。0使用mysql;1使用h2db。
|
||||
## 是否使用内置DB。0使用mysql;1使用h2db。
|
||||
## MySQL需要把事物隔离级别改成"Read committed",使用命令来修改"set global transaction_isolation='read-committed';",其他数据库默认已经是这个级别不用修改
|
||||
embed.db 1
|
||||
|
||||
## 是否自动清理历史消息记录,当为true时,IM服务会定时扫描t_messages_x和t_user_messages_x表,清除掉3年前的历史消息。
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
|
||||
<packaging>pom</packaging>
|
||||
<version>0.79</version>
|
||||
<version>0.82</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.79</version>
|
||||
<version>0.82</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -269,6 +269,24 @@ public class Main {
|
||||
System.out.println("destroy user failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
if (commercialServer) {
|
||||
IMResult<GetOnlineUserCountResult> getOnlineUserCountResultIMResult = UserAdmin.getOnlineUserCount();
|
||||
if (getOnlineUserCountResultIMResult != null && getOnlineUserCountResultIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("get user online count success");
|
||||
} else {
|
||||
System.out.println("get user online count failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
IMResult<GetOnlineUserResult> getOnlineUserResultIMResult = UserAdmin.getOnlineUser(1, 0, 100);
|
||||
if (getOnlineUserResultIMResult != null && getOnlineUserResultIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("get user online success");
|
||||
} else {
|
||||
System.out.println("get user online failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//***********************************************
|
||||
@@ -664,6 +682,24 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
payload.setSearchableContent("hello world2");
|
||||
resultSendMessage = MessageAdmin.sendMessage("user1", conversation, payload, null);
|
||||
if (resultSendMessage != null && resultSendMessage.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("send message success");
|
||||
} else {
|
||||
System.out.println("send message failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
payload.setSearchableContent("hello world3");
|
||||
voidIMResult = MessageAdmin.updateMessageContent("user1", resultSendMessage.getResult().getMessageUid(), payload, true);
|
||||
if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("update message success");
|
||||
} else {
|
||||
System.out.println("update message failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
IMResult<BroadMessageResult> resultBroadcastMessage = MessageAdmin.broadcastMessage("user1", 0, payload);
|
||||
if (resultBroadcastMessage != null && resultBroadcastMessage.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("broad message success, send message to " + resultBroadcastMessage.getResult().getCount() + " users");
|
||||
|
||||
@@ -37,6 +37,17 @@ public class MessageAdmin {
|
||||
return AdminHttpUtils.httpJsonPost(path, deleteMessageData, Void.class);
|
||||
}
|
||||
|
||||
public static IMResult<Void> updateMessageContent(String operator, long messageUid, MessagePayload payload, boolean distribute) throws Exception {
|
||||
String path = APIPath.Msg_Update;
|
||||
UpdateMessageContentData updateMessageContentData = new UpdateMessageContentData();
|
||||
updateMessageContentData.setOperator(operator);
|
||||
updateMessageContentData.setMessageUid(messageUid);
|
||||
updateMessageContentData.setPayload(payload);
|
||||
updateMessageContentData.setDistribute(distribute?1:0);
|
||||
updateMessageContentData.setUpdateTimestamp(0);
|
||||
return AdminHttpUtils.httpJsonPost(path, updateMessageContentData, Void.class);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -117,4 +117,16 @@ public class UserAdmin {
|
||||
inputUserId.setUserId(userId);
|
||||
return AdminHttpUtils.httpJsonPost(path, inputUserId, OutputDeviceList.class);
|
||||
}
|
||||
|
||||
public static IMResult<GetOnlineUserCountResult> getOnlineUserCount() throws Exception {
|
||||
return AdminHttpUtils.httpJsonPost(APIPath.User_Online_Count, null, GetOnlineUserCountResult.class);
|
||||
}
|
||||
|
||||
public static IMResult<GetOnlineUserResult> getOnlineUser(int nodeId, int offset, int count) throws Exception {
|
||||
GetOnlineUserRequest request = new GetOnlineUserRequest();
|
||||
request.nodeId = nodeId;
|
||||
request.offset = offset;
|
||||
request.count = count;
|
||||
return AdminHttpUtils.httpJsonPost(APIPath.User_Online_List, request, GetOnlineUserResult.class);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user