Interface AvatarService

  • All Known Implementing Classes:
    AvatarServiceImpl

    public interface AvatarService
    Since:
    9.5
    • Method Detail

      • getUserDefault

        @NotNull
        @NotNull CacheableAvatarSupplier getUserDefault​(int size)
        Retrieves a stable default user avatar, suitable for display in anonymous contexts.
        Parameters:
        size - the size to retrieve the avatar in
        Returns:
        an AvatarSupplier which can be used to read the avatar
      • getForUser

        @Nullable
        @Nullable CacheableAvatarSupplier getForUser​(@NotNull
                                                     @NotNull Principal user,
                                                     int size)
        Retrieves the current avatar for the specified user. If no explicit avatar has been set, a null will be returned.
        Parameters:
        user - the user to retrieve the avatar for
        size - the size to retrieve the avatar in
        Returns:
        an AvatarSupplier which can be used to read the avatar
      • saveForUser

        void saveForUser​(@NotNull
                         @NotNull Principal user,
                         @NotNull
                         @NotNull Supplier<AvatarSupplier> metaSupplier)
        Saves the avatar contained in the provided avatarSupplier obtained from the provided metaSupplier as the new avatar for the specified User, removing any previously-stored avatar.

        Previous avatars are not maintained. The only way to restore a previous avatar is to save it again.

        Parameters:
        user - the user whose avatar is being set
        metaSupplier - a supplier providing access to the new avatar to use
      • isUserAvatarStored

        boolean isUserAvatarStored​(@NotNull
                                   @NotNull Principal user)
        Checks whether the user has an avatar stored.
        Parameters:
        user - the user to check
        Returns:
        true if the user's avatar is stored.
      • deleteForUser

        void deleteForUser​(@NotNull
                           @NotNull Principal user)
        Delete the avatar associated with a user.

        This will revert the avatar of the user in the UI to their Gravatar image (if the Gravatar integration is enabled) or to the default user avatar (if the Gravatar integration is disabled)

        Parameters:
        user - the user whose (local) avatar will be removed
      • deleteForUser

        void deleteForUser​(@NotNull
                           @NotNull String userName)
        Delete the avatar associated with a user's name.

        This will revert the avatar of the user in the UI to their Gravatar image (if the Gravatar integration is enabled) or to the default user avatar (if the Gravatar integration is disabled)

        Parameters:
        userName - the user's name whose (local) avatar will be removed
      • moveForUser

        void moveForUser​(@NotNull
                         @NotNull String oldUserName,
                         @NotNull
                         @NotNull String newUserName)
        Moves the avatar associated with a user to another user.
        Parameters:
        oldUserName - the user whose avatar will be moved
        newUserName - the user whose avatar will be replaced
      • getMaxUploadSize

        long getMaxUploadSize()
        Retrieves the maximum size, in bytes, for uploaded avatars. Avatars larger than this will be rejected by the server.
        Returns:
        the maximum size, in bytes, for uploaded avatars