public interface

CommentLikeService

com.atlassian.stash.comment.like.CommentLikeService

Class Overview

Provides API for creating, removing and querying comment likes. Users can express their support for a comment ("like" the comment), as well as remove their support ("unlike" the comment). For any comment clients can query for a list of users who have liked the comment.

Note that all of the methods make use of the current authenticated user to process the requests.

The "like" and "unlike" operations are idempotent - invoking them multiple times in a row will not change the "liked" status of the comment with regards to the particular user beyond the initial invocation.

All operations require the user to have the read permission to the repository the comment belongs to.

Summary

Public Methods
@Nonnull Page<StashUser> findByComment(Repository repository, Comment comment, PageRequest pageRequest)
Get a page of "likers" of the comment (i.e.
boolean hasLike(Repository repository, Comment comment)
Checks whether the specified comment has been liked by the current authenticated user.
void like(Repository repository, Comment comment)
Like the comment as the current authenticated user.
void unlike(Repository repository, Comment comment)
Remove like from the comment as the current authenticated user.

Public Methods

@Nonnull public Page<StashUser> findByComment (Repository repository, Comment comment, PageRequest pageRequest)

Get a page of "likers" of the comment (i.e. users who have liked the comment).

The global order of the likers will be as the consecutive likes were recorded, with the exception of the current authenticated user - if that user has previously liked the comment, they will be "promoted" to the first position (globally) in the list, meaning that they will only be returned in a page requested with a page request start equal to 0.

Parameters
repository the repository that the comment belongs to
comment the comment
pageRequest page request
Returns
  • a page of users who have liked the comment, as per the pageRequest. May be empty, but never null
Throws
if the user has no read permission to the repository

public boolean hasLike (Repository repository, Comment comment)

Checks whether the specified comment has been liked by the current authenticated user.

Parameters
comment the comment to check
Returns
  • true if the current user has liked the comment, otherwise false.

public void like (Repository repository, Comment comment)

Like the comment as the current authenticated user. If the current user has already liked the comment previously, this call will have no effect.

Comment authors are not allowed or unlike to like their own comments.

Parameters
repository the repository that the comment belongs to
comment the comment to like
Throws
if the current user has no read permission to the repository
if the current user is the comment author

public void unlike (Repository repository, Comment comment)

Remove like from the comment as the current authenticated user. If the current user has not liked the comment previously, this call will have no effect.

Comment authors are not allowed or unlike to like their own comments.

Parameters
repository the repository that the comment belongs to
comment the comment to like
Throws
if the current user has no read permission to the repository
if the current user is the comment author