diff --git a/common/src/main/java/cn/wildfirechat/common/APIPath.java b/common/src/main/java/cn/wildfirechat/common/APIPath.java index 3350ed66..7127e4a6 100644 --- a/common/src/main/java/cn/wildfirechat/common/APIPath.java +++ b/common/src/main/java/cn/wildfirechat/common/APIPath.java @@ -159,6 +159,7 @@ public interface APIPath { 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"; diff --git a/sdk/src/main/java/cn/wildfirechat/sdk/Main.java b/sdk/src/main/java/cn/wildfirechat/sdk/Main.java index 1e1b6bd1..2ac9004c 100644 --- a/sdk/src/main/java/cn/wildfirechat/sdk/Main.java +++ b/sdk/src/main/java/cn/wildfirechat/sdk/Main.java @@ -1656,7 +1656,7 @@ public class Main { //仅专业版支持,且服务器端支持朋友圈 if (robotMomentsEnabled) { - IMResult postResult = robotService.postMomentsFeed(ProtoConstants.MomentsContentType.Moments_Content_Text_Type, "hello from robot", null, null, null, null, null); + IMResult 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 { @@ -1672,14 +1672,12 @@ public class Main { 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 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 commentThumbUpResult = robotService.postMomentsComment(postResult.result.feedId, 0, ProtoConstants.MomentsCommentType.Moments_Comment_Thumbup_Type, null, null, null); @@ -1698,6 +1696,14 @@ public class Main { System.exit(-1); } + IMResult 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 deleteCommentThumbUpResult = robotService.deleteMomentsComment(postResult.result.feedId, commentThumbUpResult.result.commentId); if (deleteCommentThumbUpResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) { System.out.println("delete moments thumb up success"); diff --git a/sdk/src/main/java/cn/wildfirechat/sdk/RobotService.java b/sdk/src/main/java/cn/wildfirechat/sdk/RobotService.java index d88965bd..c9b71035 100644 --- a/sdk/src/main/java/cn/wildfirechat/sdk/RobotService.java +++ b/sdk/src/main/java/cn/wildfirechat/sdk/RobotService.java @@ -302,6 +302,20 @@ public class RobotService { return feedResult; } + 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(); + 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 getMomentsFeeds(long feedId, int count, String user) throws Exception { String path = APIPath.Robot_Moments_Pull_Feeds; PullFeedRequestPojo requestPojo = new PullFeedRequestPojo();