添加server api发送好友请求功能
This commit is contained in:
@@ -253,6 +253,30 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
IMResult<Void> result = RelationAdmin.sendFrienRequest("ff1", "ff2", "hello", true);
|
||||
if (result != null && result.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("send friend request success");
|
||||
} else {
|
||||
System.out.println("failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
result = RelationAdmin.sendFrienRequest("ff1", "ff2", "hello2", false);
|
||||
if (result != null && result.getErrorCode() != ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("success");
|
||||
} else {
|
||||
System.out.println("failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
result = RelationAdmin.sendFrienRequest("ff1", "ff2", "hello3", true);
|
||||
if (result != null && result.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("success");
|
||||
} else {
|
||||
System.out.println("send friend request success");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
IMResult<Void> updateFriendStatusResult = RelationAdmin.setUserFriend("ff1", "ff2", true, "{\"from\":1}");
|
||||
if (updateFriendStatusResult != null && updateFriendStatusResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("update friend status success");
|
||||
|
||||
@@ -56,11 +56,13 @@ public class RelationAdmin {
|
||||
return AdminHttpUtils.httpJsonPost(path, input, OutputGetAlias.class);
|
||||
}
|
||||
|
||||
public static IMResult<OutputGetAlias> sendFrienRequest(String operator, String targetId, String reason, String extra) throws Exception {
|
||||
public static IMResult<Void> sendFrienRequest(String userId, String targetId, String reason, boolean force) throws Exception {
|
||||
String path = APIPath.Friend_Send_Request;
|
||||
InputGetAlias input = new InputGetAlias();
|
||||
input.setOperator(operator);
|
||||
input.setTargetId(targetId);
|
||||
return AdminHttpUtils.httpJsonPost(path, input, OutputGetAlias.class);
|
||||
InputAddFriendRequest input = new InputAddFriendRequest();
|
||||
input.setUserId(userId);
|
||||
input.setFriendUid(targetId);
|
||||
input.setReason(reason);
|
||||
input.setForce(force);
|
||||
return AdminHttpUtils.httpJsonPost(path, input, Void.class);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user