sdk添加对设置会话置顶的功能

This commit is contained in:
imhao183
2021-01-14 10:28:17 +08:00
parent 38595c06d8
commit 5dbfeaabf9
3 changed files with 99 additions and 1 deletions
@@ -27,4 +27,40 @@ public class GeneralAdmin {
return AdminHttpUtils.httpJsonPost(path, inputCreateChannel, OutputCreateChannel.class);
}
//以下仅专业版支持
public static IMResult<Void> 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<Boolean> getConversationTop(String userId, int conversationType, String target, int line) throws Exception {
String key = conversationType + "-" + line + "-" + target;
IMResult<UserSettingPojo> result = getUserSetting(userId, 3, key);
IMResult<Boolean> out = new IMResult<Boolean>();
out.code = result.code;
out.msg = result.msg;
out.result = result.result != null && "1".equals(result.result.getValue());
return out;
}
private static IMResult<UserSettingPojo> 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<Void> 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);
}
}