调整用户关系API
This commit is contained in:
+88
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* This file is part of the Wildfire Chat package.
|
||||
* (c) Heavyrain2012 <[email protected]>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
package com.xiaoleilu.loServer.action.admin;
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import cn.wildfirechat.pojos.InputBlacklistRequest;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import com.google.gson.Gson;
|
||||
import com.xiaoleilu.loServer.RestResult;
|
||||
import com.xiaoleilu.loServer.annotation.HttpMethod;
|
||||
import com.xiaoleilu.loServer.annotation.Route;
|
||||
import com.xiaoleilu.loServer.handler.Request;
|
||||
import com.xiaoleilu.loServer.handler.Response;
|
||||
import io.moquette.persistence.RPCCenter;
|
||||
import io.moquette.persistence.TargetEntry;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import win.liyufan.im.IMTopic;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@Route(APIPath.Blacklist_Update_Status)
|
||||
@HttpMethod("POST")
|
||||
public class BlacklistAction extends AdminAction {
|
||||
|
||||
@Override
|
||||
public boolean isTransactionAction() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean action(Request request, Response response) {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
InputBlacklistRequest inputData = getRequestBody(request.getNettyRequest(), InputBlacklistRequest.class);
|
||||
if (inputData != null
|
||||
&& !StringUtil.isNullOrEmpty(inputData.getUserId())
|
||||
&& !StringUtil.isNullOrEmpty(inputData.getTargetUid())
|
||||
) {
|
||||
WFCMessage.BlackUserRequest friendRequest = WFCMessage.BlackUserRequest.newBuilder().setUid(inputData.getTargetUid()).setStatus(inputData.getStatus()).build();
|
||||
RPCCenter.getInstance().sendRequest(inputData.getUserId(), null, IMTopic.BlackListUserTopic, friendRequest.toByteArray(), inputData.getUserId(), TargetEntry.Type.TARGET_TYPE_USER, new RPCCenter.Callback() {
|
||||
@Override
|
||||
public void onSuccess(byte[] result) {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
sendResponse(response, null, null);
|
||||
} else {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ErrorCode errorCode) {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeout() {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_TIMEOUT, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor getResponseExecutor() {
|
||||
return command -> ctx.executor().execute(command);
|
||||
}
|
||||
}, true);
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* This file is part of the Wildfire Chat package.
|
||||
* (c) Heavyrain2012 <[email protected]>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
package com.xiaoleilu.loServer.action.admin;
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import cn.wildfirechat.pojos.InputGetFriendList;
|
||||
import cn.wildfirechat.pojos.InputUserId;
|
||||
import cn.wildfirechat.pojos.OutputStringList;
|
||||
import com.google.gson.Gson;
|
||||
import com.xiaoleilu.loServer.RestResult;
|
||||
import com.xiaoleilu.loServer.annotation.HttpMethod;
|
||||
import com.xiaoleilu.loServer.annotation.Route;
|
||||
import com.xiaoleilu.loServer.handler.Request;
|
||||
import com.xiaoleilu.loServer.handler.Response;
|
||||
import com.xiaoleilu.loServer.model.FriendData;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Route(APIPath.Blacklist_Get_List)
|
||||
@HttpMethod("POST")
|
||||
public class BlacklistGetAction extends AdminAction {
|
||||
|
||||
@Override
|
||||
public boolean isTransactionAction() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean action(Request request, Response response) {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
InputUserId inputGetFriendList = getRequestBody(request.getNettyRequest(), InputUserId.class);
|
||||
List<FriendData> dataList = messagesStore.getFriendList(inputGetFriendList.getUserId(), null, 0);
|
||||
List<String> list = new ArrayList<>();
|
||||
for (FriendData data : dataList) {
|
||||
if (data.getBlacked() > 0) {
|
||||
list.add(data.getFriendUid());
|
||||
}
|
||||
}
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.ok(new OutputStringList(list));
|
||||
response.setContent(new Gson().toJson(result));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+3
-2
@@ -9,6 +9,7 @@
|
||||
package com.xiaoleilu.loServer.action.admin;
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import cn.wildfirechat.pojos.InputUserId;
|
||||
import cn.wildfirechat.pojos.OutputStringList;
|
||||
import com.google.gson.Gson;
|
||||
import com.xiaoleilu.loServer.RestResult;
|
||||
@@ -36,11 +37,11 @@ public class FriendRelationGetAction extends AdminAction {
|
||||
@Override
|
||||
public boolean action(Request request, Response response) {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
InputGetFriendList inputGetFriendList = getRequestBody(request.getNettyRequest(), InputGetFriendList.class);
|
||||
InputUserId inputGetFriendList = getRequestBody(request.getNettyRequest(), InputUserId.class);
|
||||
List<FriendData> dataList = messagesStore.getFriendList(inputGetFriendList.getUserId(), null, 0);
|
||||
List<String> list = new ArrayList<>();
|
||||
for (FriendData data : dataList) {
|
||||
if (data.getState() == inputGetFriendList.getStatus()) {
|
||||
if (data.getState() == 0) {
|
||||
list.add(data.getFriendUid());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@ public interface APIPath {
|
||||
|
||||
String Friend_Update_Status = "/admin/friend/status";
|
||||
String Friend_Get_List = "/admin/friend/list";
|
||||
String Blacklist_Update_Status = "/admin/blacklist/status";
|
||||
String Blacklist_Get_List = "/admin/blacklist/list";
|
||||
String Friend_Get_Alias = "/admin/friend/get_alias";
|
||||
String Friend_Set_Alias = "/admin/friend/set_alias";
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* This file is part of the Wildfire Chat package.
|
||||
* (c) Heavyrain2012 <[email protected]>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
package cn.wildfirechat.pojos;
|
||||
|
||||
|
||||
public class InputBlacklistRequest {
|
||||
private String userId;
|
||||
private String targetUid;
|
||||
private int status;
|
||||
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getTargetUid() {
|
||||
return targetUid;
|
||||
}
|
||||
|
||||
public void setTargetUid(String targetUid) {
|
||||
this.targetUid = targetUid;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
}
|
||||
@@ -17,18 +17,33 @@ import static cn.wildfirechat.proto.ProtoConstants.SystemSettingType.Group_Max_M
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) throws Exception {
|
||||
//admin使用的是18080端口,超级管理接口,理论上不能对外开放端口,也不能让非内部服务知悉密钥。
|
||||
testAdmin();
|
||||
|
||||
//Robot和Channel都是使用的80端口,第三方可以创建或者为第三方创建,第三方可以使用robot或者channel与IM系统进行对接。
|
||||
testRobot();
|
||||
// testChannel();
|
||||
//testChannel();
|
||||
}
|
||||
|
||||
|
||||
static void testAdmin() throws Exception {
|
||||
//初始化服务API
|
||||
AdminHttpUtils.init("http://localhost:18080", "123456");
|
||||
|
||||
//***********************************************
|
||||
//**** 用户相关的API
|
||||
//***********************************************
|
||||
testUser();
|
||||
testUserRelation();
|
||||
testGroup();
|
||||
testChatroom();
|
||||
testMessage();
|
||||
testGeneralApi();
|
||||
|
||||
System.out.println("Congratulation, all admin test case passed!!!!!!!");
|
||||
}
|
||||
|
||||
//***********************************************
|
||||
//**** 用户相关的API
|
||||
//***********************************************
|
||||
static void testUser() throws Exception {
|
||||
InputOutputUserInfo userInfo = new InputOutputUserInfo();
|
||||
userInfo.setUserId("userId1");
|
||||
userInfo.setName("user1");
|
||||
@@ -175,9 +190,104 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
//***********************************************
|
||||
//**** 群组相关功能
|
||||
//***********************************************
|
||||
//慎用,这个方法可能功能不完全,如果用户不在需要,建议使用block功能屏蔽用户
|
||||
IMResult<Void> voidIMResult = UserAdmin.destroyUser("user11");
|
||||
if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("destroy user success");
|
||||
} else {
|
||||
System.out.println("destroy user failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
//***********************************************
|
||||
//**** 用户关系相关的API
|
||||
//***********************************************
|
||||
static void testUserRelation() throws Exception {
|
||||
|
||||
//先创建2个用户
|
||||
InputOutputUserInfo userInfo = new InputOutputUserInfo();
|
||||
userInfo.setUserId("ff1");
|
||||
userInfo.setName("ff1");
|
||||
userInfo.setMobile("13800000000");
|
||||
userInfo.setDisplayName("ff1");
|
||||
|
||||
IMResult<OutputCreateUser> resultCreateUser = UserAdmin.createUser(userInfo);
|
||||
if (resultCreateUser != null && resultCreateUser.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("Create user " + resultCreateUser.getResult().getName() + " success");
|
||||
} else {
|
||||
System.out.println("Create user failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
userInfo = new InputOutputUserInfo();
|
||||
userInfo.setUserId("ff2");
|
||||
userInfo.setName("ff2");
|
||||
userInfo.setMobile("13800000001");
|
||||
userInfo.setDisplayName("ff2");
|
||||
|
||||
resultCreateUser = UserAdmin.createUser(userInfo);
|
||||
if (resultCreateUser != null && resultCreateUser.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("Create user " + resultCreateUser.getResult().getName() + " success");
|
||||
} else {
|
||||
System.out.println("Create user failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
IMResult<Void> updateFriendStatusResult = RelationAdmin.setUserFriend("ff1", "ff2", true);
|
||||
if (updateFriendStatusResult != null && updateFriendStatusResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("update friend status success");
|
||||
} else {
|
||||
System.out.println("update friend status failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
IMResult<OutputStringList> resultGetFriendList = RelationAdmin.getFriendList("ff1");
|
||||
if (resultGetFriendList != null && resultGetFriendList.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS && resultGetFriendList.getResult().getList().contains("ff2")) {
|
||||
System.out.println("get friend status success");
|
||||
} else {
|
||||
System.out.println("get friend status failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
updateFriendStatusResult = RelationAdmin.setUserBlacklist("ff1", "ff2", true);
|
||||
if (updateFriendStatusResult != null && updateFriendStatusResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("update blacklist status success");
|
||||
} else {
|
||||
System.out.println("update blacklist status failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
resultGetFriendList = RelationAdmin.getUserBlacklist("ff1");
|
||||
if (resultGetFriendList != null && resultGetFriendList.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS && resultGetFriendList.getResult().getList().contains("ff2")) {
|
||||
System.out.println("get blacklist status success");
|
||||
} else {
|
||||
System.out.println("get blacklist status failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
String alias = "hello" + System.currentTimeMillis();
|
||||
IMResult<Void> updateFriendAlias = RelationAdmin.updateFriendAlias("ff1", "ff2", alias);
|
||||
if (updateFriendAlias != null && updateFriendAlias.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("update friend status success");
|
||||
} else {
|
||||
System.out.println("update friend status failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
IMResult<OutputGetAlias> getFriendAlias = RelationAdmin.getFriendAlias("ff1", "ff2");
|
||||
if (getFriendAlias != null && getFriendAlias.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS && getFriendAlias.getResult().getAlias().equals(alias)) {
|
||||
System.out.println("update friend status success");
|
||||
} else {
|
||||
System.out.println("update friend status failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
//***********************************************
|
||||
//**** 群组相关功能
|
||||
//***********************************************
|
||||
static void testGroup() throws Exception {
|
||||
|
||||
IMResult<Void> voidIMResult1 = GroupAdmin.dismissGroup("user1", "groupId1", null, null);
|
||||
|
||||
PojoGroupInfo groupInfo = new PojoGroupInfo();
|
||||
@@ -314,10 +424,12 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//***********************************************
|
||||
//**** 消息相关功能
|
||||
//***********************************************
|
||||
//***********************************************
|
||||
//**** 消息相关功能
|
||||
//***********************************************
|
||||
static void testMessage() throws Exception {
|
||||
Conversation conversation = new Conversation();
|
||||
conversation.setTarget("user2");
|
||||
conversation.setType(ProtoConstants.ConversationType.ConversationType_Private);
|
||||
@@ -334,7 +446,7 @@ public class Main {
|
||||
}
|
||||
|
||||
|
||||
voidIMResult = MessageAdmin.recallMessage("user1", resultSendMessage.getResult().getMessageUid());
|
||||
IMResult<Void> voidIMResult = MessageAdmin.recallMessage("user1", resultSendMessage.getResult().getMessageUid());
|
||||
if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("recall message success");
|
||||
} else {
|
||||
@@ -359,7 +471,12 @@ public class Main {
|
||||
System.out.println("multi message failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
//***********************************************
|
||||
//**** 一些其它的功能,比如创建频道,更新用户设置等
|
||||
//***********************************************
|
||||
static void testGeneralApi() throws Exception {
|
||||
IMResult<SystemSettingPojo> resultGetSystemSetting = GeneralAdmin.getSystemSetting(Group_Max_Member_Count);
|
||||
if (resultGetSystemSetting != null && resultGetSystemSetting.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("success");
|
||||
@@ -394,81 +511,8 @@ public class Main {
|
||||
System.out.println("create channel failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
|
||||
//***********************************************
|
||||
//**** 好友相关功能
|
||||
//***********************************************
|
||||
//先创建2个用户
|
||||
userInfo = new InputOutputUserInfo();
|
||||
userInfo.setUserId("ff1");
|
||||
userInfo.setName("ff1");
|
||||
userInfo.setMobile("13800000000");
|
||||
userInfo.setDisplayName("ff1");
|
||||
|
||||
resultCreateUser = UserAdmin.createUser(userInfo);
|
||||
if (resultCreateUser != null && resultCreateUser.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("Create user " + resultCreateUser.getResult().getName() + " success");
|
||||
} else {
|
||||
System.out.println("Create user failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
userInfo = new InputOutputUserInfo();
|
||||
userInfo.setUserId("ff2");
|
||||
userInfo.setName("ff2");
|
||||
userInfo.setMobile("13800000001");
|
||||
userInfo.setDisplayName("ff2");
|
||||
|
||||
resultCreateUser = UserAdmin.createUser(userInfo);
|
||||
if (resultCreateUser != null && resultCreateUser.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("Create user " + resultCreateUser.getResult().getName() + " success");
|
||||
} else {
|
||||
System.out.println("Create user failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
IMResult<Void> updateFriendStatusResult = FriendAdmin.updateFriendStatus("ff1", "ff2", 1);
|
||||
if (updateFriendStatusResult != null && updateFriendStatusResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("update friend status success");
|
||||
} else {
|
||||
System.out.println("update friend status failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
IMResult<OutputStringList> resultGetFriendList = FriendAdmin.getFriendStatusList("ff1", 1);
|
||||
if (resultGetFriendList != null && resultGetFriendList.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS && resultGetFriendList.getResult().getList().contains("ff2")) {
|
||||
System.out.println("get friend status success");
|
||||
} else {
|
||||
System.out.println("get friend status failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
String alias = "hello" + System.currentTimeMillis();
|
||||
IMResult<Void> updateFriendAlias = FriendAdmin.updateFriendAlias("ff1", "ff2", alias);
|
||||
if (updateFriendAlias != null && updateFriendAlias.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("update friend status success");
|
||||
} else {
|
||||
System.out.println("update friend status failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
IMResult<OutputGetAlias> getFriendAlias = FriendAdmin.getFriendAlias("ff1", "ff2");
|
||||
if (getFriendAlias != null && getFriendAlias.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS && getFriendAlias.getResult().getAlias().equals(alias)) {
|
||||
System.out.println("update friend status success");
|
||||
} else {
|
||||
System.out.println("update friend status failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
|
||||
voidIMResult = UserAdmin.destroyUser("user11");
|
||||
if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("destroy user success");
|
||||
} else {
|
||||
System.out.println("destroy user failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
static void testChatroom() throws Exception {
|
||||
|
||||
String chatroomId = "chatroomId1";
|
||||
String chatroomTitle = "TESTCHATROM";
|
||||
@@ -501,7 +545,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
voidIMResult = ChatroomAdmin.destroyChatroom(chatroomId);
|
||||
IMResult<Void> voidIMResult = ChatroomAdmin.destroyChatroom(chatroomId);
|
||||
if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("destroy chatroom done!");
|
||||
} else {
|
||||
@@ -516,8 +560,6 @@ public class Main {
|
||||
System.out.println("chatroom not destroyed!");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
System.out.println("Congratulation, all admin test case passed!!!!!!!");
|
||||
}
|
||||
|
||||
static void testRobot() throws Exception {
|
||||
|
||||
+23
-8
@@ -5,21 +5,36 @@ import cn.wildfirechat.pojos.*;
|
||||
import cn.wildfirechat.sdk.model.IMResult;
|
||||
import cn.wildfirechat.sdk.utilities.AdminHttpUtils;
|
||||
|
||||
public class FriendAdmin {
|
||||
public static IMResult<Void> updateFriendStatus(String operator, String targetId, int status) throws Exception {
|
||||
public class RelationAdmin {
|
||||
public static IMResult<Void> setUserFriend(String userId, String targetId, boolean isFriend) throws Exception {
|
||||
String path = APIPath.Friend_Update_Status;
|
||||
InputFriendRequest input = new InputFriendRequest();
|
||||
input.setUserId(operator);
|
||||
input.setUserId(userId);
|
||||
input.setFriendUid(targetId);
|
||||
input.setStatus(status);
|
||||
input.setStatus(isFriend ? 0 : 1); //历史遗留问题,在IM数据库中0是好友,1是好友被删除。
|
||||
return AdminHttpUtils.httpJsonPost(path, input, Void.class);
|
||||
}
|
||||
|
||||
public static IMResult<OutputStringList> getFriendStatusList(String operator, int status) throws Exception {
|
||||
public static IMResult<OutputStringList> getFriendList(String userId) throws Exception {
|
||||
String path = APIPath.Friend_Get_List;
|
||||
InputGetFriendList input = new InputGetFriendList();
|
||||
input.setUserId(operator);
|
||||
input.setStatus(status);
|
||||
InputUserId input = new InputUserId();
|
||||
input.setUserId(userId);
|
||||
return AdminHttpUtils.httpJsonPost(path, input, OutputStringList.class);
|
||||
}
|
||||
|
||||
public static IMResult<Void> setUserBlacklist(String userId, String targetId, boolean isBlacklist) throws Exception {
|
||||
String path = APIPath.Blacklist_Update_Status;
|
||||
InputBlacklistRequest input = new InputBlacklistRequest();
|
||||
input.setUserId(userId);
|
||||
input.setTargetUid(targetId);
|
||||
input.setStatus(isBlacklist ? 1 : 0);
|
||||
return AdminHttpUtils.httpJsonPost(path, input, Void.class);
|
||||
}
|
||||
|
||||
public static IMResult<OutputStringList> getUserBlacklist(String userId) throws Exception {
|
||||
String path = APIPath.Blacklist_Get_List;
|
||||
InputUserId input = new InputUserId();
|
||||
input.setUserId(userId);
|
||||
return AdminHttpUtils.httpJsonPost(path, input, OutputStringList.class);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user