diff --git a/common/src/main/java/cn/wildfirechat/common/APIPath.java b/common/src/main/java/cn/wildfirechat/common/APIPath.java index 61fff754..3350ed66 100644 --- a/common/src/main/java/cn/wildfirechat/common/APIPath.java +++ b/common/src/main/java/cn/wildfirechat/common/APIPath.java @@ -157,5 +157,16 @@ 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_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"; } diff --git a/common/src/main/java/cn/wildfirechat/pojos/moments/CommentMsgPojo.java b/common/src/main/java/cn/wildfirechat/pojos/moments/CommentMsgPojo.java new file mode 100644 index 00000000..423083a7 --- /dev/null +++ b/common/src/main/java/cn/wildfirechat/pojos/moments/CommentMsgPojo.java @@ -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 fmedias; +} diff --git a/common/src/main/java/cn/wildfirechat/pojos/moments/CommentPojo.java b/common/src/main/java/cn/wildfirechat/pojos/moments/CommentPojo.java new file mode 100644 index 00000000..118171a5 --- /dev/null +++ b/common/src/main/java/cn/wildfirechat/pojos/moments/CommentPojo.java @@ -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; +} diff --git a/common/src/main/java/cn/wildfirechat/pojos/moments/FeedPojo.java b/common/src/main/java/cn/wildfirechat/pojos/moments/FeedPojo.java new file mode 100644 index 00000000..c51a2911 --- /dev/null +++ b/common/src/main/java/cn/wildfirechat/pojos/moments/FeedPojo.java @@ -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 medias; + + //to users + public List to; + + //excloud users + public List ex; + + //mentioned users + public List mu; + + //extra + public String extra; + + public List comments; +} diff --git a/common/src/main/java/cn/wildfirechat/pojos/moments/FeedsPojo.java b/common/src/main/java/cn/wildfirechat/pojos/moments/FeedsPojo.java new file mode 100644 index 00000000..6978a1b4 --- /dev/null +++ b/common/src/main/java/cn/wildfirechat/pojos/moments/FeedsPojo.java @@ -0,0 +1,7 @@ +package cn.wildfirechat.pojos.moments; + +import java.util.List; + +public class FeedsPojo { + public List feeds; +} diff --git a/common/src/main/java/cn/wildfirechat/pojos/moments/IdPojo.java b/common/src/main/java/cn/wildfirechat/pojos/moments/IdPojo.java new file mode 100644 index 00000000..c1658052 --- /dev/null +++ b/common/src/main/java/cn/wildfirechat/pojos/moments/IdPojo.java @@ -0,0 +1,9 @@ +package cn.wildfirechat.pojos.moments; + +public class IdPojo { + //feedid + public long id; + + //feedid + public long id2; +} diff --git a/common/src/main/java/cn/wildfirechat/pojos/moments/MediaEntry.java b/common/src/main/java/cn/wildfirechat/pojos/moments/MediaEntry.java new file mode 100644 index 00000000..b5555b41 --- /dev/null +++ b/common/src/main/java/cn/wildfirechat/pojos/moments/MediaEntry.java @@ -0,0 +1,8 @@ +package cn.wildfirechat.pojos.moments; + +public class MediaEntry { + public String m; + public String t; + public int w; + public int h; +} diff --git a/common/src/main/java/cn/wildfirechat/pojos/moments/MomentProfilePojo.java b/common/src/main/java/cn/wildfirechat/pojos/moments/MomentProfilePojo.java new file mode 100644 index 00000000..8a277c14 --- /dev/null +++ b/common/src/main/java/cn/wildfirechat/pojos/moments/MomentProfilePojo.java @@ -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 blackList; + public List blockList; + //stranger visiable count + public int svc; + public int visiableScope; +} diff --git a/common/src/main/java/cn/wildfirechat/pojos/moments/PostFeedResult.java b/common/src/main/java/cn/wildfirechat/pojos/moments/PostFeedResult.java new file mode 100644 index 00000000..09d2e42f --- /dev/null +++ b/common/src/main/java/cn/wildfirechat/pojos/moments/PostFeedResult.java @@ -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; + } +} diff --git a/common/src/main/java/cn/wildfirechat/pojos/moments/PullCommentsRequestPojo.java b/common/src/main/java/cn/wildfirechat/pojos/moments/PullCommentsRequestPojo.java new file mode 100644 index 00000000..2efb684f --- /dev/null +++ b/common/src/main/java/cn/wildfirechat/pojos/moments/PullCommentsRequestPojo.java @@ -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 ids; +} diff --git a/common/src/main/java/cn/wildfirechat/pojos/moments/PullFeedRequestPojo.java b/common/src/main/java/cn/wildfirechat/pojos/moments/PullFeedRequestPojo.java new file mode 100644 index 00000000..f829551c --- /dev/null +++ b/common/src/main/java/cn/wildfirechat/pojos/moments/PullFeedRequestPojo.java @@ -0,0 +1,8 @@ +package cn.wildfirechat.pojos.moments; + +public class PullFeedRequestPojo { + //feedid + public long feedId; + public int count; + public String user; +} diff --git a/common/src/main/java/cn/wildfirechat/pojos/moments/PullOneFeedRequestPojo.java b/common/src/main/java/cn/wildfirechat/pojos/moments/PullOneFeedRequestPojo.java new file mode 100644 index 00000000..60242685 --- /dev/null +++ b/common/src/main/java/cn/wildfirechat/pojos/moments/PullOneFeedRequestPojo.java @@ -0,0 +1,5 @@ +package cn.wildfirechat.pojos.moments; + +public class PullOneFeedRequestPojo { + public long feedId; +} diff --git a/common/src/main/java/cn/wildfirechat/pojos/moments/PullProfileRequestPojo.java b/common/src/main/java/cn/wildfirechat/pojos/moments/PullProfileRequestPojo.java new file mode 100644 index 00000000..a83cb039 --- /dev/null +++ b/common/src/main/java/cn/wildfirechat/pojos/moments/PullProfileRequestPojo.java @@ -0,0 +1,9 @@ +package cn.wildfirechat.pojos.moments; + +public class PullProfileRequestPojo { + //userId + public String u; + + //update date + public long d; +} diff --git a/common/src/main/java/cn/wildfirechat/pojos/moments/PushProfileListRequestPojo.java b/common/src/main/java/cn/wildfirechat/pojos/moments/PushProfileListRequestPojo.java new file mode 100644 index 00000000..a56c49e5 --- /dev/null +++ b/common/src/main/java/cn/wildfirechat/pojos/moments/PushProfileListRequestPojo.java @@ -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 al; + + //remove user list + public List rl; +} diff --git a/common/src/main/java/cn/wildfirechat/pojos/moments/PushProfileValueRequestPojo.java b/common/src/main/java/cn/wildfirechat/pojos/moments/PushProfileValueRequestPojo.java new file mode 100644 index 00000000..b8577278 --- /dev/null +++ b/common/src/main/java/cn/wildfirechat/pojos/moments/PushProfileValueRequestPojo.java @@ -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; +} diff --git a/common/src/main/java/cn/wildfirechat/proto/ProtoConstants.java b/common/src/main/java/cn/wildfirechat/proto/ProtoConstants.java index bb622afb..1dde35dd 100644 --- a/common/src/main/java/cn/wildfirechat/proto/ProtoConstants.java +++ b/common/src/main/java/cn/wildfirechat/proto/ProtoConstants.java @@ -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; diff --git a/sdk/src/main/java/cn/wildfirechat/sdk/Main.java b/sdk/src/main/java/cn/wildfirechat/sdk/Main.java index a0f7778c..7a77da13 100644 --- a/sdk/src/main/java/cn/wildfirechat/sdk/Main.java +++ b/sdk/src/main/java/cn/wildfirechat/sdk/Main.java @@ -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"; @@ -1575,8 +1580,6 @@ public class Main { System.out.println(config); } - - //仅专业版支持 if (commercialServer) { //开启群成员禁言 @@ -1643,6 +1646,82 @@ public class Main { System.exit(-1); } + //仅专业版支持,且服务器端支持朋友圈 + if (robotMomentsEnabled) { + IMResult postResult = robotService.postMomentsFeed(ProtoConstants.MomentsContentType.Moments_Content_Text_Type, "hello from robot", null, null, null, null, null); + 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 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); + } + + if(!pullResult.getResult().feeds.isEmpty()) { + IMResult feedResult = robotService.getMomentsFeed(pullResult.getResult().feeds.get(0).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 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 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 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 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 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 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功能,仅专业版支持*** diff --git a/sdk/src/main/java/cn/wildfirechat/sdk/RobotService.java b/sdk/src/main/java/cn/wildfirechat/sdk/RobotService.java index 1fccc074..d88965bd 100644 --- a/sdk/src/main/java/cn/wildfirechat/sdk/RobotService.java +++ b/sdk/src/main/java/cn/wildfirechat/sdk/RobotService.java @@ -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 createGroup(PojoGroupInfo group_info, List members, String member_extra, List to_lines, MessagePayload notify_message) 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(); pojoGroup.setGroup_info(group_info); @@ -118,7 +120,7 @@ public class RobotService { return robotHttpUtils.httpJsonPost(path, input, PojoGroupInfo.class); } - public IMResult dismissGroup(String groupId, List to_lines, MessagePayload notify_message) 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(); dismissGroup.setGroup_id(groupId); @@ -127,7 +129,7 @@ public class RobotService { return robotHttpUtils.httpJsonPost(path, dismissGroup, Void.class); } - public IMResult transferGroup(String groupId, String newOwner, List to_lines, MessagePayload notify_message) 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(); transferGroup.setGroup_id(groupId); @@ -137,7 +139,7 @@ public class RobotService { return robotHttpUtils.httpJsonPost(path, transferGroup, Void.class); } - public IMResult modifyGroupInfo(String groupId, /*ModifyGroupInfoType*/int type, String value, List to_lines, MessagePayload notify_message) 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(); modifyGroupInfo.setGroup_id(groupId); @@ -164,7 +166,7 @@ public class RobotService { return robotHttpUtils.httpJsonPost(path, input, PojoGroupMember.class); } - public IMResult addGroupMembers(String groupId, List groupMembers, String member_extra, List to_lines, MessagePayload notify_message) 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(); addGroupMember.setGroup_id(groupId); @@ -175,7 +177,7 @@ public class RobotService { return robotHttpUtils.httpJsonPost(path, addGroupMember, Void.class); } - public IMResult setGroupManager(String groupId, List groupMemberIds, boolean isManager, List to_lines, MessagePayload notify_message) 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(); addGroupMember.setGroup_id(groupId); @@ -186,7 +188,7 @@ public class RobotService { return robotHttpUtils.httpJsonPost(path, addGroupMember, Void.class); } - public IMResult muteGroupMember(String groupId, List groupMemberIds, boolean isMute, List to_lines, MessagePayload notify_message) 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(); addGroupMember.setGroup_id(groupId); @@ -197,7 +199,7 @@ public class RobotService { return robotHttpUtils.httpJsonPost(path, addGroupMember, Void.class); } - public IMResult allowGroupMember(String groupId, List groupMemberIds, boolean isAllow, List to_lines, MessagePayload notify_message) 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(); addGroupMember.setGroup_id(groupId); @@ -208,7 +210,7 @@ public class RobotService { return robotHttpUtils.httpJsonPost(path, addGroupMember, Void.class); } - public IMResult kickoffGroupMembers(String groupId, List groupMemberIds, List to_lines, MessagePayload notify_message) 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(); kickoffGroupMember.setGroup_id(groupId); @@ -218,7 +220,7 @@ public class RobotService { return robotHttpUtils.httpJsonPost(path, kickoffGroupMember, Void.class); } - public IMResult quitGroup(String groupId, List to_lines, MessagePayload notify_message) 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(); quitGroup.setGroup_id(groupId); @@ -227,7 +229,7 @@ public class RobotService { return robotHttpUtils.httpJsonPost(path, quitGroup, Void.class); } - public IMResult setGroupMemberAlias(String groupId, String memberId, String alias, List to_lines, MessagePayload notify_message) 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(); input.setGroup_id(groupId); @@ -238,7 +240,7 @@ public class RobotService { return robotHttpUtils.httpJsonPost(path, input, Void.class); } - public IMResult setGroupMemberExtra(String groupId, String memberId, String extra, List to_lines, MessagePayload notify_message) 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(); input.setGroup_id(groupId); @@ -276,4 +278,130 @@ public class RobotService { return robotHttpUtils.httpJsonPost(path, input, String.class); } + 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(); + feedPojo.type = type; + feedPojo.text = text; + feedPojo.medias = medias; + feedPojo.to = toUsers; + feedPojo.ex = excludeUsers; + feedPojo.mu = mentionedUsers; + feedPojo.extra = extra; + IMResult imResult = robotHttpUtils.httpJsonPost(path, feedPojo, PostFeedResult.class); + IMResult 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 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 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 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 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 imResult = robotHttpUtils.httpJsonPost(path, commentPojo, PostFeedResult.class); + IMResult 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 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 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 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 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 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 updateMomentsBlackList(List addList, List 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 updateMomentsBlockList(List addList, List 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); + } }