Compare commits

...
12 Commits
16 changed files with 50 additions and 17 deletions
+1 -1
View File
@@ -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.82</version> <version>0.85</version>
</parent> </parent>
<artifactId>moquette-broker</artifactId> <artifactId>moquette-broker</artifactId>
@@ -131,6 +131,7 @@ public class UploadFileAction extends Action {
} }
readHttpDataChunkByChunk(response, decoder, requestId, HttpHeaders.isKeepAlive(request)); readHttpDataChunkByChunk(response, decoder, requestId, HttpHeaders.isKeepAlive(request));
decoder.destroy();
if (chunk instanceof LastHttpContent) { if (chunk instanceof LastHttpContent) {
@@ -28,7 +28,7 @@ public class HandleFriendRequestHandler extends IMHandler<WFCMessage.HandleFrien
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, ProtoConstants.RequestSourceType requestSourceType, WFCMessage.HandleFriendRequest request, Qos1PublishHandler.IMCallback callback) { public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, ProtoConstants.RequestSourceType requestSourceType, WFCMessage.HandleFriendRequest request, Qos1PublishHandler.IMCallback callback) {
WFCMessage.Message.Builder builder = WFCMessage.Message.newBuilder(); WFCMessage.Message.Builder builder = WFCMessage.Message.newBuilder();
builder.setFromUser(request.getTargetUid()); builder.setFromUser(request.getTargetUid());
long[] heads = new long[2]; long[] heads = new long[4];
boolean isAdmin = requestSourceType == ProtoConstants.RequestSourceType.Request_From_Admin; boolean isAdmin = requestSourceType == ProtoConstants.RequestSourceType.Request_From_Admin;
ErrorCode errorCode = m_messagesStore.handleFriendRequest(fromUser, request, builder, heads, isAdmin); ErrorCode errorCode = m_messagesStore.handleFriendRequest(fromUser, request, builder, heads, isAdmin);
@@ -84,6 +84,14 @@ public class HandleFriendRequestHandler extends IMHandler<WFCMessage.HandleFrien
publisher.publishNotification(IMTopic.NotifyFriendTopic, request.getTargetUid(), heads[0]); publisher.publishNotification(IMTopic.NotifyFriendTopic, request.getTargetUid(), heads[0]);
publisher.publishNotification(IMTopic.NotifyFriendTopic, fromUser, heads[1]); publisher.publishNotification(IMTopic.NotifyFriendTopic, fromUser, heads[1]);
} }
if(!isAdmin) {
if(heads[2] > 0) {
publisher.publishNotification(IMTopic.NotifyFriendRequestTopic, request.getTargetUid(), heads[2], fromUser, null);
}
if(heads[3] > 0) {
publisher.publishNotification(IMTopic.NotifyFriendRequestTopic, fromUser, heads[3], fromUser, null);
}
}
} }
if(errorCode == ERROR_CODE_ALREADY_FRIENDS) { if(errorCode == ERROR_CODE_ALREADY_FRIENDS) {
errorCode = ERROR_CODE_SUCCESS; errorCode = ERROR_CODE_SUCCESS;
@@ -553,7 +553,7 @@ public class DatabaseStore {
statement.setInt(index++, message.getContent().getType()); statement.setInt(index++, message.getContent().getType());
String to = message.getToUser(); String to = message.getToUser();
if (StringUtil.isNullOrEmpty(message.getToUser())) { if (StringUtil.isNullOrEmpty(message.getToUser())) {
if (message.getToList()!= null && message.getToList().size() == 1) { if (message.getToList().size() > 0) {
to = message.getToList().get(0); to = message.getToList().get(0);
} }
} }
@@ -2078,6 +2078,10 @@ public class MemoryMessagesStore implements IMessagesStore {
return ErrorCode.ERROR_CODE_NOT_RIGHT; return ErrorCode.ERROR_CODE_NOT_RIGHT;
} }
if(message.getContent().getType() == 80) {
return ErrorCode.ERROR_CODE_SUCCESS;
}
JSONObject json = new JSONObject(); JSONObject json = new JSONObject();
json.put("s", message.getFromUser()); json.put("s", message.getFromUser());
json.put("ts", message.getServerTimestamp()); json.put("ts", message.getServerTimestamp());
@@ -3033,6 +3037,8 @@ public class MemoryMessagesStore implements IMessagesStore {
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();
heads[2] = existRequest.getUpdateDt();
heads[3] = existRequest.getUpdateDt();
databaseStore.persistOrUpdateFriendRequest(existRequest); databaseStore.persistOrUpdateFriendRequest(existRequest);
if (request.getStatus() == ProtoConstants.FriendRequestStatus.RequestStatus_Accepted) { if (request.getStatus() == ProtoConstants.FriendRequestStatus.RequestStatus_Accepted) {
@@ -165,14 +165,17 @@ public class Qos1PublishHandler extends QosPublishHandler {
if (session != null && session.getUsername().equals(fromUser)) { if (session != null && session.getUsername().equals(fromUser)) {
if (data.length > 7*1024 && session.getMqttVersion().protocolLevel() >= MqttVersion.Wildfire_1.protocolLevel()) { if (data.length > 7*1024 && session.getMqttVersion().protocolLevel() >= MqttVersion.Wildfire_1.protocolLevel()) {
ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayOutputStream out = new ByteArrayOutputStream();
GZIPOutputStream gzip; GZIPOutputStream gzip = null;
try { try {
gzip = new GZIPOutputStream(out); gzip = new GZIPOutputStream(out);
gzip.write(data); gzip.write(data);
gzip.close();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
Utility.printExecption(LOG, e); Utility.printExecption(LOG, e);
} finally {
if(gzip != null) {
gzip.close();
}
} }
data = out.toByteArray(); data = out.toByteArray();
code = (byte)ErrorCode.ERROR_CODE_SUCCESS_GZIPED.code; code = (byte)ErrorCode.ERROR_CODE_SUCCESS_GZIPED.code;
+1 -1
View File
@@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>wildfirechat-parent</artifactId> <artifactId>wildfirechat-parent</artifactId>
<groupId>cn.wildfirechat</groupId> <groupId>cn.wildfirechat</groupId>
<version>0.82</version> <version>0.85</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
@@ -48,6 +48,7 @@ public enum ErrorCode {
ERROR_CODE_ROBOT_NO_TOKEN(27, "robot no token"), ERROR_CODE_ROBOT_NO_TOKEN(27, "robot no token"),
ERROR_CODE_WS_NOT_CONFIGURED_CORRECTLY(28, "ws not configured correctly"), ERROR_CODE_WS_NOT_CONFIGURED_CORRECTLY(28, "ws not configured correctly"),
ERROR_CODE_CONFERENCE_ROOM_NOT_EXIST(60, "conference room not exist"), ERROR_CODE_CONFERENCE_ROOM_NOT_EXIST(60, "conference room not exist"),
ERROR_CODE_CONFERENCE_SERVICE_NOT_AVAILABLE(61, "conference service not available"),
ERROR_CODE_CHANNEL_NO_EXIST(236, "channel no exist"), ERROR_CODE_CHANNEL_NO_EXIST(236, "channel no exist"),
ERROR_CODE_CHANNEL_NO_SECRET(237, "channel no secret"), ERROR_CODE_CHANNEL_NO_SECRET(237, "channel no secret"),
@@ -19,12 +19,11 @@ public class OutputGetChannelInfo {
private String extra; private String extra;
private String owner; private String owner;
private int state; private int state;
//此字段已经废弃,为了兼容旧的SDK版本,以后会移除
@Deprecated()
private int status; private int status;
private long updateDt; private long updateDt;
private String callback; private String callback;
private int automatic; private int automatic;
private String secret;
public String getChannelId() { public String getChannelId() {
@@ -115,6 +114,14 @@ public class OutputGetChannelInfo {
this.status = status; this.status = status;
} }
public String getSecret() {
return secret;
}
public void setSecret(String secret) {
this.secret = secret;
}
public static OutputGetChannelInfo fromPbInfo(WFCMessage.ChannelInfo channelInfo) { public static OutputGetChannelInfo fromPbInfo(WFCMessage.ChannelInfo channelInfo) {
OutputGetChannelInfo out = new OutputGetChannelInfo(); OutputGetChannelInfo out = new OutputGetChannelInfo();
out.automatic = channelInfo.getAutomatic(); out.automatic = channelInfo.getAutomatic();
@@ -126,8 +133,9 @@ public class OutputGetChannelInfo {
out.owner = channelInfo.getOwner(); out.owner = channelInfo.getOwner();
out.portrait = channelInfo.getPortrait(); out.portrait = channelInfo.getPortrait();
out.state = channelInfo.getStatus(); out.state = channelInfo.getStatus();
out.status = out.state; out.status = channelInfo.getStatus();;
out.updateDt = channelInfo.getUpdateDt(); out.updateDt = channelInfo.getUpdateDt();
out.secret = channelInfo.getSecret();
return out; return out;
} }
} }
@@ -8,4 +8,5 @@ public class PojoConferenceCreate {
public int bitrate; public int bitrate;
public boolean advance; public boolean advance;
public boolean recording; public boolean recording;
public boolean permanent;
} }
@@ -129,7 +129,7 @@ public class ProtoConstants {
//第3位表示是否允许给非订阅用户发送消息 //第3位表示是否允许给非订阅用户发送消息
//第4位表示是否私有,不可以被用户搜索和主动订阅 //第4位表示是否私有,不可以被用户搜索和主动订阅
//第6位表示是否删除 //第6位表示是否删除
//第8位表示是否是全局频道,全局频道没有订阅关系,会发送给系统内所有成员。 //第8位表示是否是全局频道,全局频道没有订阅关系,会发送给系统内所有成员。可以给非订阅用户单独发消息。
public interface ChannelState { public interface ChannelState {
int Channel_State_Mask_FullInfo = 0x01; int Channel_State_Mask_FullInfo = 0x01;
int Channel_State_Mask_Unsubscribed_User_Access = 0x02; int Channel_State_Mask_Unsubscribed_User_Access = 0x02;
+1 -1
View File
@@ -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.82</version> <version>0.85</version>
</parent> </parent>
<artifactId>distribution</artifactId> <artifactId>distribution</artifactId>
+1 -1
View File
@@ -12,7 +12,7 @@
<artifactId>wildfirechat-parent</artifactId> <artifactId>wildfirechat-parent</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<version>0.82</version> <version>0.85</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
View File
@@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>wildfirechat-parent</artifactId> <artifactId>wildfirechat-parent</artifactId>
<groupId>cn.wildfirechat</groupId> <groupId>cn.wildfirechat</groupId>
<version>0.82</version> <version>0.85</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
@@ -17,7 +17,7 @@ public class ConferenceAdmin {
return AdminHttpUtils.httpJsonPost(path, data, PojoConferenceParticipantList.class); return AdminHttpUtils.httpJsonPost(path, data, PojoConferenceParticipantList.class);
} }
public static IMResult<Void> createRoom(String roomId, String description, String pin, int maxPublisher, boolean advance, int bitrate, boolean recording) throws Exception { public static IMResult<Void> createRoom(String roomId, String description, String pin, int maxPublisher, boolean advance, int bitrate, boolean recording, boolean permanent) throws Exception {
String path = APIPath.Conference_Create; String path = APIPath.Conference_Create;
PojoConferenceCreate create = new PojoConferenceCreate(); PojoConferenceCreate create = new PojoConferenceCreate();
create.roomId = roomId; create.roomId = roomId;
@@ -27,6 +27,7 @@ public class ConferenceAdmin {
create.advance = advance; create.advance = advance;
create.bitrate = bitrate; create.bitrate = bitrate;
create.recording = recording; create.recording = recording;
create.permanent = permanent;
return AdminHttpUtils.httpJsonPost(path, create, Void.class); return AdminHttpUtils.httpJsonPost(path, create, Void.class);
} }
@@ -20,6 +20,7 @@ import static cn.wildfirechat.proto.ProtoConstants.SystemSettingType.Group_Max_M
public class Main { public class Main {
private static boolean commercialServer = false; private static boolean commercialServer = false;
private static boolean advanceVoip = false;
//管理端口是8080 //管理端口是8080
private static String AdminUrl = "http://localhost:18080"; private static String AdminUrl = "http://localhost:18080";
private static String AdminSecret = "123456"; private static String AdminSecret = "123456";
@@ -51,6 +52,8 @@ public class Main {
testSensitiveApi(); testSensitiveApi();
if (commercialServer) { if (commercialServer) {
testDevice(); testDevice();
}
if(advanceVoip) {
testConference(); testConference();
} }
@@ -857,6 +860,7 @@ public class Main {
System.exit(-1); System.exit(-1);
} }
Thread.sleep(1000);
getChatroomInfoIMResult = ChatroomAdmin.getChatroomInfo(chatroomId); getChatroomInfoIMResult = ChatroomAdmin.getChatroomInfo(chatroomId);
if (getChatroomInfoIMResult != null && getChatroomInfoIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS && getChatroomInfoIMResult.getResult().getState() == ProtoConstants.ChatroomState.Chatroom_State_End) { if (getChatroomInfoIMResult != null && getChatroomInfoIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS && getChatroomInfoIMResult.getResult().getState() == ProtoConstants.ChatroomState.Chatroom_State_End) {
System.out.println("chatroom destroyed!"); System.out.println("chatroom destroyed!");
@@ -1522,7 +1526,7 @@ public class Main {
System.out.println("conference list " + listResult.getResult().conferenceInfoList); System.out.println("conference list " + listResult.getResult().conferenceInfoList);
} }
IMResult<Void> createResult = ConferenceAdmin.createRoom("helloroomid", "hello room description", "123456", 9, false, 0, false); IMResult<Void> createResult = ConferenceAdmin.createRoom("helloroomid", "hello room description", "123456", 9, false, 0, false, true);
if(createResult == null || createResult.getErrorCode() != ErrorCode.ERROR_CODE_SUCCESS) { if(createResult == null || createResult.getErrorCode() != ErrorCode.ERROR_CODE_SUCCESS) {
System.out.println("create conference failure"); System.out.println("create conference failure");
System.exit(-1); System.exit(-1);
@@ -1530,7 +1534,7 @@ public class Main {
System.out.println("create conference"); System.out.println("create conference");
} }
createResult = ConferenceAdmin.createRoom("helloroomid2", "hello room description advanced", "123456", 20, true, 0, false); createResult = ConferenceAdmin.createRoom("helloroomid2", "hello room description advanced", "123456", 20, true, 0, false, true);
if(createResult == null || createResult.getErrorCode() != ErrorCode.ERROR_CODE_SUCCESS) { if(createResult == null || createResult.getErrorCode() != ErrorCode.ERROR_CODE_SUCCESS) {
System.out.println("create conference failure"); System.out.println("create conference failure");
System.exit(-1); System.exit(-1);