From 07b1de4ae34c70df2f87db0e346f0940b43a8070 Mon Sep 17 00:00:00 2001 From: heavyrian2012 Date: Mon, 20 Apr 2026 08:19:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wildfirechat/sdk/ChannelServiceApi.java | 95 +++++ .../cn/wildfirechat/sdk/RobotService.java | 346 +++++++++++++++++- 2 files changed, 439 insertions(+), 2 deletions(-) diff --git a/sdk/src/main/java/cn/wildfirechat/sdk/ChannelServiceApi.java b/sdk/src/main/java/cn/wildfirechat/sdk/ChannelServiceApi.java index 565e954d..9ca0220d 100644 --- a/sdk/src/main/java/cn/wildfirechat/sdk/ChannelServiceApi.java +++ b/sdk/src/main/java/cn/wildfirechat/sdk/ChannelServiceApi.java @@ -41,24 +41,49 @@ public class ChannelServiceApi implements Closeable { channelHttpUtils = new ChannelHttpUtils(imurl, channelId, secret); } + /** + * 根据用户ID获取用户信息 + * @param userId 用户ID + * @return 用户信息 + * @throws Exception 请求失败时抛出异常 + */ public IMResult getUserInfo(String userId) throws Exception { String path = APIPath.Channel_User_Info; InputGetUserInfo getUserInfo = new InputGetUserInfo(userId, null, null); return channelHttpUtils.httpJsonPost(path, getUserInfo, InputOutputUserInfo.class); } + /** + * 根据用户名获取用户信息 + * @param userName 用户名 + * @return 用户信息 + * @throws Exception 请求失败时抛出异常 + */ public IMResult getUserInfoByName(String userName) throws Exception { String path = APIPath.Channel_User_Info; InputGetUserInfo getUserInfo = new InputGetUserInfo(null, userName, null); return channelHttpUtils.httpJsonPost(path, getUserInfo, InputOutputUserInfo.class); } + /** + * 根据手机号获取用户信息 + * @param mobile 手机号 + * @return 用户信息 + * @throws Exception 请求失败时抛出异常 + */ public IMResult getUserInfoByMobile(String mobile) throws Exception { String path = APIPath.Channel_User_Info; InputGetUserInfo getUserInfo = new InputGetUserInfo(null, null, mobile); return channelHttpUtils.httpJsonPost(path, getUserInfo, InputOutputUserInfo.class); } + /** + * 修改频道信息 + * @param type 修改类型,参考{@link cn.wildfirechat.proto.ProtoConstants.ModifyChannelInfoType} + * @param value 修改的值 + * @return 操作结果 + * @throws Exception 请求失败时抛出异常 + */ public IMResult modifyChannelInfo(/*ProtoConstants.ModifyChannelInfoType*/int type, String value) throws Exception { String path = APIPath.Channel_Update_Profile; InputModifyChannelInfo modifyChannelInfo = new InputModifyChannelInfo(); @@ -67,16 +92,35 @@ public class ChannelServiceApi implements Closeable { return channelHttpUtils.httpJsonPost(path, modifyChannelInfo, Void.class); } + /** + * 获取频道信息 + * @return 频道信息 + * @throws Exception 请求失败时抛出异常 + */ public IMResult getChannelInfo() throws Exception { String path = APIPath.Channel_Get_Profile; return channelHttpUtils.httpJsonPost(path, null, OutputGetChannelInfo.class); } + /** + * 修改频道菜单 + * @param menus 菜单列表 + * @return 操作结果 + * @throws Exception 请求失败时抛出异常 + */ public IMResult modifyChannelMenu(List menus) throws Exception { String menuStr = new Gson().toJson(menus); return modifyChannelInfo(ProtoConstants.ModifyChannelInfoType.Modify_Channel_Menu, menuStr); } + /** + * 发送频道消息 + * @param line 线路 + * @param targets 目标用户ID列表 + * @param payload 消息内容 + * @return 发送结果 + * @throws Exception 请求失败时抛出异常 + */ public IMResult sendMessage(int line, List targets, MessagePayload payload) throws Exception { String path = APIPath.Channel_Message_Send; SendChannelMessageData messageData = new SendChannelMessageData(); @@ -86,6 +130,12 @@ public class ChannelServiceApi implements Closeable { return channelHttpUtils.httpJsonPost(path, messageData, SendMessageResult.class); } + /** + * 撤回频道消息 + * @param messageUid 消息UID + * @return 操作结果,返回被撤回消息的UID + * @throws Exception 请求失败时抛出异常 + */ public IMResult recallMessage(long messageUid) throws Exception { String path = APIPath.Channel_Msg_Recall; RecallMessageData messageData = new RecallMessageData(); @@ -93,6 +143,13 @@ public class ChannelServiceApi implements Closeable { return channelHttpUtils.httpJsonPost(path, messageData, String.class); } + /** + * 重新发布频道消息 + * @param messageUid 消息UID + * @param targets 目标用户ID列表 + * @return 操作结果 + * @throws Exception 请求失败时抛出异常 + */ public IMResult republishMessage(long messageUid, List targets) throws Exception { String path = APIPath.Channel_Msg_Republish; RepublishChannelMessageData messageData = new RepublishChannelMessageData(); @@ -101,6 +158,12 @@ public class ChannelServiceApi implements Closeable { return channelHttpUtils.httpJsonPost(path, messageData, Void.class); } + /** + * 订阅频道 + * @param userId 用户ID + * @return 操作结果 + * @throws Exception 请求失败时抛出异常 + */ public IMResult subscribe(String userId) throws Exception { String path = APIPath.Channel_Subscribe; InputChannelSubscribe input = new InputChannelSubscribe(); @@ -109,6 +172,12 @@ public class ChannelServiceApi implements Closeable { return channelHttpUtils.httpJsonPost(path, input, Void.class); } + /** + * 取消订阅频道 + * @param userId 用户ID + * @return 操作结果 + * @throws Exception 请求失败时抛出异常 + */ public IMResult unsubscribe(String userId) throws Exception { String path = APIPath.Channel_Subscribe; InputChannelSubscribe input = new InputChannelSubscribe(); @@ -117,17 +186,34 @@ public class ChannelServiceApi implements Closeable { return channelHttpUtils.httpJsonPost(path, input, Void.class); } + /** + * 获取频道订阅者列表 + * @return 订阅者用户ID列表 + * @throws Exception 请求失败时抛出异常 + */ public IMResult getSubscriberList() throws Exception { String path = APIPath.Channel_Subscriber_List; return channelHttpUtils.httpJsonPost(path, null, OutputStringList.class); } + /** + * 判断用户是否订阅了频道 + * @param userId 用户ID + * @return 是否订阅 + * @throws Exception 请求失败时抛出异常 + */ public IMResult isSubscriber(String userId) throws Exception { String path = APIPath.Channel_Is_Subscriber; InputUserId input = new InputUserId(userId); return channelHttpUtils.httpJsonPost(path, input, Boolean.class); } + /** + * 通过授权码获取应用用户信息 + * @param authCode 授权码 + * @return 应用用户信息 + * @throws Exception 请求失败时抛出异常 + */ public IMResult applicationGetUserInfo(String authCode) throws Exception { String path = APIPath.Channel_Application_Get_UserInfo; InputApplicationGetUserInfo input = new InputApplicationGetUserInfo(); @@ -135,6 +221,11 @@ public class ChannelServiceApi implements Closeable { return channelHttpUtils.httpJsonPost(path, input, OutputApplicationUserInfo.class); } + /** + * 获取应用签名配置 + *

用于客户端接入时的签名验证

+ * @return 应用签名配置数据 + */ public OutputApplicationConfigData getApplicationSignature() { int nonce = (int)(Math.random() * 100000 + 3); long timestamp = System.currentTimeMillis()/1000; @@ -149,6 +240,10 @@ public class ChannelServiceApi implements Closeable { return configData; } + /** + * 关闭服务,释放资源 + * @throws IOException 关闭时发生IO异常 + */ @Override public void close() throws IOException { channelHttpUtils.close(); diff --git a/sdk/src/main/java/cn/wildfirechat/sdk/RobotService.java b/sdk/src/main/java/cn/wildfirechat/sdk/RobotService.java index 0a265a62..e4432731 100644 --- a/sdk/src/main/java/cn/wildfirechat/sdk/RobotService.java +++ b/sdk/src/main/java/cn/wildfirechat/sdk/RobotService.java @@ -97,6 +97,14 @@ public class RobotService implements Closeable { return robotHttpUtils.httpJsonPost(path, messageData, SendMessageResult.class); } + /** + * 回复消息 + * @param messageUid 原消息UID + * @param payload 消息内容 + * @param only2Sender 是否只回复给原发送者 + * @return 发送结果 + * @throws Exception 请求失败时抛出异常 + */ public IMResult replyMessage(long messageUid, MessagePayload payload, boolean only2Sender) throws Exception { String path = APIPath.Robot_Message_Reply; ReplyMessageData messageData = new ReplyMessageData(); @@ -106,6 +114,12 @@ public class RobotService implements Closeable { return robotHttpUtils.httpJsonPost(path, messageData, SendMessageResult.class); } + /** + * 撤回消息 + * @param messageUid 消息UID + * @return 操作结果,返回被撤回消息的UID + * @throws Exception 请求失败时抛出异常 + */ public IMResult recallMessage(long messageUid) throws Exception { String path = APIPath.Robot_Message_Recall; RecallMessageData messageData = new RecallMessageData(); @@ -113,10 +127,25 @@ public class RobotService implements Closeable { return robotHttpUtils.httpJsonPost(path, messageData, String.class); } + /** + * 更新消息内容 + * @param messageUid 消息UID + * @param payload 新的消息内容 + * @return 操作结果 + * @throws Exception 请求失败时抛出异常 + */ public IMResult updateMessage(long messageUid, MessagePayload payload) throws Exception { return updateMessage(messageUid, payload, true); } + /** + * 更新消息内容 + * @param messageUid 消息UID + * @param payload 新的消息内容 + * @param distribute 是否分发给在线用户 + * @return 操作结果 + * @throws Exception 请求失败时抛出异常 + */ public IMResult updateMessage(long messageUid, MessagePayload payload, boolean distribute) throws Exception { String path = APIPath.Robot_Message_Update; UpdateMessageContentData updateMessageContentData = new UpdateMessageContentData(); @@ -127,24 +156,48 @@ public class RobotService implements Closeable { return robotHttpUtils.httpJsonPost(path, updateMessageContentData, Void.class); } + /** + * 根据用户ID获取用户信息 + * @param userId 用户ID + * @return 用户信息 + * @throws Exception 请求失败时抛出异常 + */ public IMResult getUserInfo(String userId) throws Exception { String path = APIPath.Robot_User_Info; InputGetUserInfo getUserInfo = new InputGetUserInfo(userId, null, null); return robotHttpUtils.httpJsonPost(path, getUserInfo, InputOutputUserInfo.class); } + /** + * 根据手机号获取用户信息 + * @param phone 手机号 + * @return 用户信息 + * @throws Exception 请求失败时抛出异常 + */ public IMResult getUserInfoByMobile(String phone) throws Exception { String path = APIPath.Robot_User_Info; InputGetUserInfo getUserInfo = new InputGetUserInfo(null, null, phone); return robotHttpUtils.httpJsonPost(path, getUserInfo, InputOutputUserInfo.class); } + /** + * 根据用户名获取用户信息 + * @param userName 用户名 + * @return 用户信息 + * @throws Exception 请求失败时抛出异常 + */ public IMResult getUserInfoByName(String userName) throws Exception { String path = APIPath.Robot_User_Info; InputGetUserInfo getUserInfo = new InputGetUserInfo(null, userName, null); return robotHttpUtils.httpJsonPost(path, getUserInfo, InputOutputUserInfo.class); } + /** + * 设置机器人消息回调地址 + * @param url 回调地址 + * @return 操作结果 + * @throws Exception 请求失败时抛出异常 + */ public IMResult setCallback(String url) throws Exception { String path = APIPath.Robot_Set_Callback; RobotCallbackPojo pojo = new RobotCallbackPojo(); @@ -152,23 +205,43 @@ public class RobotService implements Closeable { return robotHttpUtils.httpJsonPost(path, pojo, Void.class); } + /** + * 获取机器人消息回调地址 + * @return 回调信息 + * @throws Exception 请求失败时抛出异常 + */ public IMResult getCallback() throws Exception { String path = APIPath.Robot_Get_Callback; return robotHttpUtils.httpJsonPost(path, null, RobotCallbackPojo.class); } + /** + * 删除机器人消息回调地址 + * @return 操作结果 + * @throws Exception 请求失败时抛出异常 + */ public IMResult deleteCallback() throws Exception { String path = APIPath.Robot_Delete_Callback; return robotHttpUtils.httpJsonPost(path, null, Void.class); } + /** + * 获取机器人资料 + * @return 机器人资料 + * @throws Exception 请求失败时抛出异常 + */ public IMResult getProfile() throws Exception { String path = APIPath.Robot_Get_Profile; return robotHttpUtils.httpJsonPost(path, null, OutputRobot.class); } - /* - type可选范围为MyInfoType,注意不能修改电话号码,如果要修改电话号码请使用adminapi进行修改 + /** + * 更新机器人资料 + *

type可选范围为MyInfoType,注意不能修改电话号码,如果要修改电话号码请使用adminapi进行修改

+ * @param type 资料类型,参考MyInfoType + * @param value 资料值 + * @return 操作结果 + * @throws Exception 请求失败时抛出异常 */ public IMResult updateProfile(int/*MyInfoType*/ type, String value) throws Exception { String path = APIPath.Robot_Update_Profile; @@ -176,6 +249,16 @@ public class RobotService implements Closeable { return robotHttpUtils.httpJsonPost(path, pojo, Void.class); } + /** + * 创建群组 + * @param group_info 群组信息 + * @param members 群成员列表 + * @param member_extra 成员扩展信息 + * @param to_lines 指定线路 + * @param notify_message 通知消息 + * @return 创建结果 + * @throws Exception 请求失败时抛出异常 + */ public IMResult createGroup(PojoGroupInfo group_info, List members, String member_extra, List to_lines, MessagePayload notify_message) throws Exception { String path = APIPath.Robot_Create_Group; PojoGroup pojoGroup = new PojoGroup(); @@ -190,6 +273,12 @@ public class RobotService implements Closeable { return robotHttpUtils.httpJsonPost(path, createGroup, OutputCreateGroupResult.class); } + /** + * 获取群组信息 + * @param groupId 群组ID + * @return 群组信息 + * @throws Exception 请求失败时抛出异常 + */ public IMResult getGroupInfo(String groupId) throws Exception { String path = APIPath.Robot_Group_Get_Info; InputGetGroup input = new InputGetGroup(); @@ -198,6 +287,14 @@ public class RobotService implements Closeable { return robotHttpUtils.httpJsonPost(path, input, PojoGroupInfo.class); } + /** + * 解散群组 + * @param groupId 群组ID + * @param to_lines 指定线路 + * @param notify_message 通知消息 + * @return 操作结果 + * @throws Exception 请求失败时抛出异常 + */ public IMResult dismissGroup(String groupId, List to_lines, MessagePayload notify_message) throws Exception { String path = APIPath.Robot_Group_Dismiss; InputDismissGroup dismissGroup = new InputDismissGroup(); @@ -207,6 +304,15 @@ public class RobotService implements Closeable { return robotHttpUtils.httpJsonPost(path, dismissGroup, Void.class); } + /** + * 转让群组 + * @param groupId 群组ID + * @param newOwner 新群主用户ID + * @param to_lines 指定线路 + * @param notify_message 通知消息 + * @return 操作结果 + * @throws Exception 请求失败时抛出异常 + */ public IMResult transferGroup(String groupId, String newOwner, List to_lines, MessagePayload notify_message) throws Exception { String path = APIPath.Robot_Group_Transfer; InputTransferGroup transferGroup = new InputTransferGroup(); @@ -217,6 +323,16 @@ public class RobotService implements Closeable { return robotHttpUtils.httpJsonPost(path, transferGroup, Void.class); } + /** + * 修改群组信息 + * @param groupId 群组ID + * @param type 修改类型,参考ModifyGroupInfoType + * @param value 修改的值 + * @param to_lines 指定线路 + * @param notify_message 通知消息 + * @return 操作结果 + * @throws Exception 请求失败时抛出异常 + */ public IMResult modifyGroupInfo(String groupId, /*ModifyGroupInfoType*/int type, String value, List to_lines, MessagePayload notify_message) throws Exception { String path = APIPath.Robot_Group_Modify_Info; InputModifyGroupInfo modifyGroupInfo = new InputModifyGroupInfo(); @@ -229,6 +345,12 @@ public class RobotService implements Closeable { } + /** + * 获取群成员列表 + * @param groupId 群组ID + * @return 群成员列表 + * @throws Exception 请求失败时抛出异常 + */ public IMResult getGroupMembers(String groupId) throws Exception { String path = APIPath.Robot_Group_Member_List; InputGetGroup input = new InputGetGroup(); @@ -236,6 +358,13 @@ public class RobotService implements Closeable { return robotHttpUtils.httpJsonPost(path, input, OutputGroupMemberList.class); } + /** + * 获取指定群成员信息 + * @param groupId 群组ID + * @param memberId 成员用户ID + * @return 群成员信息 + * @throws Exception 请求失败时抛出异常 + */ public IMResult getGroupMember(String groupId, String memberId) throws Exception { String path = APIPath.Robot_Group_Member_Get; InputGetGroupMember input = new InputGetGroupMember(); @@ -244,6 +373,16 @@ public class RobotService implements Closeable { return robotHttpUtils.httpJsonPost(path, input, PojoGroupMember.class); } + /** + * 添加群成员 + * @param groupId 群组ID + * @param groupMembers 要添加的成员列表 + * @param member_extra 成员扩展信息 + * @param to_lines 指定线路 + * @param notify_message 通知消息 + * @return 操作结果 + * @throws Exception 请求失败时抛出异常 + */ public IMResult addGroupMembers(String groupId, List groupMembers, String member_extra, List to_lines, MessagePayload notify_message) throws Exception { String path = APIPath.Robot_Group_Member_Add; InputAddGroupMember addGroupMember = new InputAddGroupMember(); @@ -255,6 +394,16 @@ public class RobotService implements Closeable { return robotHttpUtils.httpJsonPost(path, addGroupMember, Void.class); } + /** + * 设置群管理员 + * @param groupId 群组ID + * @param groupMemberIds 成员用户ID列表 + * @param isManager 是否设为管理员 + * @param to_lines 指定线路 + * @param notify_message 通知消息 + * @return 操作结果 + * @throws Exception 请求失败时抛出异常 + */ public IMResult setGroupManager(String groupId, List groupMemberIds, boolean isManager, List to_lines, MessagePayload notify_message) throws Exception { String path = APIPath.Robot_Group_Set_Manager; InputSetGroupManager addGroupMember = new InputSetGroupManager(); @@ -266,6 +415,16 @@ public class RobotService implements Closeable { return robotHttpUtils.httpJsonPost(path, addGroupMember, Void.class); } + /** + * 禁言/取消禁言群成员 + * @param groupId 群组ID + * @param groupMemberIds 成员用户ID列表 + * @param isMute 是否禁言 + * @param to_lines 指定线路 + * @param notify_message 通知消息 + * @return 操作结果 + * @throws Exception 请求失败时抛出异常 + */ public IMResult muteGroupMember(String groupId, List groupMemberIds, boolean isMute, List to_lines, MessagePayload notify_message) throws Exception { String path = APIPath.Robot_Group_Mute_Member; InputMuteGroupMember addGroupMember = new InputMuteGroupMember(); @@ -277,6 +436,16 @@ public class RobotService implements Closeable { return robotHttpUtils.httpJsonPost(path, addGroupMember, Void.class); } + /** + * 允许/禁止群成员 + * @param groupId 群组ID + * @param groupMemberIds 成员用户ID列表 + * @param isAllow 是否允许 + * @param to_lines 指定线路 + * @param notify_message 通知消息 + * @return 操作结果 + * @throws Exception 请求失败时抛出异常 + */ public IMResult allowGroupMember(String groupId, List groupMemberIds, boolean isAllow, List to_lines, MessagePayload notify_message) throws Exception { String path = APIPath.Robot_Group_Allow_Member; InputMuteGroupMember addGroupMember = new InputMuteGroupMember(); @@ -288,6 +457,15 @@ public class RobotService implements Closeable { return robotHttpUtils.httpJsonPost(path, addGroupMember, Void.class); } + /** + * 踢出群成员 + * @param groupId 群组ID + * @param groupMemberIds 要踢出的成员用户ID列表 + * @param to_lines 指定线路 + * @param notify_message 通知消息 + * @return 操作结果 + * @throws Exception 请求失败时抛出异常 + */ public IMResult kickoffGroupMembers(String groupId, List groupMemberIds, List to_lines, MessagePayload notify_message) throws Exception { String path = APIPath.Robot_Group_Member_Kickoff; InputKickoffGroupMember kickoffGroupMember = new InputKickoffGroupMember(); @@ -298,6 +476,14 @@ public class RobotService implements Closeable { return robotHttpUtils.httpJsonPost(path, kickoffGroupMember, Void.class); } + /** + * 退出群组 + * @param groupId 群组ID + * @param to_lines 指定线路 + * @param notify_message 通知消息 + * @return 操作结果 + * @throws Exception 请求失败时抛出异常 + */ public IMResult quitGroup(String groupId, List to_lines, MessagePayload notify_message) throws Exception { String path = APIPath.Robot_Group_Member_Quit; InputQuitGroup quitGroup = new InputQuitGroup(); @@ -307,6 +493,16 @@ public class RobotService implements Closeable { return robotHttpUtils.httpJsonPost(path, quitGroup, Void.class); } + /** + * 设置群成员昵称 + * @param groupId 群组ID + * @param memberId 成员用户ID + * @param alias 群昵称 + * @param to_lines 指定线路 + * @param notify_message 通知消息 + * @return 操作结果 + * @throws Exception 请求失败时抛出异常 + */ public IMResult setGroupMemberAlias(String groupId, String memberId, String alias, List to_lines, MessagePayload notify_message) throws Exception { String path = APIPath.Robot_Group_Set_Member_Alias; InputSetGroupMemberAlias input = new InputSetGroupMemberAlias(); @@ -318,6 +514,16 @@ public class RobotService implements Closeable { return robotHttpUtils.httpJsonPost(path, input, Void.class); } + /** + * 设置群成员扩展信息 + * @param groupId 群组ID + * @param memberId 成员用户ID + * @param extra 扩展信息 + * @param to_lines 指定线路 + * @param notify_message 通知消息 + * @return 操作结果 + * @throws Exception 请求失败时抛出异常 + */ public IMResult setGroupMemberExtra(String groupId, String memberId, String extra, List to_lines, MessagePayload notify_message) throws Exception { String path = APIPath.Robot_Group_Set_Member_Extra; InputSetGroupMemberExtra input = new InputSetGroupMemberExtra(); @@ -329,6 +535,12 @@ public class RobotService implements Closeable { return robotHttpUtils.httpJsonPost(path, input, Void.class); } + /** + * 通过授权码获取应用用户信息 + * @param authCode 授权码 + * @return 应用用户信息 + * @throws Exception 请求失败时抛出异常 + */ public IMResult applicationGetUserInfo(String authCode) throws Exception { String path = APIPath.Robot_Application_Get_UserInfo; InputApplicationGetUserInfo input = new InputApplicationGetUserInfo(); @@ -336,6 +548,11 @@ public class RobotService implements Closeable { return robotHttpUtils.httpJsonPost(path, input, OutputApplicationUserInfo.class); } + /** + * 获取应用签名配置 + *

用于客户端接入时的签名验证

+ * @return 应用签名配置数据 + */ public OutputApplicationConfigData getApplicationSignature() { int nonce = (int)(Math.random() * 100000 + 3); long timestamp = System.currentTimeMillis()/1000; @@ -350,12 +567,36 @@ public class RobotService implements Closeable { return configData; } + /** + * 发送会议相关请求 + * @param robotId 机器人ID + * @param clientId 客户端ID + * @param request 请求类型 + * @param sessionId 会话ID + * @param roomId 会议室ID + * @param data 请求数据 + * @param advance 是否高级请求 + * @return 请求结果 + * @throws Exception 请求失败时抛出异常 + */ public IMResult sendConferenceRequest(String robotId, String clientId, String request, long sessionId, String roomId, String data, boolean advance) throws Exception { String path = APIPath.Robot_Conference_Request; InputConferenceRequest input = new InputConferenceRequest(robotId, clientId, request, sessionId, roomId, data, advance); return robotHttpUtils.httpJsonPost(path, input, String.class); } + /** + * 发布朋友圈动态 + * @param type 内容类型,参考MomentsContentType + * @param text 文本内容 + * @param medias 媒体列表 + * @param toUsers 可见用户列表 + * @param excludeUsers 不可见用户列表 + * @param mentionedUsers 提及用户列表 + * @param extra 扩展信息 + * @return 发布结果 + * @throws Exception 请求失败时抛出异常 + */ public IMResult postMomentsFeed(int/*MomentsContentType*/ type, String text, List medias, List toUsers, List excludeUsers, List mentionedUsers, String extra) throws Exception { String path = APIPath.Robot_Moments_Post_Feed; FeedPojo feedPojo = new FeedPojo(); @@ -380,6 +621,19 @@ public class RobotService implements Closeable { return feedResult; } + /** + * 更新朋友圈动态 + * @param feedId 动态ID + * @param type 内容类型,参考MomentsContentType + * @param text 文本内容 + * @param medias 媒体列表 + * @param toUsers 可见用户列表 + * @param excludeUsers 不可见用户列表 + * @param mentionedUsers 提及用户列表 + * @param extra 扩展信息 + * @return 操作结果 + * @throws Exception 请求失败时抛出异常 + */ public IMResult updateMomentsFeed(long feedId, int/*MomentsContentType*/ type, String text, List medias, List toUsers, List excludeUsers, List mentionedUsers, String extra) throws Exception { String path = APIPath.Robot_Moments_Update_Feed; FeedPojo feedPojo = new FeedPojo(); @@ -394,6 +648,14 @@ public class RobotService implements Closeable { return robotHttpUtils.httpJsonPost(path, feedPojo, Void.class); } + /** + * 获取朋友圈动态列表 + * @param feedId 起始动态ID + * @param count 获取数量 + * @param user 指定用户ID,为空表示获取所有 + * @return 动态列表 + * @throws Exception 请求失败时抛出异常 + */ public IMResult getMomentsFeeds(long feedId, int count, String user) throws Exception { String path = APIPath.Robot_Moments_Pull_Feeds; PullFeedRequestPojo requestPojo = new PullFeedRequestPojo(); @@ -403,6 +665,12 @@ public class RobotService implements Closeable { return robotHttpUtils.httpJsonPost(path, requestPojo, FeedsPojo.class); } + /** + * 获取单条朋友圈动态 + * @param feedId 动态ID + * @return 动态详情 + * @throws Exception 请求失败时抛出异常 + */ public IMResult getMomentsFeed(long feedId) throws Exception { String path = APIPath.Robot_Moments_Fetch_Feed; PullOneFeedRequestPojo requestPojo = new PullOneFeedRequestPojo(); @@ -410,6 +678,12 @@ public class RobotService implements Closeable { return robotHttpUtils.httpJsonPost(path, requestPojo, FeedPojo.class); } + /** + * 删除朋友圈动态 + * @param feedId 动态ID + * @return 操作结果 + * @throws Exception 请求失败时抛出异常 + */ public IMResult deleteMomentsFeed(long feedId) throws Exception { String path = APIPath.Robot_Moments_Recall_Feed; IdPojo requestPojo = new IdPojo(); @@ -417,6 +691,17 @@ public class RobotService implements Closeable { return robotHttpUtils.httpJsonPost(path, requestPojo, Void.class); } + /** + * 发布朋友圈评论 + * @param feedId 动态ID + * @param replyId 回复的评论ID + * @param type 评论类型,参考MomentsCommentType + * @param text 评论内容 + * @param replyTo 回复目标用户ID + * @param extra 扩展信息 + * @return 评论结果 + * @throws Exception 请求失败时抛出异常 + */ public IMResult 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(); @@ -440,6 +725,13 @@ public class RobotService implements Closeable { return feedResult; } + /** + * 删除朋友圈评论 + * @param feedId 动态ID + * @param commentId 评论ID + * @return 操作结果 + * @throws Exception 请求失败时抛出异常 + */ public IMResult deleteMomentsComment(long feedId, long commentId) throws Exception { String path = APIPath.Robot_Moments_Recall_Comment; IdPojo requestPojo = new IdPojo(); @@ -448,6 +740,12 @@ public class RobotService implements Closeable { return robotHttpUtils.httpJsonPost(path, requestPojo, Void.class); } + /** + * 获取用户朋友圈资料 + * @param userId 用户ID + * @return 朋友圈资料 + * @throws Exception 请求失败时抛出异常 + */ public IMResult getUserMomentsProfile(String userId) throws Exception { String path = APIPath.Robot_Moments_Fetch_Profiles; PullProfileRequestPojo requestPojo = new PullProfileRequestPojo(); @@ -455,6 +753,12 @@ public class RobotService implements Closeable { return robotHttpUtils.httpJsonPost(path, requestPojo, MomentProfilePojo.class); } + /** + * 更新朋友圈背景图 + * @param url 背景图URL + * @return 操作结果 + * @throws Exception 请求失败时抛出异常 + */ public IMResult updateMomentsBackgroundUrl(String url) throws Exception { String path = APIPath.Robot_Moments_Update_Profiles_Value; PushProfileValueRequestPojo requestPojo = new PushProfileValueRequestPojo(); @@ -463,6 +767,12 @@ public class RobotService implements Closeable { return robotHttpUtils.httpJsonPost(path, requestPojo, Void.class); } + /** + * 更新朋友圈陌生人可见数量 + * @param count 可见数量 + * @return 操作结果 + * @throws Exception 请求失败时抛出异常 + */ public IMResult updateMomentsStrangerVisibleCount(int count) throws Exception { String path = APIPath.Robot_Moments_Update_Profiles_Value; PushProfileValueRequestPojo requestPojo = new PushProfileValueRequestPojo(); @@ -471,6 +781,12 @@ public class RobotService implements Closeable { return robotHttpUtils.httpJsonPost(path, requestPojo, Void.class); } + /** + * 更新朋友圈可见范围 + * @param scope 可见范围,参考MomentsVisibleScope + * @return 操作结果 + * @throws Exception 请求失败时抛出异常 + */ public IMResult updateMomentsVisibleScope(int/*MomentsVisibleScope*/ scope) throws Exception { String path = APIPath.Robot_Moments_Update_Profiles_Value; PushProfileValueRequestPojo requestPojo = new PushProfileValueRequestPojo(); @@ -479,6 +795,13 @@ public class RobotService implements Closeable { return robotHttpUtils.httpJsonPost(path, requestPojo, Void.class); } + /** + * 更新朋友圈黑名单 + * @param addList 要添加的用户ID列表 + * @param removeList 要移除的用户ID列表 + * @return 操作结果 + * @throws Exception 请求失败时抛出异常 + */ public IMResult updateMomentsBlackList(List addList, List removeList) throws Exception { String path = APIPath.Robot_Moments_Update_Profiles_List_Value; PushProfileListRequestPojo requestPojo = new PushProfileListRequestPojo(); @@ -488,6 +811,13 @@ public class RobotService implements Closeable { return robotHttpUtils.httpJsonPost(path, requestPojo, Void.class); } + /** + * 更新朋友圈屏蔽列表 + * @param addList 要添加的用户ID列表 + * @param removeList 要移除的用户ID列表 + * @return 操作结果 + * @throws Exception 请求失败时抛出异常 + */ public IMResult updateMomentsBlockList(List addList, List removeList) throws Exception { String path = APIPath.Robot_Moments_Update_Profiles_List_Value; PushProfileListRequestPojo requestPojo = new PushProfileListRequestPojo(); @@ -497,6 +827,14 @@ public class RobotService implements Closeable { return robotHttpUtils.httpJsonPost(path, requestPojo, Void.class); } + /** + * 获取预签名上传地址 + * @param fileName 文件名 + * @param mediaType 媒体类型,参考{@link cn.wildfirechat.proto.ProtoConstants.MessageMediaType} + * @param contentType 文件Content-Type + * @return 预签名上传地址信息 + * @throws Exception 请求失败时抛出异常 + */ public IMResult getPresignedUploadUrl(String fileName, int/*ProtoConstants.MessageMediaType*/ mediaType, String contentType) throws Exception { String path = APIPath.Robot_Get_Presigned_Upload_Url; @@ -824,6 +1162,10 @@ public class RobotService implements Closeable { // 注意:正常流程下的流关闭在 uploadToQiniu 或 uploadToOther 的 finally 块中处理 } + /** + * 关闭服务,释放资源 + * @throws IOException 关闭时发生IO异常 + */ @Override public void close() throws IOException { robotHttpUtils.close();