Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
30cd56aae2 | ||
|
|
6fbecfb0fb | ||
|
|
d2cb8427bb | ||
|
|
826bad2d66 | ||
|
|
aaccec00e9 | ||
|
|
3c1c5ce6d3 | ||
|
|
b0fe1636a7 | ||
|
|
014cd3844d | ||
|
|
6cc00950f0 |
@@ -57,10 +57,13 @@ token.key testim
|
||||
##token.expire_time 2592000000
|
||||
|
||||
##首次登录,是否接收之前的历史消息。
|
||||
##0 不接收历史消息,只接收5分钟以内的消息,由于服务器没有保存已经收取记录,所以如果有超过5分钟之前未收取的消息也不会收取下拉;
|
||||
##0 不接收历史消息,只接收${message.compensate_time_limit}毫秒以内的消息,由于服务器没有保存已经收取记录,所以如果有超过${message.compensate_time_limit}毫秒之前未收取的消息也不会收取下拉;
|
||||
##1接收,会接收 message.max_queue 配置的条数的历史消息
|
||||
message.roaming 0
|
||||
|
||||
## 消息补偿时限,当${message.roaming}为0时,会同步时限以内且小于${message.max_queue}的消息,默认时限为5分钟。当${message.roaming}为1时,会接收 message.max_queue 配置的条数的历史消息。
|
||||
message.compensate_time_limit 300000
|
||||
|
||||
##是否开启拉取远程历史消息。如果为1,客户端在会话内如果本地消息读取完了,可以下拉继续加载在服务器上的该会话的消息;如果为0则不能。
|
||||
message.remote_history_message 0
|
||||
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
alter table `t_channel` add column `_menu` BLOB DEFAULT NULL;
|
||||
@@ -0,0 +1 @@
|
||||
alter table `t_channel` add column `_menu` BLOB DEFAULT NULL;
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<relativePath>../</relativePath>
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
<groupId>cn.wildfirechat</groupId>
|
||||
<version>0.91</version>
|
||||
<version>0.92</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>moquette-broker</artifactId>
|
||||
|
||||
@@ -131,6 +131,7 @@ public final class BrokerConstants {
|
||||
public static final String SERVER_CLIENT_SUPPORT_KICKOFF_EVENT = "server.client_support_kickoff_event";
|
||||
|
||||
public static final String MESSAGE_ROAMING = "message.roaming";
|
||||
public static final String MESSAGE_Compensate_Time_Limit = "message.compensate_time_limit";
|
||||
public static final String MESSAGE_Remote_History_Message = "message.remote_history_message";
|
||||
public static final String MESSAGE_Remote_Chatroom_History_Message = "message.chatroom_remote_history_message";
|
||||
|
||||
|
||||
@@ -2972,7 +2972,8 @@ public class DatabaseStore {
|
||||
", `_secret`" +
|
||||
", `_callback`" +
|
||||
", `_automatic`" +
|
||||
", `_dt`) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" +
|
||||
", `_menu`" +
|
||||
", `_dt`) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" +
|
||||
" ON DUPLICATE KEY UPDATE `_name`=?" +
|
||||
", `_portrait`=?" +
|
||||
", `_owner`=?" +
|
||||
@@ -2982,12 +2983,20 @@ public class DatabaseStore {
|
||||
", `_secret`=?" +
|
||||
", `_callback`=?" +
|
||||
", `_automatic`=?" +
|
||||
", `_menu`=?" +
|
||||
", `_dt`=?";
|
||||
|
||||
statement = connection.prepareStatement(sql);
|
||||
|
||||
int index = 1;
|
||||
WFCMessage.ChannelMenuList.Builder builder = WFCMessage.ChannelMenuList.newBuilder();
|
||||
if (!channelInfo.getMenuList().isEmpty()) {
|
||||
for (WFCMessage.ChannelMenu menuBtn:channelInfo.getMenuList()) {
|
||||
builder.addMenu(menuBtn);
|
||||
}
|
||||
}
|
||||
byte[] menuBytes = builder.build().toByteArray();
|
||||
|
||||
int index = 1;
|
||||
statement.setString(index++, channelInfo.getTargetId());
|
||||
statement.setString(index++, channelInfo.getName());
|
||||
statement.setString(index++, channelInfo.getPortrait());
|
||||
@@ -2998,6 +3007,7 @@ public class DatabaseStore {
|
||||
statement.setString(index++, channelInfo.getSecret());
|
||||
statement.setString(index++, channelInfo.getCallback());
|
||||
statement.setInt(index++, channelInfo.getAutomatic());
|
||||
statement.setBytes(index++, menuBytes);
|
||||
statement.setLong(index++, channelInfo.getUpdateDt() == 0 ? System.currentTimeMillis() : channelInfo.getUpdateDt());
|
||||
|
||||
statement.setString(index++, channelInfo.getName());
|
||||
@@ -3009,6 +3019,7 @@ public class DatabaseStore {
|
||||
statement.setString(index++, channelInfo.getSecret());
|
||||
statement.setString(index++, channelInfo.getCallback());
|
||||
statement.setInt(index++, channelInfo.getAutomatic());
|
||||
statement.setBytes(index++, menuBytes);
|
||||
statement.setLong(index++, channelInfo.getUpdateDt() == 0 ? System.currentTimeMillis() : channelInfo.getUpdateDt());
|
||||
|
||||
int count = statement.executeUpdate();
|
||||
@@ -3061,6 +3072,7 @@ public class DatabaseStore {
|
||||
", `_secret`" +
|
||||
", `_callback`" +
|
||||
", `_automatic`" +
|
||||
", `_menu`" +
|
||||
", `_dt` from t_channel where `_cid` = ?";
|
||||
|
||||
statement = connection.prepareStatement(sql);
|
||||
@@ -3111,6 +3123,21 @@ public class DatabaseStore {
|
||||
intValue = rs.getInt(index++);
|
||||
builder.setAutomatic(intValue);
|
||||
|
||||
try {
|
||||
byte[] bytes = null;
|
||||
Blob blob = rs.getBlob(index++);
|
||||
if (blob != null) {
|
||||
bytes = toByteArray(blob.getBinaryStream());
|
||||
}
|
||||
|
||||
WFCMessage.ChannelMenuList menuButtonList = WFCMessage.ChannelMenuList.parseFrom(bytes);
|
||||
if (menuButtonList.getMenuCount() > 0) {
|
||||
builder.addAllMenu(menuButtonList.getMenuList());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
long longValue = rs.getLong(index++);
|
||||
builder.setUpdateDt(longValue);
|
||||
|
||||
|
||||
@@ -96,6 +96,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
private static final String CHANNEL_LISTENERS = "channel_listeners";
|
||||
|
||||
private static boolean IS_MESSAGE_ROAMING = true;
|
||||
private static long msgCompensateTimeLimit = 300000;
|
||||
|
||||
private static boolean IS_MESSAGE_REMOTE_HISTORY_MESSAGE = true;
|
||||
private static boolean IS_CHATROOM_MESSAGE_REMOTE_HISTORY_MESSAGE = true;
|
||||
@@ -178,6 +179,11 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
this.databaseStore = databaseStore;
|
||||
|
||||
IS_MESSAGE_ROAMING = "1".equals(m_Server.getConfig().getProperty(MESSAGE_ROAMING));
|
||||
try {
|
||||
msgCompensateTimeLimit = Long.parseLong(m_Server.getConfig().getProperty(MESSAGE_Compensate_Time_Limit, "300000"));
|
||||
} catch (NumberFormatException e) {
|
||||
|
||||
}
|
||||
IS_MESSAGE_REMOTE_HISTORY_MESSAGE = "1".equals(m_Server.getConfig().getProperty(MESSAGE_Remote_History_Message));
|
||||
IS_CHATROOM_MESSAGE_REMOTE_HISTORY_MESSAGE = "1".equals(m_Server.getConfig().getProperty(MESSAGE_Remote_Chatroom_History_Message, "1"));
|
||||
Constants.MAX_MESSAGE_QUEUE = Integer.parseInt(m_Server.getConfig().getProperty(MESSAGE_Max_Queue));
|
||||
@@ -739,7 +745,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
}
|
||||
}
|
||||
|
||||
if (noRoaming && (System.currentTimeMillis() - bundle.getMessage().getServerTimestamp() > 5 * 60 * 1000)) {
|
||||
if (noRoaming && (System.currentTimeMillis() - bundle.getMessage().getServerTimestamp() > msgCompensateTimeLimit)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -3882,9 +3888,15 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
e.printStackTrace();
|
||||
Utility.printExecption(LOG, e);
|
||||
}
|
||||
} else if(modifyType == Modify_Channel_Menu) {
|
||||
OutputGetChannelInfo.OutputMenuList outputMenuButtons = new Gson().fromJson(value, OutputGetChannelInfo.OutputMenuList.class);
|
||||
if (!outputMenuButtons.isEmpty()) {
|
||||
for (OutputGetChannelInfo.OutputMenu outputMenuButton : outputMenuButtons) {
|
||||
newInfoBuilder.addMenu(outputMenuButton.toPbInfo());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
newInfoBuilder.setUpdateDt(System.currentTimeMillis());
|
||||
mIMap.put(channelId, newInfoBuilder.build());
|
||||
callbackChannelInfoUpdateEvent(operator, channelId, Channel_Event_Update);
|
||||
|
||||
@@ -369,9 +369,6 @@ public class Server {
|
||||
private String getServerIp(IConfig config) {
|
||||
String serverIp = config.getProperty(BrokerConstants.SERVER_IP_PROPERTY_NAME);
|
||||
if (serverIp == null || serverIp.equals("0.0.0.0")) {
|
||||
String warning = "警告:无效配置,server.ip不能为空,需要配置服务的公网IP地址或者域名才能在公网使用!!!\nIM服务将使用本地地址,只能在局域网内使用!";
|
||||
System.out.println(warning);
|
||||
LOG.error(warning);
|
||||
serverIp = Utility.getLocalAddress().getHostAddress();
|
||||
}
|
||||
return serverIp;
|
||||
|
||||
@@ -604,7 +604,7 @@ public class MessagesPublisher {
|
||||
public void publish2Receivers(WFCMessage.Message message, Set<String> receivers, String exceptClientId, int pullType) {
|
||||
if (message.getConversation().getType() == ProtoConstants.ConversationType.ConversationType_Channel) {
|
||||
WFCMessage.ChannelInfo channelInfo = m_messagesStore.getChannelInfo(message.getConversation().getTarget());
|
||||
if (channelInfo != null && !StringUtil.isNullOrEmpty(channelInfo.getCallback())) {
|
||||
if (channelInfo != null && !StringUtil.isNullOrEmpty(channelInfo.getCallback()) && channelInfo.getAutomatic() == 1 && !message.getFromUser().equals(channelInfo.getOwner())) {
|
||||
OutputClient outputClient = null;
|
||||
if(m_messagesStore.isChannelCallbackWithClientInfo() && !StringUtil.isNullOrEmpty(exceptClientId)) {
|
||||
Session session = m_sessionsStore.getSession(exceptClientId);
|
||||
@@ -701,7 +701,7 @@ public class MessagesPublisher {
|
||||
}
|
||||
|
||||
public void notifyChannelListenStatusChanged(WFCMessage.ChannelInfo channelInfo, String user, boolean listen) {
|
||||
if (channelInfo == null || StringUtil.isNullOrEmpty(channelInfo.getCallback())) {
|
||||
if (channelInfo == null || StringUtil.isNullOrEmpty(channelInfo.getCallback()) || channelInfo.getAutomatic() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ public class DBUtil {
|
||||
if (embedDB != null && embedDB.equals("1")) {
|
||||
IsEmbedDB = true;
|
||||
LOG.info("Use h2 database");
|
||||
String warning = "您正在使用内置h2数据库,建议仅在开发验证或者用户数小于100人时才使用此数据库,其它情况建议使用MySQL。";
|
||||
String warning = "您正在使用h2数据库,建议仅在开发验证或者用户数小于100人时才使用此数据库。正式上线时建议切换到MySQL数据库。";
|
||||
System.out.println(warning);
|
||||
LOG.warn(warning);
|
||||
} else {
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
<groupId>cn.wildfirechat</groupId>
|
||||
<version>0.91</version>
|
||||
<version>0.92</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package cn.wildfirechat.pojos;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
|
||||
public class ArticleContent {
|
||||
public static class Article {
|
||||
public String id;
|
||||
public String cover;
|
||||
public String title;
|
||||
public String url;
|
||||
public boolean rr;
|
||||
|
||||
public Article() {
|
||||
}
|
||||
|
||||
public Article(String id, String cover, String title, String url, boolean rr) {
|
||||
this.id = id;
|
||||
this.cover = cover;
|
||||
this.title = title;
|
||||
this.url = url;
|
||||
this.rr = rr;
|
||||
}
|
||||
}
|
||||
public Article top;
|
||||
public List<Article> subArticles;
|
||||
|
||||
public ArticleContent() {
|
||||
}
|
||||
|
||||
public ArticleContent(String id, String cover, String title, String url, boolean rr) {
|
||||
this.top = new Article(id, cover, title, url, rr);
|
||||
}
|
||||
|
||||
public ArticleContent addSubArticle(String id, String cover, String title, String url, boolean rr) {
|
||||
if (subArticles == null)
|
||||
subArticles = new ArrayList<>();
|
||||
subArticles.add(new Article(id, cover, title, url, rr));
|
||||
return this;
|
||||
}
|
||||
|
||||
public MessagePayload toPayload() {
|
||||
MessagePayload payload = new MessagePayload();
|
||||
payload.setType(13);
|
||||
payload.setSearchableContent(top.title);
|
||||
payload.setBase64edData(Base64.getEncoder().encodeToString(new Gson().toJson(this).getBytes(StandardCharsets.UTF_8)));
|
||||
return payload;
|
||||
}
|
||||
}
|
||||
@@ -3,4 +3,5 @@ package cn.wildfirechat.pojos;
|
||||
public class ConferenceJoinEvent {
|
||||
public String userId;
|
||||
public String roomId;
|
||||
public boolean screenSharing;
|
||||
}
|
||||
|
||||
@@ -3,4 +3,5 @@ package cn.wildfirechat.pojos;
|
||||
public class ConferenceLeaveEvent {
|
||||
public String userId;
|
||||
public String roomId;
|
||||
public boolean screenSharing;
|
||||
}
|
||||
|
||||
@@ -4,4 +4,5 @@ public class ConferencePublishEvent {
|
||||
public String userId;
|
||||
public boolean video;
|
||||
public String roomId;
|
||||
public boolean screenSharing;
|
||||
}
|
||||
|
||||
@@ -3,4 +3,5 @@ package cn.wildfirechat.pojos;
|
||||
public class ConferenceUnpublishEvent {
|
||||
public String userId;
|
||||
public String roomId;
|
||||
public boolean screenSharing;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,9 @@ public class ForwardDeviceMessageData {
|
||||
private int type;
|
||||
private byte[] data;
|
||||
|
||||
public ForwardDeviceMessageData() {
|
||||
}
|
||||
|
||||
public ForwardDeviceMessageData(String deviceId, int type, byte[] data) {
|
||||
this.deviceId = deviceId;
|
||||
this.type = type;
|
||||
|
||||
@@ -31,6 +31,9 @@ public class GroupNotificationBinaryContent {
|
||||
//value2(member or something)
|
||||
private String m;
|
||||
|
||||
public GroupNotificationBinaryContent() {
|
||||
}
|
||||
|
||||
public GroupNotificationBinaryContent(String g, String o, String n, String m) {
|
||||
this.g = g;
|
||||
this.o = o;
|
||||
|
||||
@@ -13,6 +13,9 @@ public class InputChatroomMute {
|
||||
private String chatroomId;
|
||||
private int status;
|
||||
|
||||
public InputChatroomMute() {
|
||||
}
|
||||
|
||||
public InputChatroomMute(String chatroomId, int status) {
|
||||
this.chatroomId = chatroomId;
|
||||
this.status = status;
|
||||
|
||||
@@ -5,6 +5,9 @@ public class InputGetToken {
|
||||
private String clientId;
|
||||
private Integer platform;
|
||||
|
||||
public InputGetToken() {
|
||||
}
|
||||
|
||||
public InputGetToken(String userId, String clientId, int platform) {
|
||||
this.userId = userId;
|
||||
this.clientId = clientId;
|
||||
|
||||
@@ -13,6 +13,9 @@ public class InputGetUserInfo {
|
||||
private String name;
|
||||
private String mobile;
|
||||
|
||||
public InputGetUserInfo() {
|
||||
}
|
||||
|
||||
public InputGetUserInfo(String userId, String name, String mobile) {
|
||||
this.userId = userId;
|
||||
this.name = name;
|
||||
|
||||
@@ -13,6 +13,9 @@ public class InputOutputUserBlockStatus {
|
||||
private String userId;
|
||||
private int status;
|
||||
|
||||
public InputOutputUserBlockStatus() {
|
||||
}
|
||||
|
||||
public InputOutputUserBlockStatus(String userId, int status) {
|
||||
this.userId = userId;
|
||||
this.status = status;
|
||||
|
||||
@@ -13,6 +13,9 @@ public class OutputCreateDevice {
|
||||
private String token;
|
||||
private String secret;
|
||||
|
||||
public OutputCreateDevice() {
|
||||
}
|
||||
|
||||
public OutputCreateDevice(String userId, String token, String secret) {
|
||||
this.deviceId = userId;
|
||||
this.token = token;
|
||||
|
||||
@@ -12,6 +12,9 @@ public class OutputCreateRobot {
|
||||
private String userId;
|
||||
private String secret;
|
||||
|
||||
public OutputCreateRobot() {
|
||||
}
|
||||
|
||||
public OutputCreateRobot(String userId, String secret) {
|
||||
this.userId = userId;
|
||||
this.secret = secret;
|
||||
|
||||
@@ -12,6 +12,9 @@ public class OutputCreateUser {
|
||||
private String userId;
|
||||
private String name;
|
||||
|
||||
public OutputCreateUser() {
|
||||
}
|
||||
|
||||
public OutputCreateUser(String userId, String name) {
|
||||
this.userId = userId;
|
||||
this.name = name;
|
||||
|
||||
@@ -20,6 +20,9 @@ public class OutputDevice {
|
||||
private List<String> owners;
|
||||
private String extra;
|
||||
|
||||
public OutputDevice() {
|
||||
}
|
||||
|
||||
public OutputDevice(String deviceId, String token, String secret) {
|
||||
this.deviceId = deviceId;
|
||||
this.token = token;
|
||||
|
||||
@@ -10,8 +10,69 @@ package cn.wildfirechat.pojos;
|
||||
|
||||
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class OutputGetChannelInfo {
|
||||
public static class OutputMenu {
|
||||
public String menuId;
|
||||
public String type;
|
||||
public String name;
|
||||
public String key;
|
||||
public String url;
|
||||
public String mediaId;
|
||||
public String articleId;
|
||||
public String appId;
|
||||
public String appPage;
|
||||
public String extra;
|
||||
public List<OutputMenu> subMenus;
|
||||
|
||||
public static OutputMenu fromPbInfo(WFCMessage.ChannelMenu channelMenuMenu) {
|
||||
OutputMenu out = new OutputMenu();
|
||||
out.menuId = channelMenuMenu.getMenuId();
|
||||
out.type = channelMenuMenu.getType();
|
||||
out.name = channelMenuMenu.getName();
|
||||
out.key = channelMenuMenu.getKey();
|
||||
out.url = channelMenuMenu.getUrl();
|
||||
out.mediaId = channelMenuMenu.getMediaId();
|
||||
out.articleId = channelMenuMenu.getArticleId();
|
||||
out.appId = channelMenuMenu.getAppId();
|
||||
out.appPage = channelMenuMenu.getAppPage();
|
||||
out.extra = channelMenuMenu.getExtra();
|
||||
if (channelMenuMenu.getSubMenuCount() > 0) {
|
||||
out.subMenus = new ArrayList<>();
|
||||
for (WFCMessage.ChannelMenu menuMenu : channelMenuMenu.getSubMenuList()) {
|
||||
out.subMenus.add(fromPbInfo(menuMenu));
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
public WFCMessage.ChannelMenu.Builder toPbInfo() {
|
||||
WFCMessage.ChannelMenu.Builder builder = WFCMessage.ChannelMenu.newBuilder();
|
||||
builder.setType(type);
|
||||
builder.setName(name);
|
||||
if (!StringUtil.isNullOrEmpty(menuId)) builder.setMenuId(menuId);
|
||||
if (!StringUtil.isNullOrEmpty(key)) builder.setKey(key);
|
||||
if (!StringUtil.isNullOrEmpty(url)) builder.setUrl(url);
|
||||
if (!StringUtil.isNullOrEmpty(mediaId)) builder.setMediaId(mediaId);
|
||||
if (!StringUtil.isNullOrEmpty(articleId)) builder.setArticleId(articleId);
|
||||
if (!StringUtil.isNullOrEmpty(appId)) builder.setAppId(appId);
|
||||
if (!StringUtil.isNullOrEmpty(appPage)) builder.setAppPage(appPage);
|
||||
if (!StringUtil.isNullOrEmpty(extra)) builder.setExtra(extra);
|
||||
if (subMenus != null && !subMenus.isEmpty()) {
|
||||
subMenus.forEach(menuMenu -> builder.addSubMenu(menuMenu.toPbInfo()));
|
||||
}
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
|
||||
public static class OutputMenuList extends ArrayList<OutputMenu> {
|
||||
|
||||
}
|
||||
|
||||
private String channelId;
|
||||
private String name;
|
||||
private String desc;
|
||||
@@ -24,7 +85,7 @@ public class OutputGetChannelInfo {
|
||||
private String callback;
|
||||
private int automatic;
|
||||
private String secret;
|
||||
|
||||
public List<OutputMenu> menus;
|
||||
|
||||
public String getChannelId() {
|
||||
return channelId;
|
||||
@@ -136,6 +197,13 @@ public class OutputGetChannelInfo {
|
||||
out.status = channelInfo.getStatus();;
|
||||
out.updateDt = channelInfo.getUpdateDt();
|
||||
out.secret = channelInfo.getSecret();
|
||||
if (channelInfo.getMenuCount() > 0) {
|
||||
out.menus = new ArrayList<>();
|
||||
for (WFCMessage.ChannelMenu channelMenuMenu : channelInfo.getMenuList()) {
|
||||
out.menus.add(OutputMenu.fromPbInfo(channelMenuMenu));
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,9 @@ public class OutputLoginData {
|
||||
private String userId;
|
||||
private String token;
|
||||
|
||||
public OutputLoginData() {
|
||||
}
|
||||
|
||||
public OutputLoginData(String userId, String token) {
|
||||
this.userId = userId;
|
||||
this.token = token;
|
||||
|
||||
@@ -13,6 +13,9 @@ public class OutputNotifyChannelSubscribeStatus {
|
||||
private String channelId;
|
||||
private int status;
|
||||
|
||||
public OutputNotifyChannelSubscribeStatus() {
|
||||
}
|
||||
|
||||
public OutputNotifyChannelSubscribeStatus(String userId, String channelId, boolean subscirbed) {
|
||||
this.userId = userId;
|
||||
this.channelId = channelId;
|
||||
|
||||
@@ -16,6 +16,9 @@ public class OutputRouteData { ;
|
||||
private int shortPort;
|
||||
private String secret;
|
||||
|
||||
public OutputRouteData() {
|
||||
}
|
||||
|
||||
public OutputRouteData(List<String> serverIPs, int longPort, int shortPort, String secret) {
|
||||
this.serverIPs = serverIPs;
|
||||
this.longPort = longPort;
|
||||
|
||||
@@ -173,6 +173,7 @@ public class ProtoConstants {
|
||||
int Modify_Channel_Secret = 4;
|
||||
int Modify_Channel_Callback = 5;
|
||||
int Modify_Channel_OnlyCallback = 6;
|
||||
int Modify_Channel_Menu = 7;
|
||||
}
|
||||
|
||||
//Channel -> status
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -6,7 +6,7 @@
|
||||
<!--<relativePath>../pom.xml</relativePath>-->
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
<groupId>cn.wildfirechat</groupId>
|
||||
<version>0.91</version>
|
||||
<version>0.92</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>distribution</artifactId>
|
||||
@@ -51,7 +51,7 @@
|
||||
<!--指定"git.properties"文件的存放路径(相对于${project.basedir}的一个路径);-->
|
||||
<generateGitPropertiesFilename>src/main/resources/git.properties</generateGitPropertiesFilename>
|
||||
<!--".git"文件夹未找到时,构建是否失败;若设置true,则构建失败;若设置false,则跳过执行该目标;默认值:true;-->
|
||||
<failOnNoGitDirectory>true</failOnNoGitDirectory>
|
||||
<failOnNoGitDirectory>false</failOnNoGitDirectory>
|
||||
|
||||
<!--git描述配置,可选;由JGit提供实现;-->
|
||||
<gitDescribe>
|
||||
|
||||
@@ -24,6 +24,11 @@
|
||||
<directory>../broker/config/i18n/</directory>
|
||||
<outputDirectory>/config/i18n</outputDirectory>
|
||||
</fileSet>
|
||||
|
||||
<fileSet>
|
||||
<directory>src/main/resources/</directory>
|
||||
<outputDirectory>config/</outputDirectory>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
|
||||
<files>
|
||||
@@ -40,32 +45,7 @@
|
||||
</file>
|
||||
|
||||
<file>
|
||||
<source>src/main/resources/log4j2.xml</source>
|
||||
<outputDirectory>config/</outputDirectory>
|
||||
<destName>log4j2.xml</destName>
|
||||
</file>
|
||||
|
||||
<file>
|
||||
<source>src/main/resources/wildfirechat.conf</source>
|
||||
<outputDirectory>config/</outputDirectory>
|
||||
</file>
|
||||
|
||||
<file>
|
||||
<source>src/main/resources/hazelcast.xml</source>
|
||||
<outputDirectory>config/</outputDirectory>
|
||||
</file>
|
||||
<file>
|
||||
<source>src/main/resources/c3p0-config.xml</source>
|
||||
<outputDirectory>config/</outputDirectory>
|
||||
</file>
|
||||
|
||||
<file>
|
||||
<source>src/main/resources/README.txt</source>
|
||||
</file>
|
||||
|
||||
<file>
|
||||
<source>src/main/resources/git.properties</source>
|
||||
<outputDirectory>config/</outputDirectory>
|
||||
<source>src/main/files/README.txt</source>
|
||||
</file>
|
||||
|
||||
<file>
|
||||
|
||||
@@ -53,10 +53,13 @@ token.key testim
|
||||
##token.expire_time 2592000000
|
||||
|
||||
##首次登录,是否接收之前的历史消息。
|
||||
##0 不接收历史消息,只接收5分钟以内的消息,由于服务器没有保存已经收取记录,所以如果有超过5分钟之前未收取的消息也不会收取下拉;
|
||||
##0 不接收历史消息,只接收${message.compensate_time_limit}毫秒以内的消息,由于服务器没有保存已经收取记录,所以如果有超过${message.compensate_time_limit}毫秒之前未收取的消息也不会收取下拉;
|
||||
##1接收,会接收 message.max_queue 配置的条数的历史消息
|
||||
message.roaming 0
|
||||
|
||||
## 消息补偿时限,当${message.roaming}为0时,会同步时限以内且小于${message.max_queue}的消息,默认时限为5分钟。当${message.roaming}为1时,会接收 message.max_queue 配置的条数的历史消息。
|
||||
message.compensate_time_limit 300000
|
||||
|
||||
##是否开启拉取远程历史消息。如果为1,客户端在会话内如果本地消息读取完了,可以下拉继续加载在服务器上的该会话的消息;如果为0则不能。
|
||||
message.remote_history_message 0
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
|
||||
<packaging>pom</packaging>
|
||||
<version>0.91</version>
|
||||
<version>0.92</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.91</version>
|
||||
<version>0.92</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -8,13 +8,11 @@ import cn.wildfirechat.proto.ProtoConstants;
|
||||
import cn.wildfirechat.sdk.model.IMResult;
|
||||
import cn.wildfirechat.sdk.utilities.AdminHttpUtils;
|
||||
import cn.wildfirechat.sdk.utilities.RobotHttpUtils;
|
||||
import com.google.gson.Gson;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
import static cn.wildfirechat.pojos.MyInfoType.Modify_DisplayName;
|
||||
import static cn.wildfirechat.proto.ProtoConstants.ChannelState.*;
|
||||
@@ -827,8 +825,8 @@ public class Main {
|
||||
|
||||
IMResult<OutputGetChannelInfo> resultGetChannel = GeneralAdmin.getChannelInfo(inputCreateChannel.getTargetId());
|
||||
if(resultGetChannel != null && resultGetChannel.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS
|
||||
&& resultGetChannel.getResult().getName().equals(channelName)
|
||||
&& resultGetChannel.getResult().getOwner().equals(channelOwner)) {
|
||||
&& resultGetChannel.getResult().getName().equals(channelName)
|
||||
&& resultGetChannel.getResult().getOwner().equals(channelOwner)) {
|
||||
System.out.println("success");
|
||||
} else {
|
||||
System.out.println("get channel failure");
|
||||
@@ -1356,7 +1354,11 @@ public class Main {
|
||||
inputCreateChannel.setName("testChannel");
|
||||
inputCreateChannel.setOwner("userId1");
|
||||
String secret = "channelsecret";
|
||||
String channelId = "channelId123";
|
||||
inputCreateChannel.setSecret(secret);
|
||||
inputCreateChannel.setTargetId(channelId);
|
||||
inputCreateChannel.setAuto(1);
|
||||
inputCreateChannel.setCallback("http://192.168.1.81:8088/wf/channelId123");
|
||||
inputCreateChannel.setState(Channel_State_Mask_FullInfo | Channel_State_Mask_Unsubscribed_User_Access | Channel_State_Mask_Active_Subscribe | Channel_State_Mask_Message_Unsubscribed);
|
||||
IMResult<OutputCreateChannel> resultCreateChannel = GeneralAdmin.createChannel(inputCreateChannel);
|
||||
if (resultCreateChannel != null && resultCreateChannel.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
@@ -1368,7 +1370,7 @@ public class Main {
|
||||
|
||||
|
||||
//2. 初始化api,注意端口是80,不是18080
|
||||
ChannelServiceApi channelServiceApi = new ChannelServiceApi(IMUrl, resultCreateChannel.getResult().getTargetId(), secret);
|
||||
ChannelServiceApi channelServiceApi = new ChannelServiceApi(IMUrl, channelId, secret);
|
||||
|
||||
|
||||
//3. 测试channel api功能
|
||||
@@ -1424,7 +1426,20 @@ public class Main {
|
||||
payload.setType(1);
|
||||
payload.setSearchableContent("hello world");
|
||||
|
||||
IMResult<SendMessageResult> resultSendMessage = channelServiceApi.sendMessage(0, null,payload);
|
||||
IMResult<SendMessageResult> resultSendMessage = channelServiceApi.sendMessage(0, null, payload);
|
||||
if (resultSendMessage != null && resultSendMessage.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("send message to all the subscriber success");
|
||||
} else {
|
||||
System.out.println("send message to all the subscriber failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
ArticleContent articleContent = new ArticleContent("article1", "https://media.wfcoss.cn/channel-assets/20220816/2dd76540daa9444dae44e942aa1c2bbc.png", "这是一个测试文章", "https://mp.weixin.qq.com/s/W6tanLbALd3qqZM8r3MTgA", true);
|
||||
articleContent.addSubArticle("article2", "https://media.wfcoss.cn/channel-assets/20220816/2dd76540daa9444dae44e942aa1c2bbc.png", "这是第二个测试文章", "https://mp.weixin.qq.com/s/W6tanLbALd3qqZM8r3MTgA", false);
|
||||
articleContent.addSubArticle("article3", "https://media.wfcoss.cn/channel-assets/20220816/2dd76540daa9444dae44e942aa1c2bbc.png", "这是第三个测试文章", "https://mp.weixin.qq.com/s/W6tanLbALd3qqZM8r3MTgA", false);
|
||||
payload = articleContent.toPayload();
|
||||
|
||||
resultSendMessage = channelServiceApi.sendMessage(0, null, payload);
|
||||
if (resultSendMessage != null && resultSendMessage.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("send message to all the subscriber success");
|
||||
} else {
|
||||
@@ -1450,6 +1465,41 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
List<OutputGetChannelInfo.OutputMenu> menus = new ArrayList<>();
|
||||
OutputGetChannelInfo.OutputMenu menu1 = new OutputGetChannelInfo.OutputMenu();
|
||||
menu1.menuId = UUID.randomUUID().toString();
|
||||
menu1.type = "view";
|
||||
menu1.name = "一级菜单1";
|
||||
menu1.key = "key1";
|
||||
menu1.url = "http://www.baidu.com";
|
||||
menus.add(menu1);
|
||||
|
||||
OutputGetChannelInfo.OutputMenu menu2 = new OutputGetChannelInfo.OutputMenu();
|
||||
menu2.menuId = UUID.randomUUID().toString();
|
||||
menu2.type = "view";
|
||||
menu2.name = "一级菜单2";
|
||||
menu2.key = "key2";
|
||||
menu2.url = "http://www.sohu.com";
|
||||
menu2.subMenus = new ArrayList<>();
|
||||
menus.add(menu2);
|
||||
|
||||
OutputGetChannelInfo.OutputMenu menu21 = new OutputGetChannelInfo.OutputMenu();
|
||||
menu21.menuId = UUID.randomUUID().toString();
|
||||
menu21.type = "click";
|
||||
menu21.name = "二级菜单21";
|
||||
menu21.key = "key21";
|
||||
menu21.url = "http://www.sohu.com";
|
||||
menu2.subMenus.add(menu21);
|
||||
|
||||
String menuStr = new Gson().toJson(menus);
|
||||
voidIMResult = channelServiceApi.modifyChannelInfo(ProtoConstants.ModifyChannelInfoType.Modify_Channel_Menu, menuStr);
|
||||
if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("modify channel menu success");
|
||||
} else {
|
||||
System.out.println("modify channel menu failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
IMResult<OutputGetChannelInfo> outputGetChannelInfoIMResult = channelServiceApi.getChannelInfo();
|
||||
if (outputGetChannelInfoIMResult != null && outputGetChannelInfoIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("get channel info success");
|
||||
|
||||
Reference in New Issue
Block a user