Class User

java.lang.Object
org.localify.user.User

@Entity public class User extends Object
Represents a user.
  • Constructor Details

    • User

      protected User()
      Protected no-arg constructor for JPA.
  • Method Details

    • isEmailConnected

      public boolean isEmailConnected()
      Checks if the user has an email connected.
      Returns:
      true if an email is connected, false otherwise.
    • isAppleConnected

      public boolean isAppleConnected()
      Checks if the user has an Apple Music account connected.
      Returns:
      true if an Apple Music account is connected, false otherwise.
    • isSpotifyConnected

      public boolean isSpotifyConnected()
      Checks if the user has a Spotify account connected.
      Returns:
      true if a Spotify account is connected, false otherwise.
    • getContributionBannedAt

      public Instant getContributionBannedAt()
      Gets the timestamp when the user was banned from making contributions.
      Returns:
      The contribution banned timestamp.
    • setContributionBannedAt

      public void setContributionBannedAt(Instant contributionBannedAt)
      Sets the timestamp when the user was banned from making contributions.
      Parameters:
      contributionBannedAt - The contribution banned timestamp.
    • getSpotifyUsername

      public String getSpotifyUsername()
      Gets the user's Spotify username.
      Returns:
      The Spotify username.
    • setSpotifyUsername

      public void setSpotifyUsername(String spotifyUsername)
      Sets the user's Spotify username.
      Parameters:
      spotifyUsername - The Spotify username.
    • processGoogleContainer

      public void processGoogleContainer(GoogleJwtUserDetails details)
      Processes a Google JWT user details object and updates the user's information.
      Parameters:
      details - The Google JWT user details.
    • updateSpotifyCredentials

      public void updateSpotifyCredentials(se.michaelthelin.spotify.model_objects.credentials.AuthorizationCodeCredentials spotifyCreds)
      Updates the user's Spotify credentials.
      Parameters:
      spotifyCreds - The new Spotify credentials.
    • processSpotifyContainer

      public User processSpotifyContainer(SpotifyUserDetails details)
      Processes a Spotify user details object and updates the user's information.
      Parameters:
      details - The Spotify user details.
      Returns:
      This User instance.
    • copySimpleDetails

      public User copySimpleDetails(User other)
      Copies simple details from another user object to this one.
      Parameters:
      other - The other user object.
      Returns:
      This User instance.
    • nameEligibleToBeAutoChanged

      public boolean nameEligibleToBeAutoChanged()
      Checks if the user's name is eligible to be automatically changed.
      Returns:
      true if the name is eligible, false otherwise.
    • emailEligibleToBeChanged

      public boolean emailEligibleToBeChanged()
      Checks if the user's email is eligible to be changed.
      Returns:
      true if the email is eligible, false otherwise.
    • setVerifiedEmail

      public void setVerifiedEmail(String verifiedEmail)
      Sets the user's email as verified.
      Parameters:
      verifiedEmail - The verified email address.
    • newGuestUser

      public static User newGuestUser(InetAddress ipAddress)
      Creates a new guest user.
      Parameters:
      ipAddress - The IP address of the user.
      Returns:
      The new guest user.
    • newUser

      public static User newUser(String name, InetAddress ipAddress)
      Creates a new user.
      Parameters:
      name - The name of the user.
      ipAddress - The IP address of the user.
      Returns:
      The new user.
    • toResponse

      public UserDetailsResponse toResponse()
      Converts the user to a response DTO.
      Returns:
      The user details response DTO.
    • spotifyCredentialsInvalid

      public boolean spotifyCredentialsInvalid()
      Checks if the user's Spotify credentials are invalid.
      Returns:
      true if the credentials are invalid, false otherwise.
    • toUserDetailsDto

      public UserDetailsDto toUserDetailsDto()
      Converts the user to a user details DTO for authentication purposes.
      Returns:
      The user details DTO.
    • isEmailVerified

      public boolean isEmailVerified()
      Checks if the user's email is verified.
      Returns:
      true if the email is verified, false otherwise.
    • isEmailOptIn

      public boolean isEmailOptIn()
      Checks if the user has opted in to emails.
      Returns:
      true if the user has opted in, false otherwise.
    • setEmailOptIn

      public void setEmailOptIn(boolean emailOptIn)
      Sets whether the user has opted in to emails.
      Parameters:
      emailOptIn - true if the user has opted in, false otherwise.
    • setHideContributed

      public void setHideContributed(boolean hideContributed)
      Sets whether to hide the user's contributions.
      Parameters:
      hideContributed - true to hide contributions, false otherwise.
    • isGuest

      public boolean isGuest()
      Checks if the user is a guest.
      Returns:
      true if the user is a guest, false otherwise.
    • setGuest

      public void setGuest(boolean guest)
      Sets whether the user is a guest.
      Parameters:
      guest - true if the user is a guest, false otherwise.
    • setVerifiedArtist

      public void setVerifiedArtist(Artist verifiedArtist)
      Sets the verified artist for the user.
      Parameters:
      verifiedArtist - The verified artist.
    • setDisabled

      public void setDisabled(boolean disabled)
      Sets whether the user is disabled.
      Parameters:
      disabled - true if the user is disabled, false otherwise.
    • setAdmin

      public void setAdmin(boolean admin)
      Sets whether the user is an admin.
      Parameters:
      admin - true if the user is an admin, false otherwise.
    • setSuperAdmin

      public void setSuperAdmin(boolean superAdmin)
      Sets whether the user is a super admin.
      Parameters:
      superAdmin - true if the user is a super admin, false otherwise.
    • setTeamMember

      public void setTeamMember(boolean teamMember)
      Sets whether the user is a team member.
      Parameters:
      teamMember - true if the user is a team member, false otherwise.
    • accountCreationDate

      public Instant accountCreationDate()
      Gets the account creation date.
      Returns:
      The account creation date.
    • getName

      public String getName()
      Gets the name of the user.
      Returns:
      The user's name.
    • setName

      public void setName(String name)
      Sets the name of the user.
      Parameters:
      name - The user's name.
    • getUserEmail

      public String getUserEmail()
      Gets the user's email address.
      Returns:
      The email address.
    • setUserEmail

      public void setUserEmail(String userEmail)
      Sets the user's email address.
      Parameters:
      userEmail - The email address.
    • optEmailIn

      public void optEmailIn()
      Opts the user in to emails.
    • optEmailOut

      public void optEmailOut()
      Opts the user out of emails.
    • getCreatedAt

      public Instant getCreatedAt()
      Gets the creation timestamp.
      Returns:
      The creation timestamp.
    • getUpdatedAt

      public Instant getUpdatedAt()
      Gets the last update timestamp.
      Returns:
      The last update timestamp.
    • getDeletedAt

      public Instant getDeletedAt()
      Gets the deleted timestamp.
      Returns:
      The deleted timestamp.
    • getSpotifyId

      public String getSpotifyId()
      Gets the user's Spotify ID.
      Returns:
      The Spotify ID.
    • setSpotifyId

      public void setSpotifyId(String spotifyId)
      Sets the user's Spotify ID.
      Parameters:
      spotifyId - The Spotify ID.
    • getId

      public UUID getId()
      Gets the user's ID.
      Returns:
      The user ID.
    • disableUser

      public void disableUser()
      Disables the user's account.
    • enableUser

      public void enableUser()
      Enables the user's account.
    • getCities

      public List<UserCity> getCities()
      Gets the user's cities.
      Returns:
      A list of user cities.
    • getSignupIp

      public InetAddress getSignupIp()
      Gets the user's signup IP address.
      Returns:
      The signup IP address.
    • getGoogleId

      public String getGoogleId()
      Gets the user's Google ID.
      Returns:
      The Google ID.
    • setGoogleId

      public void setGoogleId(String googleId)
      Sets the user's Google ID.
      Parameters:
      googleId - The Google ID.
    • getVerifiedArtist

      public Artist getVerifiedArtist()
      Gets the user's verified artist.
      Returns:
      The verified artist.
    • setEmailVerified

      public void setEmailVerified(boolean emailVerified)
      Sets whether the user's email is verified.
      Parameters:
      emailVerified - true if the email is verified, false otherwise.
    • getGooglePictureUrl

      public String getGooglePictureUrl()
      Gets the user's Google profile picture URL.
      Returns:
      The Google profile picture URL.
    • getSpotifyCountryCode

      public com.neovisionaries.i18n.CountryCode getSpotifyCountryCode()
      Gets the user's Spotify country code.
      Returns:
      The Spotify country code.
    • getSpotifyProfilePicture

      public String getSpotifyProfilePicture()
      Gets the user's Spotify profile picture URL.
      Returns:
      The Spotify profile picture URL.
    • getSpotifyAccessToken

      public String getSpotifyAccessToken()
      Gets the user's Spotify access token.
      Returns:
      The Spotify access token.
    • getSpotifyRefreshToken

      public String getSpotifyRefreshToken()
      Gets the user's Spotify refresh token.
      Returns:
      The Spotify refresh token.
    • getSpotifyAccessTokenExpiresAt

      public Instant getSpotifyAccessTokenExpiresAt()
      Gets the expiration time of the user's Spotify access token.
      Returns:
      The expiration time.
    • getLegacyId

      public Integer getLegacyId()
      Gets the user's legacy ID.
      Returns:
      The legacy ID.
    • setLegacyId

      public void setLegacyId(Integer legacyId)
      Sets the user's legacy ID.
      Parameters:
      legacyId - The legacy ID.
    • getTrustScore

      public Double getTrustScore()
      Gets the user's trust score.
      Returns:
      The trust score.
    • setTrustScore

      public void setTrustScore(Double trustScore)
      Sets the user's trust score.
      Parameters:
      trustScore - The trust score.
    • hideContributed

      public void hideContributed()
      Hides the user's contributions.
    • showContributed

      public void showContributed()
      Shows the user's contributions.
    • isHideContributed

      public boolean isHideContributed()
      Checks if the user's contributions are hidden.
      Returns:
      true if contributions are hidden, false otherwise.
    • getAppleMusicToken

      public String getAppleMusicToken()
      Gets the user's Apple Music token.
      Returns:
      The Apple Music token.
    • setAppleMusicToken

      public void setAppleMusicToken(String appleMusicToken)
      Sets the user's Apple Music token.
      Parameters:
      appleMusicToken - The Apple Music token.
    • isHidingContributed

      public boolean isHidingContributed()
      Checks if the user is hiding their contributions.
      Returns:
      true if contributions are hidden, false otherwise.
    • getContributedName

      public String getContributedName()
      Gets the name to display for contributions.
      Returns:
      The contribution name.
    • setId

      public void setId(UUID id)
      Sets the user's ID.
      Parameters:
      id - The user ID.
    • setSignupIp

      public void setSignupIp(InetAddress signupIp)
      Sets the user's signup IP address.
      Parameters:
      signupIp - The signup IP address.
    • setCreatedAt

      public void setCreatedAt(Instant createdAt)
      Sets the creation timestamp.
      Parameters:
      createdAt - The creation timestamp.
    • setUpdatedAt

      public void setUpdatedAt(Instant updatedAt)
      Sets the last update timestamp.
      Parameters:
      updatedAt - The last update timestamp.
    • setDeletedAt

      public void setDeletedAt(Instant deletedAt)
      Sets the deleted timestamp.
      Parameters:
      deletedAt - The deleted timestamp.
    • setGooglePictureUrl

      public void setGooglePictureUrl(String googlePictureUrl)
      Sets the user's Google profile picture URL.
      Parameters:
      googlePictureUrl - The Google profile picture URL.
    • setSpotifyCountryCode

      public void setSpotifyCountryCode(com.neovisionaries.i18n.CountryCode spotifyCountryCode)
      Sets the user's Spotify country code.
      Parameters:
      spotifyCountryCode - The Spotify country code.
    • setSpotifyProfilePicture

      public void setSpotifyProfilePicture(String spotifyProfilePicture)
      Sets the user's Spotify profile picture URL.
      Parameters:
      spotifyProfilePicture - The Spotify profile picture URL.
    • setSpotifyAccessToken

      public void setSpotifyAccessToken(String spotifyAccessToken)
      Sets the user's Spotify access token.
      Parameters:
      spotifyAccessToken - The Spotify access token.
    • setSpotifyRefreshToken

      public void setSpotifyRefreshToken(String spotifyRefreshToken)
      Sets the user's Spotify refresh token.
      Parameters:
      spotifyRefreshToken - The Spotify refresh token.
    • setSpotifyAccessTokenExpiresAt

      public void setSpotifyAccessTokenExpiresAt(Instant spotifyAccessTokenExpiresAt)
      Sets the expiration time of the user's Spotify access token.
      Parameters:
      spotifyAccessTokenExpiresAt - The expiration time.
    • setCities

      public void setCities(List<UserCity> cities)
      Sets the user's cities.
      Parameters:
      cities - A list of user cities.
    • getAppleId

      public String getAppleId()
      Gets the user's Apple Music ID.
      Returns:
      The Apple Music ID.
    • setAppleId

      public void setAppleId(String appleId)
      Sets the user's Apple Music ID.
      Parameters:
      appleId - The Apple Music ID.
    • isDisabled

      public boolean isDisabled()
      Checks if the user is disabled.
      Returns:
      true if the user is disabled, false otherwise.
    • isAdmin

      public boolean isAdmin()
      Checks if the user is an admin.
      Returns:
      true if the user is an admin, false otherwise.
    • isSuperAdmin

      public boolean isSuperAdmin()
      Checks if the user is a super admin.
      Returns:
      true if the user is a super admin, false otherwise.
    • isTeamMember

      public boolean isTeamMember()
      Checks if the user is a team member.
      Returns:
      true if the user is a team member, false otherwise.
    • getPlaylistUseSeedSongs

      public Boolean getPlaylistUseSeedSongs()
      Gets the user's preference for using seed songs in playlists.
      Returns:
      The user's preference.
    • setPlaylistUseSeedSongs

      public void setPlaylistUseSeedSongs(Boolean playlistUseSeedSongs)
      Sets the user's preference for using seed songs in playlists.
      Parameters:
      playlistUseSeedSongs - The user's preference.
    • getPlaylistLocalSongsPerSeed

      public Integer getPlaylistLocalSongsPerSeed()
      Gets the number of local songs to include per seed artist in playlists.
      Returns:
      The number of local songs per seed.
    • setPlaylistLocalSongsPerSeed

      public void setPlaylistLocalSongsPerSeed(Integer playlistLocalSongsPerSeed)
      Sets the number of local songs to include per seed artist in playlists.
      Parameters:
      playlistLocalSongsPerSeed - The number of local songs per seed.
    • getPlaylistGeneration

      public Boolean getPlaylistGeneration()
      Gets the user's preference for playlist generation.
      Returns:
      The user's preference.
    • setPlaylistGeneration

      public void setPlaylistGeneration(Boolean playlistGeneration)
      Sets the user's preference for playlist generation.
      Parameters:
      playlistGeneration - The user's preference.
    • removeUserData

      public void removeUserData()
      Removes all personal data associated with a user.
    • getLocalifyProfilePicture

      public String getLocalifyProfilePicture()
      Gets the user's Localify profile picture URL.
      Returns:
      The profile picture URL.