Owns forum, wall post and comment operations for the current organisation: creating and finding posts, forum questions and comments, voting, tagging, reporting abuse, and tracking who follows a piece of content so they are notified of replies. Registered as the forumManager service, reachable from server-side JS. Most methods resolve the current organisation or website from the request context rather than taking it as a parameter.
Group: Managers
Properties
| Property | Returns | Description |
|---|---|---|
| forums | List<Forum> | Finds every forum belonging to the current organisation. Expensive: queries the database. |
Methods
findVotesBy(Profile voter) · findVotesFor(Profile voter) · wallContentId(BaseEntity entity) · newWallPostBuilder() · processWallPost(WallPostBuilder wallPostBuilder) · newForumQuestion(Forum forum, Website website, String parentHref, String newQuestion, String comment, Profile poster, List<Map<String,Object>> files) · replies(long postId) · replies(Post post, int limit) · followers(String contentId, Website website) · isFollowing(Profile user, Object target, Website website) · follow(Profile user, Object target, Website website) · unfollow(Profile user, Object target, Website website) · contentId(Object target) · willBeNotified(Profile p, Website w, String contentId) · post(String message) · post(Organisation teamOrg, String message) · post(Profile profile, String message) · post(String contentId, String message) · replyToPost(long postId, String comment) · vote(long postId, boolean upVote) · deleteVote(long postId) · getForums() · forum(String name) · renderSharedItem(RootFolder rf, String relatedAppName, String relatedItemId, KSearchHit hit) · deletePost(Post post) · findPost(Object oid) · newPostMatchRequest() · findMatchingPosts(PostMatchRequest request) · report(Post post, String category, String postURL, String comment) · tag(Post post, Profile taggedProfile, String comment) · deleteTag(Profile taggedProfile, Post post) · findVote(Post post) · findVoteById(long id) · deleteVote(Vote v) · updateVoteCount(Post post) · findPostTags(Post post) · newWallSharedItem(String contentId, ShareableItemEvent raae) · newProfileWallSharedItem(Profile userProfile, ShareableItemEvent raae) · newOrgWallSharedItem(Organisation teamOrg, ShareableItemEvent raae) · fireShareableItemEvent(Profile sourceProfile, Website sourceWebsite, String description, String relatedAppId, String relatedItemId) · fireShareableItemEvent(Profile sourceProfile, Website sourceWebsite, String description, String relatedAppId, String relatedItemId, List<String> contentIds) · findPostByOrg(Date start, Date finish, Integer limit) · newForumPostBuilder(Forum forum) · newCommentPostBuilder(CommonResource postedToResource) · newCommentPostBuilder(BlogArticle article) · findPostAttachment(Post post, String contentHash) · createPost(PostBuilder b) · findForumReplies(Profile profile, Date start, Date finish) · findComments(Profile profile, Date start, Date finish)
findVotesBy(Profile voter)
Returns: List<Vote>
Finds every vote cast by the given profile within the current organisation. Expensive: queries the database.
| Parameter | Description |
|---|---|
voter | the profile who cast the votes |
findVotesFor(Profile voter)
Returns: List<Vote>
Finds every vote cast for the given profile (as the recipient) within the current organisation. Expensive: queries the database.
| Parameter | Description |
|---|---|
voter | the profile who received the votes |
wallContentId(BaseEntity entity)
Returns: String
Builds the content id used to identify comments posted to the wall of the given entity, for use with the follow, unfollow and isFollowing methods.
| Parameter | Description |
|---|---|
entity | the organisation or profile whose wall content id is required |
newWallPostBuilder()
Returns: WallPostBuilder
Returns a new instance of WallPostBuilder
processWallPost(WallPostBuilder wallPostBuilder)
Returns: Comment
Creates a wall comment from a fully populated WallPostBuilder: resolves the poster, comment text and website either from the builder's ShareableItemEvent or from the current user and comment text, creates the comment against the wall entity, and attaches any files added to the builder.
| Parameter | Description |
|---|---|
wallPostBuilder | the builder describing the wall post to create, or null |
newForumQuestion(Forum forum, Website website, String parentHref, String newQuestion, String comment, Profile poster, List<Map<String,Object>> files)
Returns: ForumPost
Creates a new forum question in the given forum, makes the poster a follower of it so they are notified of replies, and attaches any files passed in the files list.
| Parameter | Description |
|---|---|
forum | the forum the question is posted to |
website | the website the question is posted from |
parentHref | the href of the page the question was raised from, if any |
newQuestion | the title of the new question |
comment | the body text of the question |
poster | the profile asking the question |
files | a list of maps describing files to attach, each with fileName, hash, type, size and ordinal entries |
replies(long postId)
Returns: List<Post>
Finds the ten most recent direct replies to a comment or post, identified by id, sorted oldest first. Expensive: queries the database.
| Parameter | Description |
|---|---|
postId | the id of the comment or post to find replies for |
replies(Post post, int limit)
Returns: List<Post>
Finds direct replies to the given post, up to limit results. For a forum post this reads its already-loaded forum replies, skipping deleted ones; for any other kind of post it queries for the most recent replies. Expensive when it falls back to a database query.
| Parameter | Description |
|---|---|
post | the comment, post, forum post or forum reply to find replies for |
limit | the maximum number of replies to return |
followers(String contentId, Website website)
Returns: List<PostFollower>
Finds every profile following the content item identified by contentId within the given website. Expensive: queries the database.
| Parameter | Description |
|---|---|
contentId | the content id of the item, as returned by contentId or wallContentId |
website | the website the content belongs to |
isFollowing(Profile user, Object target, Website website)
Returns: boolean
Checks whether the given profile is currently following a content item for notifications.
| Parameter | Description |
|---|---|
user | the profile to check |
target | the content item to check, as accepted by the contentId method |
website | the website the content belongs to |
follow(Profile user, Object target, Website website)
Returns: PostFollower
Makes a profile a follower of comments on the given target object, so they are notified of new comments and replies. The target can be a pre-formatted content id string, or a ForumPost, BlogArticle or CommonResource that is converted to a content id. Does nothing if the profile is already following the content.
| Parameter | Description |
|---|---|
user | the profile to make a follower |
target | the content item to follow, as accepted by the contentId method |
website | the website the content belongs to |
unfollow(Profile user, Object target, Website website)
Returns: void
Stops a profile following comments on the given target object, so they no longer receive notifications for it. Does nothing if the profile was not already following the content.
| Parameter | Description |
|---|---|
user | the profile to remove as a follower |
target | the content item to unfollow, as accepted by the contentId method |
website | the website the content belongs to |
contentId(Object target)
Returns: String
Converts a content object into the content id string used to key follows, notifications and comments. Accepts a String (returned unchanged), a ForumPost, a MyQuestionFolder (uses its underlying question), a BlogArticle, a BlogArticleFolder (uses its underlying article), or a CommonResource. Any other type, or null, yields null.
| Parameter | Description |
|---|---|
target | the content item to compute a content id for |
willBeNotified(Profile p, Website w, String contentId)
Returns: boolean
Checks whether the given profile would be sent an email notification if a comment were made on the content item identified by contentId.
| Parameter | Description |
|---|---|
p | the profile to check |
w | the website the content belongs to |
contentId | the content id of the item, as returned by contentId or wallContentId |
post(String message)
Returns: Post
Posts a wall comment as the current user, on the current admin organisation's wall.
| Parameter | Description |
|---|---|
message | the text of the post |
post(Organisation teamOrg, String message)
Returns: Post
Posts a wall comment as the current user, on the given team organisation's wall.
| Parameter | Description |
|---|---|
teamOrg | the organisation whose wall the post is created on, or null for the current admin organisation |
message | the text of the post |
post(Profile profile, String message)
Returns: Post
Posts a wall comment as the current user, on the given profile's wall.
| Parameter | Description |
|---|---|
profile | the profile whose wall the post is created on |
message | the text of the post |
post(String contentId, String message)
Returns: Post
Posts a wall comment as the current user, on the wall or content item identified by contentId.
| Parameter | Description |
|---|---|
contentId | the content id of the item to post on, as returned by contentId or wallContentId |
message | the text of the post |
replyToPost(long postId, String comment)
Returns: Post
Posts a reply as the current user to an existing post, identified by id.
| Parameter | Description |
|---|---|
postId | the id of the post to reply to |
comment | the text of the reply |
vote(long postId, boolean upVote)
Returns: void
Casts the current user's vote on a post, identified by id, either up or down.
| Parameter | Description |
|---|---|
postId | the id of the post to vote on |
upVote | true to cast an up vote, false to cast a down vote |
deleteVote(long postId)
Returns: void
Removes the current user's vote on a post, identified by id.
| Parameter | Description |
|---|---|
postId | the id of the post to remove the current user's vote from |
getForums()
Returns: List<Forum>
Finds every forum belonging to the current organisation. Expensive: queries the database.
forum(String name)
Returns: Forum
Finds a forum belonging to the current organisation by its name. Expensive: loads every forum in the organisation to find it.
| Parameter | Description |
|---|---|
name | the name of the forum to find |
renderSharedItem(RootFolder rf, String relatedAppName, String relatedItemId, KSearchHit hit)
Returns: String
Renders a search hit for a shared item using the app that owns it, if that app is active and supports sharing. Used to render search results for content that was shared via a wall post.
| Parameter | Description |
|---|---|
rf | the root folder the search was run against |
relatedAppName | the name of the app that owns the shared item |
relatedItemId | the id of the shared item within its owning app |
hit | the search hit to render |
deletePost(Post post)
Returns: void
Deletes a post within the current organisation.
| Parameter | Description |
|---|---|
post | the post to delete |
findPost(Object oid)
Returns: Post
Finds a post within the current organisation by id. Expensive: queries the database.
| Parameter | Description |
|---|---|
oid | the post id, as a Long or a value convertible to one |
newPostMatchRequest()
Returns: PostMatchRequest
Creates a new, empty PostMatchRequest ready to have its criteria set.
findMatchingPosts(PostMatchRequest request)
Returns: List<Post>
Runs a PostMatchRequest against posts in the current organisation and returns the matches. Always restricts results to the current organisation, and applies the request's deleted flag, date range, sort fields and paging on top of its combined criteria. Expensive: builds and executes a database query.
| Parameter | Description |
|---|---|
request | the criteria to match posts against |
report(Post post, String category, String postURL, String comment)
Returns: void
Reports a post as abusive or inappropriate on behalf of the current user, recording the category, the URL the report was raised from and an optional comment.
| Parameter | Description |
|---|---|
post | the post being reported |
category | the name of a PostReport.ReportCategory value describing why the post is being reported |
postURL | the URL the report was raised from |
comment | an optional comment explaining the report |
tag(Post post, Profile taggedProfile, String comment)
Returns: void
Tags a profile on a post, with an optional comment, typically to notify that profile of the post.
| Parameter | Description |
|---|---|
post | the post the profile is being tagged on |
taggedProfile | the profile being tagged |
comment | an optional comment about the tag |
deleteTag(Profile taggedProfile, Post post)
Returns: void
Removes a previously added tag of a profile on a post.
| Parameter | Description |
|---|---|
taggedProfile | the tagged profile whose tag is being removed |
post | the post the tag was made on |
findVote(Post post)
Returns: Vote
Finds the current user's vote on a post, if they have voted on it.
| Parameter | Description |
|---|---|
post | the post to find the current user's vote for |
findVoteById(long id)
Returns: Vote
Finds a vote within the current organisation by id.
| Parameter | Description |
|---|---|
id | the vote id |
deleteVote(Vote v)
Returns: void
Deletes a vote and updates the total vote count on the post it was cast on.
| Parameter | Description |
|---|---|
v | the vote to delete |
updateVoteCount(Post post)
Returns: void
Recalculates and stores the total vote count on a post. Does nothing if post is null.
| Parameter | Description |
|---|---|
post | the post to update the vote count for |
findPostTags(Post post)
Returns: List<PostTag>
Finds every tag on a post within the current organisation. Expensive: queries the database.
| Parameter | Description |
|---|---|
post | the post to find tags for |
newWallSharedItem(String contentId, ShareableItemEvent raae)
Returns: Comment
Creates a wall comment for a shared item on the wall or content item identified by contentId, using the event's description, website and source profile.
| Parameter | Description |
|---|---|
contentId | the content id of the wall or content item to post on |
raae | the event describing the item being shared |
newProfileWallSharedItem(Profile userProfile, ShareableItemEvent raae)
Returns: Comment
Creates a wall comment for a shared item on a profile's wall, using the event's description and source profile. The website is resolved from the event, falling back to a website with the forums app installed.
| Parameter | Description |
|---|---|
userProfile | the profile whose wall the comment is created on |
raae | the event describing the item being shared |
newOrgWallSharedItem(Organisation teamOrg, ShareableItemEvent raae)
Returns: Comment
Creates a wall comment for a shared item on a team organisation's wall, using the event's description and source profile. The website is resolved from the event, falling back to a website with the forums app installed.
| Parameter | Description |
|---|---|
teamOrg | the organisation whose wall the comment is created on |
raae | the event describing the item being shared |
fireShareableItemEvent(Profile sourceProfile, Website sourceWebsite, String description, String relatedAppId, String relatedItemId)
Returns: void
Fires a ShareableItemEvent for the current organisation, describing an item that another profile shared or received, for example a badge or level being awarded. Listeners can react to the event, such as by posting it to a wall.
| Parameter | Description |
|---|---|
sourceProfile | the profile the event is about |
sourceWebsite | the website the shared item relates to |
description | text describing what happened, used as the wall post text if the event is posted |
relatedAppId | the name of the app that owns the shared item |
relatedItemId | the id of the shared item within its owning app |
fireShareableItemEvent(Profile sourceProfile, Website sourceWebsite, String description, String relatedAppId, String relatedItemId, List<String> contentIds)
Returns: void
Fires a ShareableItemEvent for the current organisation, as per the four-argument overload, additionally carrying a list of content ids of items related to the event.
| Parameter | Description |
|---|---|
sourceProfile | the profile the event is about |
sourceWebsite | the website the shared item relates to |
description | text describing what happened, used as the wall post text if the event is posted |
relatedAppId | the name of the app that owns the shared item |
relatedItemId | the id of the shared item within its owning app |
contentIds | content ids of items related to the event |
findPostByOrg(Date start, Date finish, Integer limit)
Returns: List<Post>
Finds posts made within the current tenant organisation in a date range, up to limit results. Expensive: queries the database.
| Parameter | Description |
|---|---|
start | the start of the date range, inclusive |
finish | the end of the date range, exclusive |
limit | the maximum number of posts to return |
newForumPostBuilder(Forum forum)
Returns: ForumPostBuilder
Creates a new builder for posting a question or reply into the given forum.
| Parameter | Description |
|---|---|
forum | the forum the post is being created in |
newCommentPostBuilder(CommonResource postedToResource)
Returns: CommentPostBuilder
Creates a new builder for posting a comment against a content resource.
| Parameter | Description |
|---|---|
postedToResource | the resource the comment is being posted against |
newCommentPostBuilder(BlogArticle article)
Returns: CommentPostBuilder
Creates a new builder for posting a comment against a blog article.
| Parameter | Description |
|---|---|
article | the blog article the comment is being posted against |
findPostAttachment(Post post, String contentHash)
Returns: InputStream
Finds a file attached to a post by content hash and returns a stream of its content. The caller is responsible for closing the returned stream.
| Parameter | Description |
|---|---|
post | the post the file is attached to |
contentHash | the content hash of the attached file |
createPost(PostBuilder b)
Returns: Post
Creates a post, forum question, forum reply or comment from a populated PostBuilder, dispatching on its concrete type (ForumPostBuilder or CommentPostBuilder), and attaches any files added to the builder.
| Parameter | Description |
|---|---|
b | the builder describing the post to create |
findForumReplies(Profile profile, Date start, Date finish)
Returns: List<ForumReply>
Finds forum replies made by the given profile within the current tenant organisation in a date range. Expensive: queries the database.
| Parameter | Description |
|---|---|
profile | the profile who posted the replies |
start | the start of the date range, inclusive |
finish | the end of the date range, exclusive |
findComments(Profile profile, Date start, Date finish)
Returns: List<Comment>
Finds comments made by the given profile within the current tenant organisation in a date range. Expensive: queries the database.
| Parameter | Description |
|---|---|
profile | the profile who posted the comments |
start | the start of the date range, inclusive |
finish | the end of the date range, exclusive |