From dd5ecd09f277999f27d0d73706b5ad28a3264187 Mon Sep 17 00:00:00 2001 From: "heavyrain.lee" Date: Fri, 28 Feb 2020 19:03:50 +0800 Subject: [PATCH] =?UTF-8?q?api=E7=9A=84=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../migrate/h2/V22__refactor_channel_status.sql | 1 + .../mysql/V27__refactor_channel_status.sql | 1 + .../persistence/MemoryMessagesStore.java | 5 ++--- .../cn/wildfirechat/proto/ProtoConstants.java | 17 +++++++++++++---- .../src/main/resources/wildfirechat.conf | 2 +- .../cn/wildfirechat/sdk/ChannelServiceApi.java | 12 ++++++++++++ 6 files changed, 30 insertions(+), 8 deletions(-) create mode 100755 broker/migrate/h2/V22__refactor_channel_status.sql create mode 100755 broker/migrate/mysql/V27__refactor_channel_status.sql diff --git a/broker/migrate/h2/V22__refactor_channel_status.sql b/broker/migrate/h2/V22__refactor_channel_status.sql new file mode 100755 index 00000000..007222c3 --- /dev/null +++ b/broker/migrate/h2/V22__refactor_channel_status.sql @@ -0,0 +1 @@ +update t_channel set `_status` = 64 where `_status` = 3; diff --git a/broker/migrate/mysql/V27__refactor_channel_status.sql b/broker/migrate/mysql/V27__refactor_channel_status.sql new file mode 100755 index 00000000..007222c3 --- /dev/null +++ b/broker/migrate/mysql/V27__refactor_channel_status.sql @@ -0,0 +1 @@ +update t_channel set `_status` = 64 where `_status` = 3; diff --git a/broker/src/main/java/io/moquette/persistence/MemoryMessagesStore.java b/broker/src/main/java/io/moquette/persistence/MemoryMessagesStore.java index b671669a..79326b57 100755 --- a/broker/src/main/java/io/moquette/persistence/MemoryMessagesStore.java +++ b/broker/src/main/java/io/moquette/persistence/MemoryMessagesStore.java @@ -50,8 +50,7 @@ import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; import java.util.function.Consumer; - -import static cn.wildfirechat.proto.ProtoConstants.ChannelStatus.Channel_Status_Destoryed; +import static cn.wildfirechat.proto.ProtoConstants.ChannelState.Channel_State_Mask_Deleted; import static cn.wildfirechat.proto.ProtoConstants.GroupMemberType.*; import static cn.wildfirechat.proto.ProtoConstants.ModifyChannelInfoType.*; import static cn.wildfirechat.proto.ProtoConstants.ModifyGroupInfoType.*; @@ -2617,7 +2616,7 @@ public class MemoryMessagesStore implements IMessagesStore { WFCMessage.ChannelInfo.Builder newInfoBuilder = oldInfo.toBuilder(); - newInfoBuilder.setStatus(Channel_Status_Destoryed); + newInfoBuilder.setStatus(oldInfo.getStatus() | Channel_State_Mask_Deleted); newInfoBuilder.setUpdateDt(System.currentTimeMillis()); mIMap.put(channelId, newInfoBuilder.build()); return ErrorCode.ERROR_CODE_SUCCESS; diff --git a/common/src/main/java/cn/wildfirechat/proto/ProtoConstants.java b/common/src/main/java/cn/wildfirechat/proto/ProtoConstants.java index 7bac27a4..1a7f6484 100644 --- a/common/src/main/java/cn/wildfirechat/proto/ProtoConstants.java +++ b/common/src/main/java/cn/wildfirechat/proto/ProtoConstants.java @@ -114,10 +114,19 @@ public class ProtoConstants { } //Channel -> status - public interface ChannelStatus { - int Channel_Status_Public = 0; - int Channel_Status_Private = 1; - int Channel_Status_Destoryed = 2; + //第0位表示是否允许查看用户所有信息,还是只允许看用户id,用户名称,用户昵称和用户头像 + //第1位表示是否允许查看非订阅用户信息 + //第2位表示是否允许主动添加用户订阅关系 + //第3位表示是否允许给非订阅用户发送消息 + //第4位表示是否私有 + //第6位表示是否删除 + public interface ChannelState { + int Channel_State_Mask_FullInfo = 0x01; + int Channel_State_Mask_Unsubscribed_User_Access = 0x02; + int Channel_State_Mask_Active_Subscribe = 0x04; + int Channel_State_Mask_Message_Unsubscribed = 0x08; + int Channel_State_Mask_Private = 0x10; + int Channel_State_Mask_Deleted = 0x40; } diff --git a/distribution/src/main/resources/wildfirechat.conf b/distribution/src/main/resources/wildfirechat.conf index b044f72c..96ed7a72 100755 --- a/distribution/src/main/resources/wildfirechat.conf +++ b/distribution/src/main/resources/wildfirechat.conf @@ -35,7 +35,7 @@ http.admin.secret_key 123456 ##服务器API接口参数是否检查时间。当设置为false时,所有的请求会检查时间的有效性;当设置为true时,可以在http.admin.secret_key保持不变的情况下,使用固定的服务API签名 ##nonce = "76616", timestamp = "1558350862502", sign = "b98f9b0717f59febccf1440067a7f50d9b31bdde" -http.admin.no_check_time true +http.admin.no_check_time false ##客户端协议栈密钥,需要与客户端协议栈文件libemqq.cc文件中的aes_key值保持一致,16进制byte用逗号分割。这个密钥对安全性帮助不大,客户不要修改 client.proto.secret_key 0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x78,0x79,0x7A,0x7B,0x7C,0x7D,0x7E,0x7F diff --git a/sdk/src/main/java/cn/wildfirechat/sdk/ChannelServiceApi.java b/sdk/src/main/java/cn/wildfirechat/sdk/ChannelServiceApi.java index a05fbd0f..8ec84e5c 100644 --- a/sdk/src/main/java/cn/wildfirechat/sdk/ChannelServiceApi.java +++ b/sdk/src/main/java/cn/wildfirechat/sdk/ChannelServiceApi.java @@ -24,6 +24,18 @@ public class ChannelServiceApi { return httpUtils.httpJsonPost(path, getUserInfo, InputOutputUserInfo.class); } + public IMResult getUserInfoByName(String userName) throws Exception { + String path = APIPath.Channel_User_Info; + InputGetUserInfo getUserInfo = new InputGetUserInfo(null, userName, null); + return httpUtils.httpJsonPost(path, getUserInfo, InputOutputUserInfo.class); + } + + public IMResult getUserInfoByMobile(String mobile) throws Exception { + String path = APIPath.Channel_User_Info; + InputGetUserInfo getUserInfo = new InputGetUserInfo(null, null, mobile); + return httpUtils.httpJsonPost(path, getUserInfo, InputOutputUserInfo.class); + } + public IMResult modifyChannelInfo(/*ProtoConstants.ModifyChannelInfoType*/int type, String value) throws Exception { String path = APIPath.Channel_Update_Profile; InputModifyChannelInfo modifyChannelInfo = new InputModifyChannelInfo();