Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6bfd175781 | ||
|
|
1fc093a2ed | ||
|
|
969d865061 | ||
|
|
6a6c59bdf2 | ||
|
|
7adadd21a6 | ||
|
|
21394985b3 | ||
|
|
b55694624d | ||
|
|
cca9cafb7e | ||
|
|
950334aad3 | ||
|
|
ce578234f4 | ||
|
|
5daa4b1dc8 | ||
|
|
22a23a3f33 |
@@ -36,7 +36,7 @@ host 0.0.0.0
|
||||
local_port 80
|
||||
|
||||
##是否使用内置DB。0使用mysql;1使用h2db;2使用mysql+mongodb。社区版只支持0和1,专业版支持2
|
||||
embed.db 0
|
||||
embed.db 1
|
||||
|
||||
##服务器管理接口密钥
|
||||
http.admin.secret_key 123456
|
||||
@@ -74,6 +74,9 @@ friend.repeat_request_duration 604800000
|
||||
##好友请求被拒绝后再次发送的间隔,单位是毫秒,默认是30天,0为不限制
|
||||
friend.reject_request_duration 2592000000
|
||||
|
||||
##好友请求过期时间,单位是毫秒,默认是7天,0为不限制
|
||||
friend.request_expiration_duration 604800000
|
||||
|
||||
## 聊天室观众空闲退出时间,单位为毫秒,默认为15分钟,0为永远不退出
|
||||
chatroom.participant_idle_time 900000
|
||||
|
||||
|
||||
@@ -9,19 +9,40 @@ server {
|
||||
root html;
|
||||
index index.html index.htm index.php;
|
||||
|
||||
## send request back to im server ##
|
||||
location /im {
|
||||
location /route {
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-real-ip $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_pass http://imserver;
|
||||
}
|
||||
|
||||
location /route {
|
||||
#社区版需要启用下面一段,专业版不能用
|
||||
location /im {
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-real-ip $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_pass http://imserver;
|
||||
}
|
||||
|
||||
location /api {
|
||||
proxy_pass http://imserver;
|
||||
}
|
||||
location / {
|
||||
proxy_pass https://wildfirechat.github.io/docs/;
|
||||
|
||||
location /fs {
|
||||
proxy_pass http://imserver;
|
||||
}
|
||||
|
||||
location /robot {
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-real-ip $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_pass http://imserver;
|
||||
}
|
||||
|
||||
location /channel {
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-real-ip $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_pass http://imserver;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.14</version>
|
||||
<version>1.2.17</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* 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 com.xiaoleilu.loServer.action;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
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.moquette.persistence.MemorySessionStore;
|
||||
import io.moquette.spi.security.Tokenor;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import win.liyufan.im.GitRepositoryState;
|
||||
import win.liyufan.im.RateLimiter;
|
||||
import win.liyufan.im.Utility;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Route("/api/verify_token")
|
||||
@HttpMethod("GET")
|
||||
public class CheckTokenAction extends Action {
|
||||
private final RateLimiter mLimitCounter = new RateLimiter(10, 1);
|
||||
@Override
|
||||
public boolean action(Request request, Response response) {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
String userId = request.getParam("userId");
|
||||
String clientId = request.getParam("clientId");
|
||||
String token = request.getParam("token");
|
||||
|
||||
String result = "这是个检查token有效性的接口,如果客户端无法连接成功,可以使用这个接口检查token是否正确。\n";
|
||||
result += "使用方法是在浏览器中输入http://imserverip/api/verify_token?userId=${userId}&clientId=${clientId}&token=${token}。\n";
|
||||
result += "例如:http://localhost/api/verify_token?userId=123&clientId=456&token=789。\n";
|
||||
result += "特别注意的是:必须使用正确的clientId,clientId必须是在测试手机上调用im接口获取。不用手机上获取到的clientId也都是不同的,一定不能用错!!!\n\n\n";
|
||||
|
||||
if (StringUtil.isNullOrEmpty(userId)) {
|
||||
result += "错误,userId为空";
|
||||
} else if (StringUtil.isNullOrEmpty(clientId)) {
|
||||
result += "错误,clientId为空";
|
||||
} else if (StringUtil.isNullOrEmpty(token)) {
|
||||
result += "错误,token为空";
|
||||
} else if(!mLimitCounter.isGranted("verify_token")) {
|
||||
result += "接口请求超频!接口限制每10秒只能验证一次!";
|
||||
} else {
|
||||
MemorySessionStore.Session session = sessionsStore.getSession(clientId);
|
||||
if (session == null) {
|
||||
result += "错误,session不存在。请确认token是从本服务通过getToken接口获取的,另外请确认clientId是否正确";
|
||||
} else if (session.getDeleted() == 1) {
|
||||
result += "错误,session已经被清除,请确认当前客户没有多端登录或者主动退出";
|
||||
} else if(!session.getUsername().equals(userId)) {
|
||||
result += "错误,当前客户端的登录用户不是" + userId + "。这一般发生在当前clientId又为其它用户获取过token";
|
||||
} else {
|
||||
String id = Tokenor.getUserId(token.getBytes());
|
||||
if (id == null) {
|
||||
result += "错误,无效的token";
|
||||
} else if(!id.equals(userId)) {
|
||||
result += "错误,改token是用户" + id + "的";
|
||||
} else {
|
||||
result += "恭喜,您的信息是正确的";
|
||||
}
|
||||
}
|
||||
}
|
||||
response.setContent(result);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@
|
||||
package com.xiaoleilu.loServer.action.admin;
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import cn.wildfirechat.proto.ProtoConstants;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import com.google.gson.Gson;
|
||||
import com.xiaoleilu.loServer.RestResult;
|
||||
@@ -43,7 +44,8 @@ public class CreateUserAction extends AdminAction {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
InputOutputUserInfo inputCreateUser = getRequestBody(request.getNettyRequest(), InputOutputUserInfo.class);
|
||||
if (inputCreateUser != null
|
||||
&& !StringUtil.isNullOrEmpty(inputCreateUser.getName())) {
|
||||
&& !StringUtil.isNullOrEmpty(inputCreateUser.getName())
|
||||
&& (inputCreateUser.getType() == ProtoConstants.UserType.UserType_Normal || inputCreateUser.getType() == ProtoConstants.UserType.UserType_Admin || inputCreateUser.getType() == ProtoConstants.UserType.UserType_Super_Admin)) {
|
||||
|
||||
if(StringUtil.isNullOrEmpty(inputCreateUser.getPassword())) {
|
||||
inputCreateUser.setPassword(UUIDGenerator.getUUID());
|
||||
@@ -78,6 +80,7 @@ public class CreateUserAction extends AdminAction {
|
||||
if (inputCreateUser.getExtra() != null)
|
||||
newUserBuilder.setExtra(inputCreateUser.getExtra());
|
||||
|
||||
newUserBuilder.setType(inputCreateUser.getType());
|
||||
newUserBuilder.setUpdateDt(System.currentTimeMillis());
|
||||
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ package com.xiaoleilu.loServer.action.channel;
|
||||
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import cn.wildfirechat.pojos.SendChannelMessageData;
|
||||
import com.google.gson.Gson;
|
||||
import com.xiaoleilu.loServer.RestResult;
|
||||
import com.xiaoleilu.loServer.annotation.HttpMethod;
|
||||
@@ -44,11 +45,15 @@ public class SendMessageAction extends ChannelAction {
|
||||
@Override
|
||||
public boolean action(Request request, Response response) {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
SendMessageData sendMessageData = getRequestBody(request.getNettyRequest(), SendMessageData.class);
|
||||
SendChannelMessageData sendChannelMessageData = getRequestBody(request.getNettyRequest(), SendChannelMessageData.class);
|
||||
SendMessageData sendMessageData = new SendMessageData();
|
||||
sendMessageData.setConv(new Conversation());
|
||||
sendMessageData.getConv().setType(ConversationType_Channel);
|
||||
sendMessageData.getConv().setTarget(channelInfo.getTargetId());
|
||||
sendMessageData.getConv().setLine(sendChannelMessageData.getLine());
|
||||
sendMessageData.setSender(channelInfo.getOwner());
|
||||
sendMessageData.setPayload(sendChannelMessageData.getPayload());
|
||||
sendMessageData.setToUsers(sendChannelMessageData.getTargets());
|
||||
if (SendMessageData.isValide(sendMessageData)) {
|
||||
RPCCenter.getInstance().sendRequest(sendMessageData.getSender(), null, IMTopic.SendMessageTopic, sendMessageData.toProtoMessage().toByteArray(), sendMessageData.getSender(), TargetEntry.Type.TARGET_TYPE_USER, new RPCCenter.Callback() {
|
||||
@Override
|
||||
|
||||
@@ -124,6 +124,7 @@ public final class BrokerConstants {
|
||||
public static final String MESSAGE_Blacklist_Strategy = "message.blacklist.strategy";
|
||||
public static final String FRIEND_Repeat_Request_Duration = "friend.repeat_request_duration";
|
||||
public static final String FRIEND_Reject_Request_Duration = "friend.reject_request_duration";
|
||||
public static final String FRIEND_Request_Expiration_Duration = "friend.request_expiration_duration";
|
||||
|
||||
public static final String CHATROOM_Participant_Idle_Time = "chatroom.participant_idle_time";
|
||||
public static final String CHATROOM_Rejoin_When_Active = "chatroom.rejoin_when_active";
|
||||
|
||||
@@ -31,7 +31,7 @@ public class ModifyGroupInfoHandler extends GroupHandler<WFCMessage.ModifyGroupI
|
||||
if (request.getType() == Modify_Group_Name) {
|
||||
content = new GroupNotificationBinaryContent(request.getGroupId(), fromUser, request.getValue(), "").getChangeGroupNameNotifyContent();
|
||||
} else if(request.getType() == Modify_Group_Portrait) {
|
||||
content = new GroupNotificationBinaryContent(request.getGroupId(), fromUser, null, "").getChangeGroupPortraitNotifyContent();
|
||||
content = new GroupNotificationBinaryContent(request.getGroupId(), fromUser, request.getValue(), "").getChangeGroupPortraitNotifyContent();
|
||||
} else if(request.getType() == Modify_Group_Mute) {
|
||||
content = new GroupNotificationBinaryContent(request.getGroupId(), fromUser, request.getValue(), "").getChangeGroupMuteNotifyContent();
|
||||
} else if(request.getType() == Modify_Group_JoinType) {
|
||||
|
||||
@@ -71,6 +71,7 @@ public class SendMessageHandler extends IMHandler<WFCMessage.Message> {
|
||||
if (errorCode != ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
if (errorCode == ErrorCode.ERROR_CODE_IN_BLACK_LIST && mBlacklistStrategy != ProtoConstants.BlacklistStrategy.Message_Reject) {
|
||||
ignoreMsg = true;
|
||||
errorCode = ErrorCode.ERROR_CODE_SUCCESS;
|
||||
} else {
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import cn.wildfirechat.proto.WFCMessage;
|
||||
import com.google.protobuf.ByteString;
|
||||
import com.hazelcast.core.*;
|
||||
import com.hazelcast.util.StringUtil;
|
||||
import com.xiaoleilu.hutool.system.UserInfo;
|
||||
import com.xiaoleilu.loServer.model.FriendData;
|
||||
import cn.wildfirechat.pojos.InputOutputUserBlockStatus;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
@@ -122,6 +121,8 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
|
||||
private long mFriendRequestDuration = 7 * 24 * 60 * 60 * 1000;
|
||||
private long mFriendRejectDuration = 30 * 24 * 60 * 60 * 1000;
|
||||
private long mFriendRequestExpiration = 7 * 24 * 60 * 60 * 1000;
|
||||
|
||||
private boolean mDisableStrangerChat = false;
|
||||
|
||||
private long mChatroomParticipantIdleTime = 900000;
|
||||
@@ -155,6 +156,13 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
Utility.printExecption(LOG, e);
|
||||
}
|
||||
|
||||
try {
|
||||
mFriendRequestExpiration = Long.parseLong(m_Server.getConfig().getProperty(FRIEND_Request_Expiration_Duration));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Utility.printExecption(LOG, e);
|
||||
}
|
||||
|
||||
try {
|
||||
mChatroomRejoinWhenActive = Boolean.parseBoolean(m_Server.getConfig().getProperty(BrokerConstants.CHATROOM_Rejoin_When_Active));
|
||||
} catch (Exception e) {
|
||||
@@ -250,8 +258,17 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
|
||||
if (!StringUtil.isNullOrEmpty(message.getToUser())) {
|
||||
notifyReceivers.add(message.getToUser());
|
||||
} else if(!message.getToList().isEmpty()) {
|
||||
notifyReceivers.addAll(message.getToList());
|
||||
} else if(message.getToList()!=null && !message.getToList().isEmpty()) {
|
||||
MultiMap<String, WFCMessage.GroupMember> groupMembers = hzInstance.getMultiMap(GROUP_MEMBERS);
|
||||
Collection<WFCMessage.GroupMember> members = groupMembers.get(message.getConversation().getTarget());
|
||||
if (members == null || members.size() == 0) {
|
||||
members = loadGroupMemberFromDB(hzInstance, message.getConversation().getTarget());
|
||||
}
|
||||
for (WFCMessage.GroupMember member : members) {
|
||||
if (member.getType() != GroupMemberType_Removed && message.getToList().contains(member.getMemberId())) {
|
||||
notifyReceivers.add(member.getMemberId());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
MultiMap<String, WFCMessage.GroupMember> groupMembers = hzInstance.getMultiMap(GROUP_MEMBERS);
|
||||
Collection<WFCMessage.GroupMember> members = groupMembers.get(message.getConversation().getTarget());
|
||||
@@ -288,14 +305,20 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
if (channelInfo != null) {
|
||||
notifyReceivers.add(fromUser);
|
||||
if (channelInfo.getOwner().equals(fromUser)) {
|
||||
MultiMap<String, String> listeners = hzInstance.getMultiMap(CHANNEL_LISTENERS);
|
||||
if (StringUtil.isNullOrEmpty(message.getToUser())) {
|
||||
MultiMap<String, String> listeners = hzInstance.getMultiMap(CHANNEL_LISTENERS);
|
||||
notifyReceivers.addAll(listeners.get(message.getConversation().getTarget()));
|
||||
} else {
|
||||
MultiMap<String, String> listeners = hzInstance.getMultiMap(CHANNEL_LISTENERS);
|
||||
if (listeners.values().contains(message.getToUser())) {
|
||||
notifyReceivers.add(message.getToUser());
|
||||
}
|
||||
} else if(message.getToList() != null && !message.getToList().isEmpty()) {
|
||||
Collection<String> ls = listeners.get(message.getConversation().getTarget());
|
||||
for (String to:message.getToList()) {
|
||||
if (ls.contains(to)) {
|
||||
notifyReceivers.add(to);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
notifyReceivers.addAll(listeners.get(message.getConversation().getTarget()));
|
||||
}
|
||||
} else {
|
||||
if (StringUtil.isNullOrEmpty(channelInfo.getCallback()) || channelInfo.getAutomatic() == 0) {
|
||||
@@ -2074,8 +2097,8 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
}
|
||||
|
||||
if (existRequest != null) {
|
||||
if (mFriendRequestDuration > 0 && System.currentTimeMillis() - existRequest.getUpdateDt() > mFriendRequestDuration) {
|
||||
return ErrorCode.ERROR_CODE_FRIEND_REQUEST_OVERTIME;
|
||||
if (mFriendRequestExpiration > 0 && System.currentTimeMillis() - existRequest.getUpdateDt() > mFriendRequestExpiration) {
|
||||
return ErrorCode.ERROR_CODE_FRIEND_REQUEST_EXPIRED;
|
||||
} else {
|
||||
existRequest = existRequest.toBuilder().setStatus(ProtoConstants.FriendRequestStatus.RequestStatus_Accepted).setUpdateDt(System.currentTimeMillis()).build();
|
||||
databaseStore.persistOrUpdateFriendRequest(existRequest);
|
||||
|
||||
@@ -36,7 +36,7 @@ public enum ErrorCode {
|
||||
//user error
|
||||
ERROR_CODE_FRIEND_ALREADY_REQUEST(16, "already send request"),
|
||||
ERROR_CODE_FRIEND_REQUEST_BLOCKED(18, "friend request blocked"),
|
||||
ERROR_CODE_FRIEND_REQUEST_OVERTIME(19, "friend request overtime"),
|
||||
ERROR_CODE_FRIEND_REQUEST_EXPIRED(19, "friend request expired"),
|
||||
|
||||
ERROR_CODE_NOT_IN_CHATROOM(20, "not in chatroom"),
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ public class InputOutputUserInfo {
|
||||
private String company;
|
||||
private String social;
|
||||
private String extra;
|
||||
private int type;
|
||||
private long updateDt;
|
||||
|
||||
public static InputOutputUserInfo fromPbUser(WFCMessage.User pbUser) {
|
||||
@@ -39,6 +40,7 @@ public class InputOutputUserInfo {
|
||||
inputCreateUser.company = pbUser.getCompany();
|
||||
inputCreateUser.social = pbUser.getSocial();
|
||||
inputCreateUser.extra = pbUser.getExtra();
|
||||
inputCreateUser.type = pbUser.getType();
|
||||
inputCreateUser.updateDt = pbUser.getUpdateDt();
|
||||
return inputCreateUser;
|
||||
}
|
||||
@@ -74,6 +76,7 @@ public class InputOutputUserInfo {
|
||||
if (getExtra() != null)
|
||||
newUserBuilder.setExtra(getExtra());
|
||||
newUserBuilder.setGender(gender);
|
||||
newUserBuilder.setType(type);
|
||||
|
||||
newUserBuilder.setUpdateDt(System.currentTimeMillis());
|
||||
return newUserBuilder.build();
|
||||
@@ -174,4 +177,12 @@ public class InputOutputUserInfo {
|
||||
public void setGender(int gender) {
|
||||
this.gender = gender;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ public class OutputGetChatroomInfo {
|
||||
private String desc;
|
||||
private String portrait;
|
||||
private String extra;
|
||||
private int state;
|
||||
private int memberCount;
|
||||
private long createDt;
|
||||
private long updateDt;
|
||||
@@ -28,6 +29,8 @@ public class OutputGetChatroomInfo {
|
||||
this.desc = chatroomInfo.getDesc();
|
||||
this.portrait = chatroomInfo.getPortrait();
|
||||
this.memberCount = memberCount;
|
||||
this.extra = chatroomInfo.getExtra();
|
||||
this.state = chatroomInfo.getState();
|
||||
this.createDt = chatroomInfo.getCreateDt();
|
||||
this.updateDt = chatroomInfo.getUpdateDt();
|
||||
}
|
||||
@@ -98,4 +101,12 @@ public class OutputGetChatroomInfo {
|
||||
public void setExtra(String extra) {
|
||||
this.extra = extra;
|
||||
}
|
||||
|
||||
public int getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(int state) {
|
||||
this.state = state;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,10 +12,13 @@ import cn.wildfirechat.proto.ProtoConstants;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SendMessageData {
|
||||
private String sender;
|
||||
private Conversation conv;
|
||||
private MessagePayload payload;
|
||||
private List<String> toUsers;
|
||||
|
||||
public String getSender() {
|
||||
return sender;
|
||||
@@ -41,6 +44,14 @@ public class SendMessageData {
|
||||
this.payload = payload;
|
||||
}
|
||||
|
||||
public List<String> getToUsers() {
|
||||
return toUsers;
|
||||
}
|
||||
|
||||
public void setToUsers(List<String> toUsers) {
|
||||
this.toUsers = toUsers;
|
||||
}
|
||||
|
||||
public static boolean isValide(SendMessageData sendMessageData) {
|
||||
if(sendMessageData == null ||
|
||||
sendMessageData.getConv() == null ||
|
||||
@@ -55,10 +66,18 @@ public class SendMessageData {
|
||||
}
|
||||
|
||||
public WFCMessage.Message toProtoMessage() {
|
||||
return WFCMessage.Message.newBuilder().setFromUser(sender)
|
||||
.setConversation(WFCMessage.Conversation.newBuilder().setType(conv.getType()).setTarget(conv.getTarget()).setLine(conv.getLine()))
|
||||
.setContent(payload.toProtoMessageContent())
|
||||
.build();
|
||||
if (toUsers != null && toUsers.size() > 0) {
|
||||
return WFCMessage.Message.newBuilder().setFromUser(sender)
|
||||
.setConversation(WFCMessage.Conversation.newBuilder().setType(conv.getType()).setTarget(conv.getTarget()).setLine(conv.getLine()))
|
||||
.setContent(payload.toProtoMessageContent())
|
||||
.addAllTo(toUsers)
|
||||
.build();
|
||||
} else {
|
||||
return WFCMessage.Message.newBuilder().setFromUser(sender)
|
||||
.setConversation(WFCMessage.Conversation.newBuilder().setType(conv.getType()).setTarget(conv.getTarget()).setLine(conv.getLine()))
|
||||
.setContent(payload.toProtoMessageContent())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
public static SendMessageData fromProtoMessage(WFCMessage.Message protoMessage) {
|
||||
|
||||
@@ -28,8 +28,8 @@ log4j.logger.io.moquette.parser.netty=WARN
|
||||
log4j.appender.file=org.apache.log4j.RollingFileAppender
|
||||
log4j.appender.file.Threshold=INFO
|
||||
log4j.appender.file.File=logs/wildfirechat.log
|
||||
log4j.appender.file.MaxFileSize=10MB
|
||||
log4j.appender.file.MaxBackupIndex=20
|
||||
log4j.appender.file.MaxFileSize=20MB
|
||||
log4j.appender.file.MaxBackupIndex=100
|
||||
log4j.appender.file.layout=org.apache.log4j.PatternLayout
|
||||
#log4j.appender.file.layout.ConversionPattern=%-4r [%t] %-5p %c{1} %x - %m%n
|
||||
log4j.appender.file.layout.ConversionPattern=%d{dd/MM/yyyy HH:mm:ss,SSS} [%t] %-5p %c{1} %L %x - %m%n
|
||||
@@ -41,7 +41,7 @@ log4j.appender.messagelog=org.apache.log4j.RollingFileAppender
|
||||
log4j.appender.messagelog.Threshold=WARN
|
||||
log4j.appender.messagelog.File=logs/wildfirechat_messages.log
|
||||
log4j.appender.messagelog.MaxFileSize=100MB
|
||||
log4j.appender.messagelog.MaxBackupIndex=1
|
||||
log4j.appender.messagelog.MaxBackupIndex=3
|
||||
log4j.appender.messagelog.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.messagelog.layout.ConversionPattern=%d{dd/MM/yyyy HH:mm:ss,SSS} [%t] %-5p %c{1} %L %x - %m%n
|
||||
|
||||
|
||||
@@ -64,6 +64,9 @@ friend.repeat_request_duration 604800000
|
||||
##好友请求被拒绝后再次发送的间隔,单位是毫秒,默认是30天,0为不限制
|
||||
friend.reject_request_duration 2592000000
|
||||
|
||||
##好友请求过期时间,单位是毫秒,默认是7天,0为不限制
|
||||
friend.request_expiration_duration 604800000
|
||||
|
||||
## 聊天室观众空闲退出时间,单位为毫秒,默认为15分钟,0为永远不退出
|
||||
chatroom.participant_idle_time 900000
|
||||
|
||||
|
||||
@@ -6,8 +6,15 @@ import cn.wildfirechat.sdk.model.IMResult;
|
||||
import cn.wildfirechat.sdk.utilities.AdminHttpUtils;
|
||||
|
||||
public class ChatroomAdmin {
|
||||
public static IMResult<OutputCreateChatroom> createChatroom(InputCreateChatroom input) throws Exception {
|
||||
public static IMResult<OutputCreateChatroom> createChatroom(String chatroomId, String title, String desc ,String portrait, String extra, Integer state) throws Exception {
|
||||
String path = APIPath.Create_Chatroom;
|
||||
InputCreateChatroom input = new InputCreateChatroom();
|
||||
input.setChatroomId(chatroomId);
|
||||
input.setTitle(title);
|
||||
input.setDesc(desc);
|
||||
input.setPortrait(portrait);
|
||||
input.setExtra(extra);
|
||||
input.setState(state);
|
||||
return AdminHttpUtils.httpJsonPost(path, input, OutputCreateChatroom.class);
|
||||
}
|
||||
|
||||
|
||||
@@ -469,6 +469,55 @@ public class Main {
|
||||
System.out.println("destroy user failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
String chatroomId = "chatroomId1";
|
||||
String chatroomTitle = "TESTCHATROM";
|
||||
String chatroomDesc = "this is a test chatroom";
|
||||
String chatroomPortrait = "http://pic.com/test123.png";
|
||||
String chatroomExtra = "{\'managers:[\"user1\",\"user2\"]}";
|
||||
IMResult<OutputCreateChatroom> chatroomIMResult = ChatroomAdmin.createChatroom(chatroomId,chatroomTitle, chatroomDesc, chatroomPortrait,chatroomExtra,ProtoConstants.ChatroomState.Chatroom_State_Normal);
|
||||
if (chatroomIMResult != null && chatroomIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS && chatroomIMResult.getResult().getChatroomId().equals(chatroomId)) {
|
||||
System.out.println("create chatroom success");
|
||||
} else {
|
||||
System.out.println("create chatroom failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
IMResult<OutputGetChatroomInfo> getChatroomInfoIMResult = ChatroomAdmin.getChatroomInfo(chatroomId);
|
||||
if (getChatroomInfoIMResult != null && getChatroomInfoIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
if (!getChatroomInfoIMResult.getResult().getChatroomId().equals(chatroomId)
|
||||
|| !getChatroomInfoIMResult.getResult().getTitle().equals(chatroomTitle)
|
||||
|| !getChatroomInfoIMResult.getResult().getDesc().equals(chatroomDesc)
|
||||
|| !getChatroomInfoIMResult.getResult().getPortrait().equals(chatroomPortrait)
|
||||
|| !getChatroomInfoIMResult.getResult().getExtra().equals(chatroomExtra)
|
||||
|| getChatroomInfoIMResult.getResult().getState() != ProtoConstants.ChatroomState.Chatroom_State_Normal) {
|
||||
System.out.println("chatroom info incorrect");
|
||||
System.exit(-1);
|
||||
} else {
|
||||
System.out.println("chatroom info incorrect");
|
||||
}
|
||||
} else {
|
||||
System.out.println("get chatroom info failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
voidIMResult = ChatroomAdmin.destroyChatroom(chatroomId);
|
||||
if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("destroy chatroom done!");
|
||||
} else {
|
||||
System.out.println("destroy chatroom failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
getChatroomInfoIMResult = ChatroomAdmin.getChatroomInfo(chatroomId);
|
||||
if (getChatroomInfoIMResult != null && getChatroomInfoIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS && getChatroomInfoIMResult.getResult().getState() == ProtoConstants.ChatroomState.Chatroom_State_End) {
|
||||
System.out.println("chatroom destroyed!");
|
||||
} else {
|
||||
System.out.println("chatroom not destroyed!");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
System.out.println("Congratulation, all admin test case passed!!!!!!!");
|
||||
}
|
||||
|
||||
static void testRobot() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user