diff --git a/common/src/main/java/cn/wildfirechat/common/APIPath.java b/common/src/main/java/cn/wildfirechat/common/APIPath.java index 0da5b362..723de0b3 100644 --- a/common/src/main/java/cn/wildfirechat/common/APIPath.java +++ b/common/src/main/java/cn/wildfirechat/common/APIPath.java @@ -28,7 +28,8 @@ public interface APIPath { String User_Get_Blocked_List = "/admin/user/get_blocked_list"; String User_Check_Block_Status = "/admin/user/check_block_status"; String User_Get_Online_Status = "/admin/user/onlinestatus"; - + String User_Put_Setting = "/admin/user/put_setting"; + String User_Get_Setting = "/admin/user/get_setting"; String Friend_Update_Status = "/admin/friend/status"; String Friend_Get_List = "/admin/friend/list"; diff --git a/common/src/main/java/cn/wildfirechat/pojos/UserSettingPojo.java b/common/src/main/java/cn/wildfirechat/pojos/UserSettingPojo.java new file mode 100755 index 00000000..a7aec9b4 --- /dev/null +++ b/common/src/main/java/cn/wildfirechat/pojos/UserSettingPojo.java @@ -0,0 +1,61 @@ +/* + * This file is part of the Wildfire Chat package. + * (c) Heavyrain2012 + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +package cn.wildfirechat.pojos; + +import cn.wildfirechat.proto.WFCMessage; +import io.netty.util.internal.StringUtil; + +public class UserSettingPojo { + private String userId; + private int scope; + private String key; + private String value; + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public int getScope() { + return scope; + } + + public void setScope(int scope) { + this.scope = scope; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + public WFCMessage.ModifyUserSettingReq toProtoRequest() { + WFCMessage.ModifyUserSettingReq.Builder builder = WFCMessage.ModifyUserSettingReq.newBuilder(); + builder.setScope(scope); + if (!StringUtil.isNullOrEmpty(key)) + builder.setKey(key); + if(!StringUtil.isNullOrEmpty(value)) + builder.setValue(value); + + return builder.build(); + } +} diff --git a/sdk/src/main/java/cn/wildfirechat/sdk/GeneralAdmin.java b/sdk/src/main/java/cn/wildfirechat/sdk/GeneralAdmin.java index 7c955bc5..047d44d0 100644 --- a/sdk/src/main/java/cn/wildfirechat/sdk/GeneralAdmin.java +++ b/sdk/src/main/java/cn/wildfirechat/sdk/GeneralAdmin.java @@ -27,4 +27,40 @@ public class GeneralAdmin { return AdminHttpUtils.httpJsonPost(path, inputCreateChannel, OutputCreateChannel.class); } + //以下仅专业版支持 + public static IMResult setConversationTop(String userId, int conversationType, String target, int line, boolean isTop) throws Exception { + String key = conversationType + "-" + line + "-" + target; + String value = isTop?"1":"0"; + return setUserSetting(userId, 3, key, value); + } + + public static IMResult getConversationTop(String userId, int conversationType, String target, int line) throws Exception { + String key = conversationType + "-" + line + "-" + target; + IMResult result = getUserSetting(userId, 3, key); + IMResult out = new IMResult(); + out.code = result.code; + out.msg = result.msg; + out.result = result.result != null && "1".equals(result.result.getValue()); + return out; + } + + + private static IMResult getUserSetting(String userId, int scope, String key) throws Exception { + String path = APIPath.User_Get_Setting; + UserSettingPojo pojo = new UserSettingPojo(); + pojo.setUserId(userId); + pojo.setScope(scope); + pojo.setKey(key); + return AdminHttpUtils.httpJsonPost(path, pojo, UserSettingPojo.class); + } + + private static IMResult setUserSetting(String userId, int scope, String key, String value) throws Exception { + String path = APIPath.User_Put_Setting; + UserSettingPojo pojo = new UserSettingPojo(); + pojo.setUserId(userId); + pojo.setScope(scope); + pojo.setKey(key); + pojo.setValue(value); + return AdminHttpUtils.httpJsonPost(path, pojo, Void.class); + } }