Compare commits

..
8 Commits
34 changed files with 633 additions and 27 deletions
+4 -1
View File
@@ -95,6 +95,9 @@ message.disable_stranger_chat false
##当禁止陌生人聊天时,允许聊天的用户id,比如管理员或者文件传输助手等。用户id以英文逗号分割。
message.allow_stranger_chat_list admin,FireRobot,wfc_file_transfer
##当禁止陌生人聊天时,允许聊天的线路。
#message.allow_stranger_line 100,101
##黑名单策略,0 发送失败,返回被拉黑的错误码;1 发送成功但消息被服务器直接丢弃
message.blacklist.strategy 0
@@ -327,7 +330,7 @@ server.mobile_default_silent_when_pc_online true
## 客户端是否支持kickoff事件。当客户端被其他端登录踢出时,如果此开关为false时,客户端协议栈上报secret_mismatch。如果此开关为ture时,客户端协议栈上报kicked_off。
## 客户端被踢时上报kicked_off是在2021.9.15之后才加上的。如果客户端协议栈全部为此日期之后的版本才可以打开此开关。
server.client_support_kickoff_event false
server.client_support_kickoff_event true
#*********************************************************************
# Push server configuration
+1 -1
View File
@@ -5,7 +5,7 @@
<relativePath>../</relativePath>
<artifactId>wildfirechat-parent</artifactId>
<groupId>cn.wildfirechat</groupId>
<version>1.3.1</version>
<version>1.3.2</version>
</parent>
<artifactId>moquette-broker</artifactId>
@@ -0,0 +1,61 @@
/*
* 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.*;
import cn.wildfirechat.proto.WFCMessage;
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.netty.handler.codec.http.FullHttpRequest;
import io.netty.handler.codec.http.HttpResponseStatus;
import io.netty.util.internal.StringUtil;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@Route(APIPath.User_Batch_Get_Infos)
@HttpMethod("POST")
public class GetBatchUserAction extends AdminAction {
@Override
public boolean isTransactionAction() {
return true;
}
@Override
public boolean action(Request request, Response response) {
if (request.getNettyRequest() instanceof FullHttpRequest) {
InputStringList inputUserId = getRequestBody(request.getNettyRequest(), InputStringList.class);
if (inputUserId != null && inputUserId.getList() != null && !inputUserId.getList().isEmpty()) {
OutputUserInfoList res = new OutputUserInfoList();
res.userInfos = new ArrayList<>();
for (String userId : inputUserId.getList()) {
WFCMessage.User user = messagesStore.getUserInfo(userId);
if(user == null || StringUtil.isNullOrEmpty(user.getName())) {
continue;
}
InputOutputUserInfo inputOutputUserInfo = InputOutputUserInfo.fromPbUser(user);
res.userInfos.add(inputOutputUserInfo);
}
RestResult result = RestResult.ok(res);
setResponseContent(result, response);
} else {
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
}
}
return true;
}
}
@@ -152,6 +152,7 @@ public final class BrokerConstants {
public static final String MESSAGE_Disable_Stranger_Chat = "message.disable_stranger_chat";
public static final String MESSAGE_Allow_Stranger_Chat_List = "message.allow_stranger_chat_list";
public static final String MESSAGE_Allow_Stranger_Line = "message.allow_stranger_line";
public static final String MESSAGE_Blacklist_Strategy = "message.blacklist.strategy";
public static final String MESSAGE_Blacklist_Allow_Send = "message.blacklist.allow_send_to_black";
@@ -152,7 +152,7 @@ public class SendMessageHandler extends IMHandler<WFCMessage.Message> {
if (message.getConversation().getType() == ProtoConstants.ConversationType.ConversationType_Private) {
if(!m_messagesStore.getBlackListExceptionTypes().contains(message.getContent().getType())) {
errorCode = m_messagesStore.isAllowUserMessage(message.getConversation().getTarget(), fromUser);
errorCode = m_messagesStore.isAllowUserMessage(message.getConversation().getTarget(), fromUser, message.getConversation().getLine());
if (errorCode != ErrorCode.ERROR_CODE_SUCCESS) {
if (errorCode == ErrorCode.ERROR_CODE_IN_BLACK_LIST && mBlacklistStrategy != ProtoConstants.BlacklistStrategy.Message_Reject) {
ignoreMsg = true;
@@ -165,6 +165,7 @@ public class MemoryMessagesStore implements IMessagesStore {
private boolean mMobileDefaultSilentWhenPCOnline = true;
private boolean mDisableStrangerChat = false;
private Set<String> mAllowStrangerChatSet = new HashSet<>();
private Set<Integer> mAllowStrangerLineSet = new HashSet<>();
private boolean mDisableStrangerAddGroup = false;
private boolean mIDUseUUID = true;
@@ -265,6 +266,18 @@ public class MemoryMessagesStore implements IMessagesStore {
e.printStackTrace();
}
try {
String allowStrangerList = m_Server.getConfig().getProperty(BrokerConstants.MESSAGE_Allow_Stranger_Line);
if(!StringUtil.isNullOrEmptyAfterTrim(allowStrangerList)) {
allowStrangerList = allowStrangerList.replace(",", ",");
for (String s : allowStrangerList.split(",")) {
mAllowStrangerLineSet.add(Integer.parseInt(s.trim()));
}
}
} catch (Exception e) {
e.printStackTrace();
}
try {
String forcePushTypes = m_Server.getConfig().getProperty(BrokerConstants.MESSAGE_Force_Push_Types);
if(!StringUtil.isNullOrEmptyAfterTrim(forcePushTypes)) {
@@ -733,7 +746,7 @@ public class MemoryMessagesStore implements IMessagesStore {
}
pullType = ProtoConstants.PullType.Pull_Normal;
} else if (type == ProtoConstants.ConversationType.ConversationType_ChatRoom) {
boolean isDirect = !StringUtil.isNullOrEmpty(message.getToUser());
boolean isDirect = !StringUtil.isNullOrEmpty(message.getToUser()) || !message.getToList().isEmpty();
Collection<UserClientEntry> entries = getChatroomMembers(message.getConversation().getTarget());
for (UserClientEntry entry : entries) {
if (isDirect) {
@@ -741,6 +754,9 @@ public class MemoryMessagesStore implements IMessagesStore {
notifyReceivers.add(message.getToUser());
break;
}
if (message.getToList().contains(entry.userId)) {
notifyReceivers.add(entry.userId);
}
} else {
notifyReceivers.add(entry.userId);
}
@@ -3193,7 +3209,7 @@ public class MemoryMessagesStore implements IMessagesStore {
}
@Override
public ErrorCode isAllowUserMessage(String targetUser, String fromUser) {
public ErrorCode isAllowUserMessage(String targetUser, String fromUser, int line) {
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
MultiMap<String, FriendData> friendsMap = hzInstance.getMultiMap(USER_FRIENDS);
@@ -3220,7 +3236,7 @@ public class MemoryMessagesStore implements IMessagesStore {
if (mDisableStrangerChat) {
//在禁止私聊时,是否是允许私聊的用户id
if(mAllowStrangerChatSet.contains(targetUser) || mAllowStrangerChatSet.contains(fromUser)) {
if(mAllowStrangerChatSet.contains(targetUser) || mAllowStrangerChatSet.contains(fromUser) || mAllowStrangerLineSet.contains(line)) {
return ErrorCode.ERROR_CODE_SUCCESS;
}
@@ -140,7 +140,7 @@ public class Server {
Runtime.getRuntime().addShutdownHook(new Thread(instance::stopServer));
Runtime.getRuntime().addShutdownHook(new Thread(httpServer::shutdown));
System.out.println("Wildfire IM server start success...");
System.out.println("Wildfire IM server start success.");
}
/**
@@ -185,7 +185,7 @@ public interface IMessagesStore {
ErrorCode blackUserRequest(String fromUser, String targetUserId, int status, long[] head);
FriendData getFriendData(String fromUser, String targetUserId);
ErrorCode SyncFriendRequestUnread(String userId, long unreadDt, long[] head);
ErrorCode isAllowUserMessage(String fromUser, String userId);
ErrorCode isAllowUserMessage(String fromUser, String userId, int line);
ErrorCode isBlacked(String fromUser, String userId);
ErrorCode setFriendAliasRequest(String fromUser, String targetUserId, String alias, long[] head);
ErrorCode setFriendExtraRequest(String fromUser, String targetUserId, String extra, long[] head);
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>wildfirechat-parent</artifactId>
<groupId>cn.wildfirechat</groupId>
<version>1.3.1</version>
<version>1.3.2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -157,5 +157,17 @@ public interface APIPath {
String Robot_Group_Transfer = "/robot/group/transfer";
String Robot_Group_Set_Manager = "/robot/group/manager/set";
String Robot_Moments_Post_Feed = "/robot/moments/feed/post";
String Robot_Moments_Pull_Feeds = "/robot/moments/feed/pull";
String Robot_Moments_Update_Feed = "/robot/moments/feed/update";
String Robot_Moments_Post_Comment = "/robot/moments/comment/post";
String Robot_Moments_Pull_Comment = "/robot/moments/comment/pull";
String Robot_Moments_Fetch_Feed = "/robot/moments/feed/pull_one";
String Robot_Moments_Fetch_Profiles = "/robot/moments/profiles/pull";
String Robot_Moments_Recall_Comment = "/robot/moments/comment/recall";
String Robot_Moments_Recall_Feed = "/robot/moments/feed/recall";
String Robot_Moments_Update_Profiles_List_Value = "/robot/moments/profiles/list/push";
String Robot_Moments_Update_Profiles_Value = "/robot/moments/profiles/value/push";
String Robot_Conference_Request = "/robot/conference/request";
}
@@ -0,0 +1,22 @@
package cn.wildfirechat.pojos;
import java.util.List;
public class InputStringList {
private List<String> list;
public InputStringList() {
}
public InputStringList(List<String> list) {
this.list = list;
}
public List<String> getList() {
return list;
}
public void setList(List<String> list) {
this.list = list;
}
}
@@ -0,0 +1,38 @@
package cn.wildfirechat.pojos.moments;
import java.util.List;
public class CommentMsgPojo {
//commentId;
public long commentId;
//sender;
public String sender;
//timestamp
public long serverTime;
//feedId
public long feedId;
//type
public int type;
//content
public String text;
//to replyTo
public String replyTo;
//extra
public String extra;
public int ftype;
public String fcontent;
public String fsender;
public List<MediaEntry> fmedias;
}
@@ -0,0 +1,30 @@
package cn.wildfirechat.pojos.moments;
public class CommentPojo {
//commentId;
public long commentId;
//replyId;
public long replyId;
//sender;
public String sender;
//timestamp
public long timestamp;
//feedId
public long feedId;
//type
public int type;
//content
public String text;
//to replyTo
public String replyTo;
//extra
public String extra;
}
@@ -0,0 +1,38 @@
package cn.wildfirechat.pojos.moments;
import java.util.List;
public class FeedPojo {
//feedid
public long feedId;
//sender
public String sender;
//timestamp
public long timestamp;
//type
public int type;
//content
public String text;
//media urls
public List<MediaEntry> medias;
//to users
public List<String> to;
//excloud users
public List<String> ex;
//mentioned users
public List<String> mu;
//extra
public String extra;
public List<CommentPojo> comments;
}
@@ -0,0 +1,7 @@
package cn.wildfirechat.pojos.moments;
import java.util.List;
public class FeedsPojo {
public List<FeedPojo> feeds;
}
@@ -0,0 +1,9 @@
package cn.wildfirechat.pojos.moments;
public class IdPojo {
//feedid
public long id;
//feedid
public long id2;
}
@@ -0,0 +1,8 @@
package cn.wildfirechat.pojos.moments;
public class MediaEntry {
public String m;
public String t;
public int w;
public int h;
}
@@ -0,0 +1,14 @@
package cn.wildfirechat.pojos.moments;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
public class MomentProfilePojo {
public String bgUrl;
public List<String> blackList;
public List<String> blockList;
//stranger visiable count
public int svc;
public int visiableScope;
}
@@ -0,0 +1,11 @@
package cn.wildfirechat.pojos.moments;
public class PostFeedResult {
public long id;
public long timestamp;
public PostFeedResult(long id, long timestamp) {
this.id = id;
this.timestamp = timestamp;
}
}
@@ -0,0 +1,11 @@
package cn.wildfirechat.pojos.moments;
import java.util.List;
public class PullCommentsRequestPojo {
public static class IdPair {
public long fid;
public long cid;
}
public List<IdPair> ids;
}
@@ -0,0 +1,8 @@
package cn.wildfirechat.pojos.moments;
public class PullFeedRequestPojo {
//feedid
public long feedId;
public int count;
public String user;
}
@@ -0,0 +1,5 @@
package cn.wildfirechat.pojos.moments;
public class PullOneFeedRequestPojo {
public long feedId;
}
@@ -0,0 +1,9 @@
package cn.wildfirechat.pojos.moments;
public class PullProfileRequestPojo {
//userId
public String u;
//update date
public long d;
}
@@ -0,0 +1,14 @@
package cn.wildfirechat.pojos.moments;
import java.util.List;
public class PushProfileListRequestPojo {
//block or black
public boolean b;
//add user list
public List<String> al;
//remove user list
public List<String> rl;
}
@@ -0,0 +1,16 @@
package cn.wildfirechat.pojos.moments;
public class PushProfileValueRequestPojo {
/*
WFMUpdateUserProfileType_BackgroudUrl,
WFMUpdateUserProfileType_StrangerVisiableCount,
WFMUpdateUserProfileType_VisiableScope
*/
public int t;
//string value depends on t
public String v;
//int value depends on t
public int i;
}
@@ -347,6 +347,25 @@ public class ProtoConstants {
int Forbidden_Mute_Group_Member = 0x800;
}
public interface MomentsContentType {
int Moments_Content_Text_Type = 0;
int Moments_Content_Image_Type = 1;
int Moments_Content_Video_Type = 2;
int Moments_Content_Link_Type = 3;
}
public interface MomentsCommentType {
int Moments_Comment_Text_Type = 0;
int Moments_Comment_Thumbup_Type = 1;
}
public interface MomentsVisibleScope {
int Moments_VisibleScope_NoLimit = 0;
int Moments_VisibleScope_3Days = 1;
int Moments_VisibleScope_1Month = 2;
int Moments_VisibleScope_6Months = 3;
};
public static final int MESSAGE_CONTENT_TYPE_CREATE_GROUP = 104;
public static final int MESSAGE_CONTENT_TYPE_ADD_GROUP_MEMBER = 105;
public static final int MESSAGE_CONTENT_TYPE_KICKOF_GROUP_MEMBER = 106;
+1 -1
View File
@@ -6,7 +6,7 @@
<!--<relativePath>../pom.xml</relativePath>-->
<artifactId>wildfirechat-parent</artifactId>
<groupId>cn.wildfirechat</groupId>
<version>1.3.1</version>
<version>1.3.2</version>
</parent>
<artifactId>distribution</artifactId>
@@ -93,6 +93,9 @@ message.disable_stranger_chat false
##当禁止陌生人聊天时,允许聊天的用户id,比如管理员或者文件传输助手等。用户id以英文逗号分割。
message.allow_stranger_chat_list admin,FireRobot,wfc_file_transfer
##当禁止陌生人聊天时,允许聊天的线路。
#message.allow_stranger_line 100,101
##黑名单策略,0 发送失败,返回被拉黑的错误码;1 发送成功但消息被服务器直接丢弃
message.blacklist.strategy 0
@@ -322,7 +325,7 @@ server.mobile_default_silent_when_pc_online true
## 客户端是否支持kickoff事件。当客户端被其他端登录踢出时,如果此开关为false时,客户端协议栈上报secret_mismatch。如果此开关为ture时,客户端协议栈上报kicked_off。
## 客户端被踢时上报kicked_off是在2021.9.15之后才加上的。如果客户端协议栈全部为此日期之后的版本才可以打开此开关。
server.client_support_kickoff_event false
server.client_support_kickoff_event true
#*********************************************************************
# Push server configuration
+1 -1
View File
@@ -12,7 +12,7 @@
<artifactId>wildfirechat-parent</artifactId>
<packaging>pom</packaging>
<version>1.3.1</version>
<version>1.3.2</version>
<name>Wildfire Chat</name>
<description>Wildfire Chat Server</description>
<inceptionYear>2019</inceptionYear>
+7
View File
@@ -12,6 +12,13 @@
# 更新记录
--------------
Release note 1.3.2:
1. 机器人Server SDK添加朋友圈相关接口。
2. Server API添加批量获取用户接口。
3. 解决聊天室定向消息无效的问题。
4. 添加配置,可以在禁止私聊时添加例外聊天线路。
--------------
Release note 1.3.1:
1. 透传消息去掉消息ID,减少消息传输大小。
+1 -1
View File
@@ -3,7 +3,7 @@
<parent>
<artifactId>wildfirechat-parent</artifactId>
<groupId>cn.wildfirechat</groupId>
<version>1.3.1</version>
<version>1.3.2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -1,6 +1,10 @@
package cn.wildfirechat.sdk;
import cn.wildfirechat.common.ErrorCode;
import cn.wildfirechat.pojos.moments.CommentPojo;
import cn.wildfirechat.pojos.moments.FeedPojo;
import cn.wildfirechat.pojos.moments.FeedsPojo;
import cn.wildfirechat.pojos.moments.MomentProfilePojo;
import cn.wildfirechat.proto.WFCMessage;
import cn.wildfirechat.sdk.messagecontent.*;
import cn.wildfirechat.pojos.*;
@@ -19,6 +23,7 @@ import static cn.wildfirechat.proto.ProtoConstants.SystemSettingType.Group_Max_M
public class Main {
private static boolean commercialServer = false;
private static boolean advanceVoip = false;
private static boolean robotMomentsEnabled = false;
//管理端口是8080
private static String AdminUrl = "http://localhost:18080";
private static String AdminSecret = "123456";
@@ -188,6 +193,14 @@ public class Main {
System.exit(-1);
}
IMResult<OutputUserInfoList> batchGetUsers = UserAdmin.getBatchUsers(Arrays.asList("userId1", "admin", "FireRobot", "TestUser"));
if (batchGetUsers.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
System.out.println("get batch user success");
} else {
System.out.println("get batch user failure");
System.exit(-1);
}
InputOutputUserInfo updateUserInfo = new InputOutputUserInfo();
updateUserInfo.setUserId(System.currentTimeMillis()+"");
updateUserInfo.setDisplayName("updatedUserName");
@@ -1575,8 +1588,6 @@ public class Main {
System.out.println(config);
}
//仅专业版支持
if (commercialServer) {
//开启群成员禁言
@@ -1643,6 +1654,88 @@ public class Main {
System.exit(-1);
}
//仅专业版支持,且服务器端支持朋友圈
if (robotMomentsEnabled) {
IMResult<FeedPojo> postResult = robotService.postMomentsFeed(ProtoConstants.MomentsContentType.Moments_Content_Text_Type, "hello from robot", null, null, null, null, "hello_extra");
if (postResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
System.out.println("post moments feed success");
} else {
System.out.println("post moments feed failure:" + postResult.getErrorCode().code);
System.exit(-1);
}
IMResult<FeedsPojo> pullResult = robotService.getMomentsFeeds(0, 10, null);
if (pullResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
System.out.println("pull moments feeds success");
} else {
System.out.println("pull moments feeds failure:" + pullResult.getErrorCode().code);
System.exit(-1);
}
IMResult<FeedPojo> feedResult = robotService.getMomentsFeed(postResult.getResult().feedId);
if (feedResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
System.out.println("pull moments one feed success");
} else {
System.out.println("pull moments one feed failure:" + feedResult.getErrorCode().code);
System.exit(-1);
}
IMResult<CommentPojo> commentThumbUpResult = robotService.postMomentsComment(postResult.result.feedId, 0, ProtoConstants.MomentsCommentType.Moments_Comment_Thumbup_Type, null, null, null);
if (commentThumbUpResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
System.out.println("post moments thumb up success");
} else {
System.out.println("post moments thumb up failure:" + commentThumbUpResult.getErrorCode().code);
System.exit(-1);
}
IMResult<CommentPojo> commentTextResult = robotService.postMomentsComment(postResult.result.feedId, 0, ProtoConstants.MomentsCommentType.Moments_Comment_Text_Type, "comment hello", null, null);
if (commentTextResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
System.out.println("post moments comment text success");
} else {
System.out.println("post moments comment text failure:" + commentTextResult.getErrorCode().code);
System.exit(-1);
}
IMResult<Void> updateResult = robotService.updateMomentsFeed(postResult.getResult().feedId, ProtoConstants.MomentsContentType.Moments_Content_Text_Type, "hello from robot2", null, null, null, null, "hello_extra2");
if (updateResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
System.out.println("update moments feed success");
} else {
System.out.println("update moments feed failure:" + updateResult.getErrorCode().code);
System.exit(-1);
}
IMResult<Void> deleteCommentThumbUpResult = robotService.deleteMomentsComment(postResult.result.feedId, commentThumbUpResult.result.commentId);
if (deleteCommentThumbUpResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
System.out.println("delete moments thumb up success");
} else {
System.out.println("delete moments thumb up failure:" + deleteCommentThumbUpResult.getErrorCode().code);
System.exit(-1);
}
IMResult<Void> deleteCommentTextResult = robotService.deleteMomentsComment(postResult.result.feedId, commentTextResult.result.commentId);
if (deleteCommentTextResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
System.out.println("delete moments comment text success");
} else {
System.out.println("delete moments comment text failure:" + deleteCommentTextResult.getErrorCode().code);
System.exit(-1);
}
IMResult<Void> deleteFeedResult = robotService.deleteMomentsFeed(postResult.result.feedId);
if (deleteFeedResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
System.out.println("delete moments feed success");
} else {
System.out.println("delete moments feed failure:" + deleteFeedResult.getErrorCode().code);
System.exit(-1);
}
IMResult<MomentProfilePojo> profileResult = robotService.getUserMomentsProfile(robotId);
if (profileResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
System.out.println("get user moments profile success");
} else {
System.out.println("get user moments profile failure:" + profileResult.getErrorCode().code);
System.exit(-1);
}
}
}
//***测试频道API功能,仅专业版支持***
@@ -1,7 +1,9 @@
package cn.wildfirechat.sdk;
import cn.wildfirechat.common.APIPath;
import cn.wildfirechat.common.ErrorCode;
import cn.wildfirechat.pojos.*;
import cn.wildfirechat.pojos.moments.*;
import cn.wildfirechat.sdk.model.IMResult;
import cn.wildfirechat.sdk.utilities.RobotHttpUtils;
import org.apache.commons.codec.digest.DigestUtils;
@@ -96,7 +98,7 @@ public class RobotService {
return robotHttpUtils.httpJsonPost(path, pojo, Void.class);
}
public IMResult<OutputCreateGroupResult> createGroup(PojoGroupInfo group_info, List<PojoGroupMember> members, String member_extra, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
public IMResult<OutputCreateGroupResult> createGroup(PojoGroupInfo group_info, List<PojoGroupMember> members, String member_extra, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
String path = APIPath.Robot_Create_Group;
PojoGroup pojoGroup = new PojoGroup();
pojoGroup.setGroup_info(group_info);
@@ -118,7 +120,7 @@ public class RobotService {
return robotHttpUtils.httpJsonPost(path, input, PojoGroupInfo.class);
}
public IMResult<Void> dismissGroup(String groupId, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
public IMResult<Void> dismissGroup(String groupId, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
String path = APIPath.Robot_Group_Dismiss;
InputDismissGroup dismissGroup = new InputDismissGroup();
dismissGroup.setGroup_id(groupId);
@@ -127,7 +129,7 @@ public class RobotService {
return robotHttpUtils.httpJsonPost(path, dismissGroup, Void.class);
}
public IMResult<Void> transferGroup(String groupId, String newOwner, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
public IMResult<Void> transferGroup(String groupId, String newOwner, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
String path = APIPath.Robot_Group_Transfer;
InputTransferGroup transferGroup = new InputTransferGroup();
transferGroup.setGroup_id(groupId);
@@ -137,7 +139,7 @@ public class RobotService {
return robotHttpUtils.httpJsonPost(path, transferGroup, Void.class);
}
public IMResult<Void> modifyGroupInfo(String groupId, /*ModifyGroupInfoType*/int type, String value, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
public IMResult<Void> modifyGroupInfo(String groupId, /*ModifyGroupInfoType*/int type, String value, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
String path = APIPath.Robot_Group_Modify_Info;
InputModifyGroupInfo modifyGroupInfo = new InputModifyGroupInfo();
modifyGroupInfo.setGroup_id(groupId);
@@ -164,7 +166,7 @@ public class RobotService {
return robotHttpUtils.httpJsonPost(path, input, PojoGroupMember.class);
}
public IMResult<Void> addGroupMembers(String groupId, List<PojoGroupMember> groupMembers, String member_extra, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
public IMResult<Void> addGroupMembers(String groupId, List<PojoGroupMember> groupMembers, String member_extra, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
String path = APIPath.Robot_Group_Member_Add;
InputAddGroupMember addGroupMember = new InputAddGroupMember();
addGroupMember.setGroup_id(groupId);
@@ -175,7 +177,7 @@ public class RobotService {
return robotHttpUtils.httpJsonPost(path, addGroupMember, Void.class);
}
public IMResult<Void> setGroupManager(String groupId, List<String> groupMemberIds, boolean isManager, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
public IMResult<Void> setGroupManager(String groupId, List<String> groupMemberIds, boolean isManager, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
String path = APIPath.Robot_Group_Set_Manager;
InputSetGroupManager addGroupMember = new InputSetGroupManager();
addGroupMember.setGroup_id(groupId);
@@ -186,7 +188,7 @@ public class RobotService {
return robotHttpUtils.httpJsonPost(path, addGroupMember, Void.class);
}
public IMResult<Void> muteGroupMember(String groupId, List<String> groupMemberIds, boolean isMute, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
public IMResult<Void> muteGroupMember(String groupId, List<String> groupMemberIds, boolean isMute, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
String path = APIPath.Robot_Group_Mute_Member;
InputMuteGroupMember addGroupMember = new InputMuteGroupMember();
addGroupMember.setGroup_id(groupId);
@@ -197,7 +199,7 @@ public class RobotService {
return robotHttpUtils.httpJsonPost(path, addGroupMember, Void.class);
}
public IMResult<Void> allowGroupMember(String groupId, List<String> groupMemberIds, boolean isAllow, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
public IMResult<Void> allowGroupMember(String groupId, List<String> groupMemberIds, boolean isAllow, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
String path = APIPath.Robot_Group_Allow_Member;
InputMuteGroupMember addGroupMember = new InputMuteGroupMember();
addGroupMember.setGroup_id(groupId);
@@ -208,7 +210,7 @@ public class RobotService {
return robotHttpUtils.httpJsonPost(path, addGroupMember, Void.class);
}
public IMResult<Void> kickoffGroupMembers(String groupId, List<String> groupMemberIds, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
public IMResult<Void> kickoffGroupMembers(String groupId, List<String> groupMemberIds, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
String path = APIPath.Robot_Group_Member_Kickoff;
InputKickoffGroupMember kickoffGroupMember = new InputKickoffGroupMember();
kickoffGroupMember.setGroup_id(groupId);
@@ -218,7 +220,7 @@ public class RobotService {
return robotHttpUtils.httpJsonPost(path, kickoffGroupMember, Void.class);
}
public IMResult<Void> quitGroup(String groupId, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
public IMResult<Void> quitGroup(String groupId, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
String path = APIPath.Robot_Group_Member_Quit;
InputQuitGroup quitGroup = new InputQuitGroup();
quitGroup.setGroup_id(groupId);
@@ -227,7 +229,7 @@ public class RobotService {
return robotHttpUtils.httpJsonPost(path, quitGroup, Void.class);
}
public IMResult<Void> setGroupMemberAlias(String groupId, String memberId, String alias, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
public IMResult<Void> setGroupMemberAlias(String groupId, String memberId, String alias, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
String path = APIPath.Robot_Group_Set_Member_Alias;
InputSetGroupMemberAlias input = new InputSetGroupMemberAlias();
input.setGroup_id(groupId);
@@ -238,7 +240,7 @@ public class RobotService {
return robotHttpUtils.httpJsonPost(path, input, Void.class);
}
public IMResult<Void> setGroupMemberExtra(String groupId, String memberId, String extra, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
public IMResult<Void> setGroupMemberExtra(String groupId, String memberId, String extra, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
String path = APIPath.Robot_Group_Set_Member_Extra;
InputSetGroupMemberExtra input = new InputSetGroupMemberExtra();
input.setGroup_id(groupId);
@@ -276,4 +278,144 @@ public class RobotService {
return robotHttpUtils.httpJsonPost(path, input, String.class);
}
public IMResult<FeedPojo> postMomentsFeed(int/*MomentsContentType*/ type, String text, List<MediaEntry> medias, List<String> toUsers, List<String> excludeUsers, List<String> mentionedUsers, String extra) throws Exception {
String path = APIPath.Robot_Moments_Post_Feed;
FeedPojo feedPojo = new FeedPojo();
feedPojo.type = type;
feedPojo.text = text;
feedPojo.medias = medias;
feedPojo.to = toUsers;
feedPojo.ex = excludeUsers;
feedPojo.mu = mentionedUsers;
feedPojo.extra = extra;
IMResult<PostFeedResult> imResult = robotHttpUtils.httpJsonPost(path, feedPojo, PostFeedResult.class);
IMResult<FeedPojo> feedResult = new IMResult<>();
if(imResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
feedPojo.feedId = imResult.result.id;
feedPojo.timestamp = imResult.result.timestamp;
feedResult.setCode(ErrorCode.ERROR_CODE_SUCCESS.getCode());
feedResult.setResult(feedPojo);
} else {
feedResult.setCode(imResult.getCode());
feedResult.setMsg(imResult.getMsg());
}
return feedResult;
}
public IMResult<Void> updateMomentsFeed(long feedId, int/*MomentsContentType*/ type, String text, List<MediaEntry> medias, List<String> toUsers, List<String> excludeUsers, List<String> mentionedUsers, String extra) throws Exception {
String path = APIPath.Robot_Moments_Update_Feed;
FeedPojo feedPojo = new FeedPojo();
feedPojo.feedId = feedId;
feedPojo.type = type;
feedPojo.text = text;
feedPojo.medias = medias;
feedPojo.to = toUsers;
feedPojo.ex = excludeUsers;
feedPojo.mu = mentionedUsers;
feedPojo.extra = extra;
return robotHttpUtils.httpJsonPost(path, feedPojo, Void.class);
}
public IMResult<FeedsPojo> getMomentsFeeds(long feedId, int count, String user) throws Exception {
String path = APIPath.Robot_Moments_Pull_Feeds;
PullFeedRequestPojo requestPojo = new PullFeedRequestPojo();
requestPojo.feedId = feedId;
requestPojo.count = count;
requestPojo.user = user;
return robotHttpUtils.httpJsonPost(path, requestPojo, FeedsPojo.class);
}
public IMResult<FeedPojo> getMomentsFeed(long feedId) throws Exception {
String path = APIPath.Robot_Moments_Fetch_Feed;
PullOneFeedRequestPojo requestPojo = new PullOneFeedRequestPojo();
requestPojo.feedId = feedId;
return robotHttpUtils.httpJsonPost(path, requestPojo, FeedPojo.class);
}
public IMResult<Void> deleteMomentsFeed(long feedId) throws Exception {
String path = APIPath.Robot_Moments_Recall_Feed;
IdPojo requestPojo = new IdPojo();
requestPojo.id = feedId;
return robotHttpUtils.httpJsonPost(path, requestPojo, Void.class);
}
public IMResult<CommentPojo> postMomentsComment(long feedId, long replyId, int/*MomentsCommentType*/ type, String text, String replyTo, String extra) throws Exception {
String path = APIPath.Robot_Moments_Post_Comment;
CommentPojo commentPojo = new CommentPojo();
commentPojo.type = type;
commentPojo.text = text;
commentPojo.replyId = replyId;
commentPojo.feedId = feedId;
commentPojo.replyTo = replyTo;
commentPojo.extra = extra;
IMResult<PostFeedResult> imResult = robotHttpUtils.httpJsonPost(path, commentPojo, PostFeedResult.class);
IMResult<CommentPojo> feedResult = new IMResult<>();
if(imResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
commentPojo.commentId = imResult.result.id;
commentPojo.timestamp = imResult.result.timestamp;
feedResult.setCode(ErrorCode.ERROR_CODE_SUCCESS.getCode());
feedResult.setResult(commentPojo);
} else {
feedResult.setCode(imResult.getCode());
feedResult.setMsg(imResult.getMsg());
}
return feedResult;
}
public IMResult<Void> deleteMomentsComment(long feedId, long commentId) throws Exception {
String path = APIPath.Robot_Moments_Recall_Comment;
IdPojo requestPojo = new IdPojo();
requestPojo.id = commentId;
requestPojo.id2 = feedId;
return robotHttpUtils.httpJsonPost(path, requestPojo, Void.class);
}
public IMResult<MomentProfilePojo> getUserMomentsProfile(String userId) throws Exception {
String path = APIPath.Robot_Moments_Fetch_Profiles;
PullProfileRequestPojo requestPojo = new PullProfileRequestPojo();
requestPojo.u = userId;
return robotHttpUtils.httpJsonPost(path, requestPojo, MomentProfilePojo.class);
}
public IMResult<Void> updateMomentsBackgroundUrl(String url) throws Exception {
String path = APIPath.Robot_Moments_Update_Profiles_Value;
PushProfileValueRequestPojo requestPojo = new PushProfileValueRequestPojo();
requestPojo.t = 0;
requestPojo.v = url;
return robotHttpUtils.httpJsonPost(path, requestPojo, Void.class);
}
public IMResult<Void> updateMomentsStrangerVisibleCount(int count) throws Exception {
String path = APIPath.Robot_Moments_Update_Profiles_Value;
PushProfileValueRequestPojo requestPojo = new PushProfileValueRequestPojo();
requestPojo.t = 1;
requestPojo.i = count;
return robotHttpUtils.httpJsonPost(path, requestPojo, Void.class);
}
public IMResult<Void> updateMomentsVisibleScope(int/*MomentsVisibleScope*/ scope) throws Exception {
String path = APIPath.Robot_Moments_Update_Profiles_Value;
PushProfileValueRequestPojo requestPojo = new PushProfileValueRequestPojo();
requestPojo.t = 2;
requestPojo.i = scope;
return robotHttpUtils.httpJsonPost(path, requestPojo, Void.class);
}
public IMResult<Void> updateMomentsBlackList(List<String> addList, List<String> removeList) throws Exception {
String path = APIPath.Robot_Moments_Update_Profiles_List_Value;
PushProfileListRequestPojo requestPojo = new PushProfileListRequestPojo();
requestPojo.b = false;
requestPojo.al = addList;
requestPojo.rl = removeList;
return robotHttpUtils.httpJsonPost(path, requestPojo, Void.class);
}
public IMResult<Void> updateMomentsBlockList(List<String> addList, List<String> removeList) throws Exception {
String path = APIPath.Robot_Moments_Update_Profiles_List_Value;
PushProfileListRequestPojo requestPojo = new PushProfileListRequestPojo();
requestPojo.b = true;
requestPojo.al = addList;
requestPojo.rl = removeList;
return robotHttpUtils.httpJsonPost(path, requestPojo, Void.class);
}
}
@@ -5,6 +5,8 @@ import cn.wildfirechat.pojos.*;
import cn.wildfirechat.sdk.model.IMResult;
import cn.wildfirechat.sdk.utilities.AdminHttpUtils;
import java.util.List;
public class UserAdmin {
public static IMResult<InputOutputUserInfo> getUserByName(String name) throws Exception {
String path = APIPath.User_Get_Info;
@@ -37,6 +39,13 @@ public class UserAdmin {
return AdminHttpUtils.httpJsonPost(path, input, OutputGetUserList.class);
}
public static IMResult<OutputUserInfoList> getBatchUsers(List<String> userIds) throws Exception {
String path = APIPath.User_Batch_Get_Infos;
InputStringList input = new InputStringList();
input.setList(userIds);
return AdminHttpUtils.httpJsonPost(path, input, OutputUserInfoList.class);
}
public static IMResult<OutputCreateUser> createUser(InputOutputUserInfo user) throws Exception {
String path = APIPath.Create_User;
return AdminHttpUtils.httpJsonPost(path, user, OutputCreateUser.class);