Package io.meeds.mcp.server.tool
Class ActivityMcpTool
java.lang.Object
io.meeds.mcp.server.tool.ActivityMcpTool
- All Implemented Interfaces:
io.meeds.mcp.server.plugin.McpToolPlugin
@Service
public class ActivityMcpTool
extends Object
implements io.meeds.mcp.server.plugin.McpToolPlugin
-
Field Summary
Fields inherited from interface io.meeds.mcp.server.plugin.McpToolPlugin
DEFAULT_LIMIT, DEFAULT_OFFSET -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionattachImageToActivity(long activityId, String imageUrl, String imageBase64, String attachmentObjectType, String attachmentObjectId, String altText) attachImageToComment(long commentId, String imageUrl, String imageBase64, String attachmentObjectType, String attachmentObjectId, String altText) createActivity(Long spaceId, String htmlContent, String publicationStartTime) createActivityComment(long activityId, String comment, Long parentCommentId) Posts a comment on an activity as the current user.createActivityCommentWithImage(long activityId, String comment, String imageUrl, String imageBase64, String attachmentObjectType, String attachmentObjectId, String altText) Posts a top-level comment carrying an image, as the current user.createActivityWithImage(Long spaceId, String htmlContent, String imageUrl, String imageBase64, String attachmentObjectType, String attachmentObjectId, String altText) voiddeleteActivity(long activityId) getActivities(Long spaceId, Integer offset, Integer limit) getActivitiesSinceDays(Long spaceId, Long days) getActivity(long activityId) getActivityAttachments(long activityId) getActivityComment(long activityCommentId) getActivityComments(long activityId, Integer offset, Integer limit) Reads the discussion under an activity as the current user: its top-level comments and the replies threaded under them, in thread order.getActivityLikers(long activityId, Integer offset, Integer limit) getCommentAttachments(long commentId) getScheduledActivities(Long spaceId, Integer offset, Integer limit) Lists the activities the current user has scheduled but not yet published.getUserActivityStream(String username, Integer offset, Integer limit) voidlikeTheActivity(long activityId) voidpinActivity(long activityId) publishScheduledActivityNow(long activityId) Publishes a scheduled activity immediately instead of waiting for its publication time.removeImageFromActivity(long activityId, String fileId) removeImageFromComment(long commentId, String fileId) shareActivityToSpace(long activityId, long spaceId) voidunlikeTheActivity(long activityId) voidunpinActivity(long activityId) updateActivity(long activityId, String htmlContent, String publicationStartTime) updateComment(long activityCommentId, String comment) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.meeds.mcp.server.plugin.McpToolPlugin
getCurrentUserAclIdentity, getCurrentUserLocale, getCurrentUserLocale, getCurrentUserName, getLocale
-
Constructor Details
-
ActivityMcpTool
public ActivityMcpTool()
-
-
Method Details
-
getActivitiesSinceDays
public List<ActivityModel> getActivitiesSinceDays(Long spaceId, Long days) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException - Throws:
IllegalAccessExceptionorg.exoplatform.commons.exception.ObjectNotFoundException
-
getActivities
public List<ActivityModel> getActivities(Long spaceId, Integer offset, Integer limit) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException - Throws:
IllegalAccessExceptionorg.exoplatform.commons.exception.ObjectNotFoundException
-
getUserActivityStream
public List<ActivityModel> getUserActivityStream(String username, Integer offset, Integer limit) throws org.exoplatform.commons.exception.ObjectNotFoundException - Throws:
org.exoplatform.commons.exception.ObjectNotFoundException
-
getActivity
public ActivityModel getActivity(long activityId) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException - Throws:
IllegalAccessExceptionorg.exoplatform.commons.exception.ObjectNotFoundException
-
getActivityComment
public ActivityCommentModel getActivityComment(long activityCommentId) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException - Throws:
IllegalAccessExceptionorg.exoplatform.commons.exception.ObjectNotFoundException
-
createActivity
public ActivityModel createActivity(Long spaceId, String htmlContent, String publicationStartTime) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException - Throws:
IllegalAccessExceptionorg.exoplatform.commons.exception.ObjectNotFoundException
-
createActivityWithImage
public ActivityModel createActivityWithImage(Long spaceId, String htmlContent, String imageUrl, String imageBase64, String attachmentObjectType, String attachmentObjectId, String altText) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException - Throws:
IllegalAccessExceptionorg.exoplatform.commons.exception.ObjectNotFoundException
-
attachImageToActivity
public ActivityModel attachImageToActivity(long activityId, String imageUrl, String imageBase64, String attachmentObjectType, String attachmentObjectId, String altText) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException - Throws:
IllegalAccessExceptionorg.exoplatform.commons.exception.ObjectNotFoundException
-
updateActivity
public ActivityModel updateActivity(long activityId, String htmlContent, String publicationStartTime) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException - Throws:
IllegalAccessExceptionorg.exoplatform.commons.exception.ObjectNotFoundException
-
getScheduledActivities
public List<ActivityModel> getScheduledActivities(Long spaceId, Integer offset, Integer limit) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException Lists the activities the current user has scheduled but not yet published. These are deliberately absent from streams and from search_activities, so this is their only discovery path.- Parameters:
spaceId- restrict to one space, or null for every space the user seesoffset- index of the first activity to retrievelimit- maximum number of activities to retrieve- Returns:
- the list of pending scheduled activities, soonest first
- Throws:
IllegalAccessExceptionorg.exoplatform.commons.exception.ObjectNotFoundException
-
publishScheduledActivityNow
public ActivityModel publishScheduledActivityNow(long activityId) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException Publishes a scheduled activity immediately instead of waiting for its publication time. Publication is idempotent on the social side: publishing an already published activity simply returns its current state.- Parameters:
activityId- id of the scheduled activity to publish now- Returns:
- the published activity
- Throws:
IllegalAccessExceptionorg.exoplatform.commons.exception.ObjectNotFoundException
-
deleteActivity
public void deleteActivity(long activityId) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException - Throws:
IllegalAccessExceptionorg.exoplatform.commons.exception.ObjectNotFoundException
-
pinActivity
public void pinActivity(long activityId) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException - Throws:
IllegalAccessExceptionorg.exoplatform.commons.exception.ObjectNotFoundException
-
unpinActivity
public void unpinActivity(long activityId) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException - Throws:
IllegalAccessExceptionorg.exoplatform.commons.exception.ObjectNotFoundException
-
getActivityComments
public List<ActivityCommentModel> getActivityComments(long activityId, Integer offset, Integer limit) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException Reads the discussion under an activity as the current user: its top-level comments and the replies threaded under them, in thread order. Social places every reply right after the comment it answers and the reply carries that comment asparentCommentId, so a flat list keeps the thread structure visible; a top-level comment has noparentCommentId. Social threads one level deep, so a reply is always the child of a top-level comment.offsetandlimitpage the top-level comments only: each page carries the replies of the comments it holds, so the number of rows returned can exceedlimit.- Parameters:
activityId- identifier of the activity (post) whose thread is readoffset- index of the first top-level comment, defaults toMcpToolPlugin.DEFAULT_OFFSETlimit- number of top-level comments per page, defaults toMcpToolPlugin.DEFAULT_LIMIT- Returns:
- the comments of the page with their replies, in thread order
- Throws:
IllegalAccessException- when the current user can't view the activityorg.exoplatform.commons.exception.ObjectNotFoundException- when no activity has that identifier
-
createActivityComment
public ActivityCommentModel createActivityComment(long activityId, String comment, Long parentCommentId) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException Posts a comment on an activity as the current user. With aparentCommentIdthe comment is posted as a threaded reply to that comment, exactly as the "Reply" action of the activity stream does; without one it is a top-level comment, as before this parameter existed. The ACL check is the activity's own view check in both cases: a reply is a comment of the same activity and inherits its visibility, so no second check is needed and none is added.- Parameters:
activityId- identifier of the activity to comment oncomment- comment textparentCommentId- identifier of the comment to reply to, or null for a top-level comment- Returns:
- the created comment
- Throws:
IllegalAccessException- when the activity isn't viewable by the current userorg.exoplatform.commons.exception.ObjectNotFoundException- when the activity or the parent comment doesn't exist
-
createActivityCommentWithImage
public ActivityCommentModel createActivityCommentWithImage(long activityId, String comment, String imageUrl, String imageBase64, String attachmentObjectType, String attachmentObjectId, String altText) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException Posts a top-level comment carrying an image, as the current user. The comment is created throughcreateActivityComment(long, java.lang.String, java.lang.Long)without a parent, then the image is attached to it; when the attachment fails the comment is deleted again so nothing half-posted remains.- Parameters:
activityId- identifier of the activity to comment oncomment- comment textimageUrl- URL of the image to attach, may be nullimageBase64- base64 content of the image to attach, may be nullattachmentObjectType- type of the object an existing attachment is copied from, may be nullattachmentObjectId- identifier of the object an existing attachment is copied from, may be nullaltText- alternative text of the image, may be null- Returns:
- the created comment
- Throws:
IllegalAccessException- when the activity isn't viewable by the current userorg.exoplatform.commons.exception.ObjectNotFoundException- when the activity doesn't exist
-
attachImageToComment
public ActivityCommentModel attachImageToComment(long commentId, String imageUrl, String imageBase64, String attachmentObjectType, String attachmentObjectId, String altText) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException - Throws:
IllegalAccessExceptionorg.exoplatform.commons.exception.ObjectNotFoundException
-
getActivityAttachments
public List<AttachmentModel> getActivityAttachments(long activityId) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException - Throws:
IllegalAccessExceptionorg.exoplatform.commons.exception.ObjectNotFoundException
-
getCommentAttachments
public List<AttachmentModel> getCommentAttachments(long commentId) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException - Throws:
IllegalAccessExceptionorg.exoplatform.commons.exception.ObjectNotFoundException
-
removeImageFromActivity
public ActivityModel removeImageFromActivity(long activityId, String fileId) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException - Throws:
IllegalAccessExceptionorg.exoplatform.commons.exception.ObjectNotFoundException
-
removeImageFromComment
public ActivityCommentModel removeImageFromComment(long commentId, String fileId) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException - Throws:
IllegalAccessExceptionorg.exoplatform.commons.exception.ObjectNotFoundException
-
updateComment
public ActivityCommentModel updateComment(long activityCommentId, String comment) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException - Throws:
IllegalAccessExceptionorg.exoplatform.commons.exception.ObjectNotFoundException
-
getActivityLikers
public List<UserModel> getActivityLikers(long activityId, Integer offset, Integer limit) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException - Throws:
IllegalAccessExceptionorg.exoplatform.commons.exception.ObjectNotFoundException
-
likeTheActivity
public void likeTheActivity(long activityId) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException - Throws:
IllegalAccessExceptionorg.exoplatform.commons.exception.ObjectNotFoundException
-
unlikeTheActivity
public void unlikeTheActivity(long activityId) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException - Throws:
IllegalAccessExceptionorg.exoplatform.commons.exception.ObjectNotFoundException
-
searchActivities
public List<ActivityModel> searchActivities(String query, Long spaceId, Boolean isFavorite, Integer offset, Integer limit) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException - Throws:
IllegalAccessExceptionorg.exoplatform.commons.exception.ObjectNotFoundException
-