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

PropertyReturnsDescription
forumsList<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.

ParameterDescription
voterthe 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.

ParameterDescription
voterthe 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.

ParameterDescription
entitythe 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.

ParameterDescription
wallPostBuilderthe 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.

ParameterDescription
forumthe forum the question is posted to
websitethe website the question is posted from
parentHrefthe href of the page the question was raised from, if any
newQuestionthe title of the new question
commentthe body text of the question
posterthe profile asking the question
filesa 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.

ParameterDescription
postIdthe 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.

ParameterDescription
postthe comment, post, forum post or forum reply to find replies for
limitthe 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.

ParameterDescription
contentIdthe content id of the item, as returned by contentId or wallContentId
websitethe 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.

ParameterDescription
userthe profile to check
targetthe content item to check, as accepted by the contentId method
websitethe 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.

ParameterDescription
userthe profile to make a follower
targetthe content item to follow, as accepted by the contentId method
websitethe 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.

ParameterDescription
userthe profile to remove as a follower
targetthe content item to unfollow, as accepted by the contentId method
websitethe 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.

ParameterDescription
targetthe 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.

ParameterDescription
pthe profile to check
wthe website the content belongs to
contentIdthe 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.

ParameterDescription
messagethe 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.

ParameterDescription
teamOrgthe organisation whose wall the post is created on, or null for the current admin organisation
messagethe 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.

ParameterDescription
profilethe profile whose wall the post is created on
messagethe 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.

ParameterDescription
contentIdthe content id of the item to post on, as returned by contentId or wallContentId
messagethe 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.

ParameterDescription
postIdthe id of the post to reply to
commentthe 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.

ParameterDescription
postIdthe id of the post to vote on
upVotetrue 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.

ParameterDescription
postIdthe 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.

ParameterDescription
namethe 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.

ParameterDescription
rfthe root folder the search was run against
relatedAppNamethe name of the app that owns the shared item
relatedItemIdthe id of the shared item within its owning app
hitthe search hit to render

deletePost(Post post)

Returns: void

Deletes a post within the current organisation.

ParameterDescription
postthe post to delete

findPost(Object oid)

Returns: Post

Finds a post within the current organisation by id. Expensive: queries the database.

ParameterDescription
oidthe 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.

ParameterDescription
requestthe 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.

ParameterDescription
postthe post being reported
categorythe name of a PostReport.ReportCategory value describing why the post is being reported
postURLthe URL the report was raised from
commentan 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.

ParameterDescription
postthe post the profile is being tagged on
taggedProfilethe profile being tagged
commentan optional comment about the tag

deleteTag(Profile taggedProfile, Post post)

Returns: void

Removes a previously added tag of a profile on a post.

ParameterDescription
taggedProfilethe tagged profile whose tag is being removed
postthe 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.

ParameterDescription
postthe post to find the current user's vote for

findVoteById(long id)

Returns: Vote

Finds a vote within the current organisation by id.

ParameterDescription
idthe vote id

deleteVote(Vote v)

Returns: void

Deletes a vote and updates the total vote count on the post it was cast on.

ParameterDescription
vthe vote to delete

updateVoteCount(Post post)

Returns: void

Recalculates and stores the total vote count on a post. Does nothing if post is null.

ParameterDescription
postthe 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.

ParameterDescription
postthe 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.

ParameterDescription
contentIdthe content id of the wall or content item to post on
raaethe 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.

ParameterDescription
userProfilethe profile whose wall the comment is created on
raaethe 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.

ParameterDescription
teamOrgthe organisation whose wall the comment is created on
raaethe 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.

ParameterDescription
sourceProfilethe profile the event is about
sourceWebsitethe website the shared item relates to
descriptiontext describing what happened, used as the wall post text if the event is posted
relatedAppIdthe name of the app that owns the shared item
relatedItemIdthe 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.

ParameterDescription
sourceProfilethe profile the event is about
sourceWebsitethe website the shared item relates to
descriptiontext describing what happened, used as the wall post text if the event is posted
relatedAppIdthe name of the app that owns the shared item
relatedItemIdthe id of the shared item within its owning app
contentIdscontent 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.

ParameterDescription
startthe start of the date range, inclusive
finishthe end of the date range, exclusive
limitthe 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.

ParameterDescription
forumthe forum the post is being created in

newCommentPostBuilder(CommonResource postedToResource)

Returns: CommentPostBuilder

Creates a new builder for posting a comment against a content resource.

ParameterDescription
postedToResourcethe resource the comment is being posted against

newCommentPostBuilder(BlogArticle article)

Returns: CommentPostBuilder

Creates a new builder for posting a comment against a blog article.

ParameterDescription
articlethe 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.

ParameterDescription
postthe post the file is attached to
contentHashthe 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.

ParameterDescription
bthe 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.

ParameterDescription
profilethe profile who posted the replies
startthe start of the date range, inclusive
finishthe 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.

ParameterDescription
profilethe profile who posted the comments
startthe start of the date range, inclusive
finishthe end of the date range, exclusive
To get full access to the Kademi Hub existing customers can login here, or new customers can register here.