Class UserSelfController

java.lang.Object
org.localify.user.UserSelfController

@RestController @ConditionalOnWebApplication @RequestMapping("/v1/@me") public class UserSelfController extends Object
Controller for handling requests related to the authenticated user's own data and personalized content.
  • Constructor Details

    • UserSelfController

      @Autowired public UserSelfController(UserService userService, CityService cityService, RecommendService recommender, AppleMusicService appleMusicService, LoginService loginService, JwtService jwtService, SpotifyLoginService spotifyLoginService, EmailLoginService emailLoginService, AccountMergingService accountMergingService)
      Constructs a new UserSelfController.
      Parameters:
      userService - The user service.
      cityService - The city service.
      recommender - The recommendation service.
      appleMusicService - The Apple Music service.
      loginService - The login service.
      jwtService - The JWT service.
      spotifyLoginService - The Spotify login service.
      emailLoginService - The email login service.
      accountMergingService - The account merging service.
  • Method Details

    • getSelfInformation

      @GetMapping(value="", produces="application/json") @ResponseBody public UserDetailsResponse getSelfInformation(@AuthenticationPrincipal UserDetailsImpl user)
      Gets the authenticated user's own information.
      Parameters:
      user - The authenticated user.
      Returns:
      The user's details.
    • linkAppleMusic

      @GetMapping("/apple-music/link") @ResponseBody public org.springframework.http.ResponseEntity<Void> linkAppleMusic(@AuthenticationPrincipal UserDetailsImpl user, @RequestParam @NotBlank @NotBlank String redirectUrl)
      Links the user's Apple Music account.
      Parameters:
      user - The authenticated user.
      redirectUrl - The URL to redirect to after linking.
      Returns:
      A redirect to the Apple Music authorization page.
    • linkSpotify

      @GetMapping("/spotify/link") @ResponseBody public org.springframework.http.ResponseEntity<URI> linkSpotify(@AuthenticationPrincipal UserDetailsImpl user, @Valid @Valid UserOAuthRedirectParams params)
      Links the user's Spotify account.
      Parameters:
      user - The authenticated user.
      params - The OAuth redirect parameters.
      Returns:
      A response containing the Spotify authorization URI.
    • connectByEmailToken

      @PostMapping("/email/link") public AuthCredentialsMergeable connectByEmailToken(@AuthenticationPrincipal UserDetailsImpl user, @RequestBody @Valid @Valid UserEmailTokenLoginRequest request)
      Connects an email account using a token.
      Parameters:
      user - The authenticated user.
      request - The email token login request.
      Returns:
      The authentication credentials.
    • changeEmail

      @PostMapping("/email") public AuthCredentialsMergeable changeEmail(@AuthenticationPrincipal UserDetailsImpl user, @RequestBody @Valid @Valid UserEmailTokenLoginRequest request)
      Changes the user's email address.
      Parameters:
      user - The authenticated user.
      request - The email token login request.
      Returns:
      The authentication credentials.
    • mergeAccounts

      @PostMapping("/merge") public AuthCredentials mergeAccounts(@AuthenticationPrincipal UserDetailsImpl user, @RequestBody @Valid @Valid AccountMergeRequest request)
      Merges accounts.
      Parameters:
      user - The authenticated user.
      request - The account merge request.
      Returns:
      The authentication credentials.
    • getMergeableAccount

      @GetMapping("/mergeable-account") public MergeableAccount getMergeableAccount(@AuthenticationPrincipal UserDetailsImpl user, @RequestParam String mergeToken)
      Gets information about a mergeable account.
      Parameters:
      user - The authenticated user.
      mergeToken - The merge token.
      Returns:
      The mergeable account information.
    • patchUserCity

      @PatchMapping(value="/cities/{cityId}", produces="application/json") @ResponseBody public UserCityContainer patchUserCity(@AuthenticationPrincipal UserDetailsImpl user, @PathVariable UUID cityId, @RequestBody @Valid @Valid UserCityPatchRequest request)
      Patches a user's city.
      Parameters:
      user - The authenticated user.
      cityId - The ID of the city.
      request - The patch request.
      Returns:
      The updated user city container.
    • putUserCity

      @PutMapping(value="/cities/{cityId}", produces="application/json") @ResponseBody public UserCityContainer putUserCity(@AuthenticationPrincipal UserDetailsImpl user, @PathVariable UUID cityId, @RequestBody @Valid @Valid UserCityPutRequest request)
      Adds or updates a user's city.
      Parameters:
      user - The authenticated user.
      cityId - The ID of the city.
      request - The put request.
      Returns:
      The updated user city container.
    • putUserCityOnboarding

      @PutMapping(value="/cities/{cityId}/onboarding", produces="application/json") @ResponseBody public UserCityContainer putUserCityOnboarding(@AuthenticationPrincipal UserDetailsImpl user, @PathVariable UUID cityId, @RequestBody @Valid @Valid UserCityPutRequest request)
      Adds or updates a user's city during onboarding.
      Parameters:
      user - The authenticated user.
      cityId - The ID of the city.
      request - The put request.
      Returns:
      The updated user city container.
    • deleteUserCity

      @DeleteMapping("/cities/{cityId}") @ResponseStatus(NO_CONTENT) public void deleteUserCity(@AuthenticationPrincipal UserDetailsImpl user, @PathVariable UUID cityId)
      Deletes a user's city.
      Parameters:
      user - The authenticated user.
      cityId - The ID of the city.
    • deleteFestivalUser

      @DeleteMapping("/festivals/{festivalId}") @ResponseStatus(NO_CONTENT) public void deleteFestivalUser(@AuthenticationPrincipal UserDetailsImpl user, @PathVariable UUID festivalId)
      Deletes a user's festival.
      Parameters:
      user - The authenticated user.
      festivalId - The ID of the festival.
    • getUserCities

      @GetMapping(value="/cities", produces="application/json") @ResponseBody public UserCitiesResponse getUserCities(@AuthenticationPrincipal UserDetailsImpl user)
      Gets the user's cities.
      Parameters:
      user - The authenticated user.
      Returns:
      A response containing the user's cities.
    • getUserCitiesAndFestivals

      @GetMapping(value="/locations", produces="application/json") @ResponseBody public UserCitiesFestivalsResponse getUserCitiesAndFestivals(@AuthenticationPrincipal UserDetailsImpl user)
      Gets the user's cities and festivals.
      Parameters:
      user - The authenticated user.
      Returns:
      A response containing the user's cities and festivals.
    • getUserCity

      @GetMapping(value="/cities/{cityId}", produces="application/json") @ResponseBody public UserCityContainer getUserCity(@AuthenticationPrincipal UserDetailsImpl user, @PathVariable UUID cityId)
      Gets a user's city.
      Parameters:
      user - The authenticated user.
      cityId - The ID of the city.
      Returns:
      The user city container.
    • getNearestUserCity

      @Deprecated @GetMapping(value="/cities/nearest", produces="application/json") @ResponseBody public UserNearestCities getNearestUserCity(jakarta.servlet.http.HttpServletRequest request)
      Deprecated.
      This endpoint is deprecated.
      Gets the nearest cities to the user's location.
      Parameters:
      request - The HTTP servlet request.
      Returns:
      A response containing the nearest cities.
    • deleteUser

      @DeleteMapping("") @ResponseStatus(NO_CONTENT) public void deleteUser(@AuthenticationPrincipal UserDetailsImpl user)
      Deletes the authenticated user's account.
      Parameters:
      user - The authenticated user.
    • patchSelf

      @PatchMapping(value="", produces="application/json") @ResponseBody public UserDetailsResponse patchSelf(@AuthenticationPrincipal UserDetailsImpl user, @Valid @RequestBody @Valid UserPatchRequest request)
      Patches the authenticated user's information.
      Parameters:
      user - The authenticated user.
      request - The patch request.
      Returns:
      The updated user details.
    • getUserSeeds

      @GetMapping(value="/seeds", produces="application/json") @ResponseBody public List<SeedArtistResponse> getUserSeeds(@AuthenticationPrincipal UserDetailsImpl user)
      Gets the authenticated user's seed artists.
      Parameters:
      user - The authenticated user.
      Returns:
      A list of seed artist responses.
    • getUserSeedsAll

      @GetMapping(value="/seeds/all", produces="application/json") @ResponseBody public List<SeedArtistResponse> getUserSeedsAll(@AuthenticationPrincipal UserDetailsImpl user)
      Gets all of the authenticated user's seed artists, including blacklisted ones.
      Parameters:
      user - The authenticated user.
      Returns:
      A list of seed artist responses.
    • putUserSeeds

      @PutMapping(value="/seeds", produces="application/json") @ResponseBody public List<SeedArtistResponse> putUserSeeds(@AuthenticationPrincipal UserDetailsImpl user, @Valid @RequestBody @Valid UserSeedsPutRequest request)
      Sets the user's seed artists.
      Parameters:
      user - The authenticated user.
      request - The request containing the list of seed artists.
      Returns:
      A list of the updated seed artist responses.
    • addIndividualSeed

      @PutMapping("/seeds/{seedId}") @ResponseStatus(NO_CONTENT) public void addIndividualSeed(@AuthenticationPrincipal UserDetailsImpl user, @PathVariable UUID seedId)
      Adds an individual seed artist for the user.
      Parameters:
      user - The authenticated user.
      seedId - The ID of the seed artist to add.
    • blacklistSeed

      @DeleteMapping("/seeds/{seedId}") @ResponseStatus(NO_CONTENT) public void blacklistSeed(@AuthenticationPrincipal UserDetailsImpl user, @PathVariable UUID seedId)
      Blacklists a seed artist for the user.
      Parameters:
      user - The authenticated user.
      seedId - The ID of the seed artist to blacklist.
    • unBlacklistSeed

      @PostMapping("/seeds/{seedId}") @ResponseStatus(NO_CONTENT) public void unBlacklistSeed(@AuthenticationPrincipal UserDetailsImpl user, @PathVariable UUID seedId)
      Un-blacklists a seed artist for the user.
      Parameters:
      user - The authenticated user.
      seedId - The ID of the seed artist to un-blacklist.
    • getArtistRecommendations

      @GetMapping(value="/cities/{cityId}/artist-recommendations", produces="application/json") @ResponseBody public List<RecommendedArtistDto> getArtistRecommendations(@AuthenticationPrincipal UserDetailsImpl user, @PathVariable UUID cityId)
      Gets artist recommendations for the user in a city.
      Parameters:
      user - The authenticated user.
      cityId - The ID of the city.
      Returns:
      A list of recommended artist DTOs.
    • getEventRecommendations

      @PostMapping(value="/cities/{cityId}/event-recommendations", produces="application/json") @ResponseBody public List<RecommendedEventDto> getEventRecommendations(@AuthenticationPrincipal UserDetailsImpl user, @PathVariable UUID cityId, @RequestBody EventRecRequest req)
      Gets event recommendations for the user in a city.
      Parameters:
      user - The authenticated user.
      cityId - The ID of the city.
      req - The event recommendation request.
      Returns:
      A list of recommended event DTOs.
    • getFestivalArtistRecommendations

      @PostMapping(value="/festivals/{festivalId}/artist-recommendations", produces="application/json") @ResponseBody public List<RecommendedFestivalArtistDto> getFestivalArtistRecommendations(@AuthenticationPrincipal UserDetailsImpl user, @PathVariable UUID festivalId, @RequestBody @Nullable FestivalArtistFilterRequest req)
      Gets artist recommendations for a festival.
      Parameters:
      user - The authenticated user.
      festivalId - The ID of the festival.
      req - The filter request.
      Returns:
      A list of recommended festival artist DTOs.
    • putUserFestival

      @PutMapping(value="/festivals/{festivalId}", produces="application/json") @ResponseBody public FestivalResponse putUserFestival(@AuthenticationPrincipal UserDetailsImpl user, @PathVariable UUID festivalId)
      Adds a festival to the user's list of festivals.
      Parameters:
      user - The authenticated user.
      festivalId - The ID of the festival.
      Returns:
      The festival response.
    • getCityFestivalRecommendations

      @GetMapping(value="/cities/{cityId}/festival-recommendations", produces="application/json") @ResponseBody public List<RecommendedCityFestivalDto> getCityFestivalRecommendations(@AuthenticationPrincipal UserDetailsImpl user, @PathVariable UUID cityId)
      Gets festival recommendations for a city.
      Parameters:
      user - The authenticated user.
      cityId - The ID of the city.
      Returns:
      A list of recommended city festival DTOs.
    • getOrCreateCityPlaylist

      @PostMapping(value="/cities/{cityId}/playlist", produces="application/json") @ResponseBody public PlaylistDto getOrCreateCityPlaylist(@AuthenticationPrincipal UserDetailsImpl user, @PathVariable UUID cityId)
      Gets or creates a playlist for a city.
      Parameters:
      user - The authenticated user.
      cityId - The ID of the city.
      Returns:
      The playlist DTO.
    • getOrCreateFestivalPlaylist

      @PostMapping(value="/festivals/{festivalId}/playlist", produces="application/json") @ResponseBody public PlaylistDto getOrCreateFestivalPlaylist(@AuthenticationPrincipal UserDetailsImpl user, @PathVariable UUID festivalId)
      Gets or creates a playlist for a festival.
      Parameters:
      user - The authenticated user.
      festivalId - The ID of the festival.
      Returns:
      The playlist DTO.
    • getPlaylist

      @PostMapping(value="/cities/{cityId}/playlist-async", produces="application/json") @ResponseBody public PlaylistDto getPlaylist(@AuthenticationPrincipal UserDetailsImpl user, @PathVariable UUID cityId)
      Gets a playlist for a city asynchronously.
      Parameters:
      user - The authenticated user.
      cityId - The ID of the city.
      Returns:
      The playlist DTO.
    • addFavoriteArtist

      @PutMapping("/artists/{artistId}/favorite") @ResponseStatus(NO_CONTENT) public void addFavoriteArtist(@AuthenticationPrincipal UserDetailsImpl user, @PathVariable UUID artistId)
      Adds an artist to the user's favorites.
      Parameters:
      user - The authenticated user.
      artistId - The ID of the artist.
    • removeFavoriteArtist

      @DeleteMapping("/artists/{artistId}/favorite") @ResponseStatus(NO_CONTENT) public void removeFavoriteArtist(@AuthenticationPrincipal UserDetailsImpl user, @PathVariable UUID artistId)
      Removes an artist from the user's favorites.
      Parameters:
      user - The authenticated user.
      artistId - The ID of the artist.
    • getFavoriteArtists

      @GetMapping(value="/artists/favorites", produces="application/json") @ResponseBody public org.springframework.data.domain.Page<BasicArtistResponse> getFavoriteArtists(@AuthenticationPrincipal UserDetailsImpl user, @Valid @Valid UserFavoriteQuery query)
      Gets the user's favorite artists.
      Parameters:
      user - The authenticated user.
      query - The query for favorite artists.
      Returns:
      A page of basic artist responses.
    • addFavoriteEvent

      @PutMapping("/events/{eventId}/favorite") @ResponseStatus(NO_CONTENT) public void addFavoriteEvent(@AuthenticationPrincipal UserDetailsImpl user, @PathVariable UUID eventId)
      Adds an event to the user's favorites.
      Parameters:
      user - The authenticated user.
      eventId - The ID of the event.
    • removeFavoriteEvent

      @DeleteMapping("/events/{eventId}/favorite") @ResponseStatus(NO_CONTENT) public void removeFavoriteEvent(@AuthenticationPrincipal UserDetailsImpl user, @PathVariable UUID eventId)
      Removes an event from the user's favorites.
      Parameters:
      user - The authenticated user.
      eventId - The ID of the event.
    • rateEvent

      @PutMapping("/events/{eventId}/rate") @ResponseStatus(NO_CONTENT) public void rateEvent(@AuthenticationPrincipal UserDetailsImpl user, @PathVariable UUID eventId, @Valid @Valid UserFavoriteEventRatingQuery rating)
      Rates an event.
      Parameters:
      user - The authenticated user.
      eventId - The ID of the event.
      rating - The rating.
    • getFavoriteEvents

      @GetMapping(value="/events/favorites", produces="application/json") @ResponseBody public org.springframework.data.domain.Page<UserFavoriteEventResponse> getFavoriteEvents(@AuthenticationPrincipal UserDetailsImpl user, @Valid @Valid UserFavoriteQuery query)
      Gets the user's favorite events.
      Parameters:
      user - The authenticated user.
      query - The query for favorite events.
      Returns:
      A page of user favorite event responses.
    • getFavoriteEventsPrevious

      @GetMapping(value="/events/favorites/previous", produces="application/json") @ResponseBody public org.springframework.data.domain.Page<UserFavoriteEventResponse> getFavoriteEventsPrevious(@AuthenticationPrincipal UserDetailsImpl user, @Valid @Valid UserFavoriteQuery query)
      Gets the user's previous favorite events.
      Parameters:
      user - The authenticated user.
      query - The query for favorite events.
      Returns:
      A page of user favorite event responses.
    • getFavoriteEventsUpcoming

      @GetMapping(value="/events/favorites/upcoming", produces="application/json") @ResponseBody public org.springframework.data.domain.Page<UserFavoriteEventResponse> getFavoriteEventsUpcoming(@AuthenticationPrincipal UserDetailsImpl user, @Valid @Valid UserFavoriteQuery query)
      Gets the user's upcoming favorite events.
      Parameters:
      user - The authenticated user.
      query - The query for favorite events.
      Returns:
      A page of user favorite event responses.
    • addFavoriteVenue

      @PutMapping("/venues/{venueId}/favorite") @ResponseStatus(NO_CONTENT) public void addFavoriteVenue(@AuthenticationPrincipal UserDetailsImpl user, @PathVariable UUID venueId)
      Adds a venue to the user's favorites.
      Parameters:
      user - The authenticated user.
      venueId - The ID of the venue.
    • removeFavoriteVenue

      @DeleteMapping("/venues/{venueId}/favorite") @ResponseStatus(NO_CONTENT) public void removeFavoriteVenue(@AuthenticationPrincipal UserDetailsImpl user, @PathVariable UUID venueId)
      Removes a venue from the user's favorites.
      Parameters:
      user - The authenticated user.
      venueId - The ID of the venue.
    • getFavoriteVenues

      @GetMapping(value="/venues/favorites", produces="application/json") @ResponseBody public org.springframework.data.domain.Page<VenueResponse> getFavoriteVenues(@AuthenticationPrincipal UserDetailsImpl user, @Valid @Valid UserFavoriteQuery query)
      Gets the user's favorite venues.
      Parameters:
      user - The authenticated user.
      query - The query for favorite venues.
      Returns:
      A page of venue responses.
    • getSearchHistory

      @GetMapping("/search-history") public List<String> getSearchHistory(@AuthenticationPrincipal UserDetailsImpl user)
      Gets the user's search history.
      Parameters:
      user - The authenticated user.
      Returns:
      A list of search queries.
    • deleteSearchHistory

      @DeleteMapping("/search-history") @ResponseStatus(NO_CONTENT) public void deleteSearchHistory(@AuthenticationPrincipal UserDetailsImpl user)
      Deletes the user's search history.
      Parameters:
      user - The authenticated user.
    • getRecentlyViewed

      @GetMapping("/recently-viewed") public UserHistoryResponse getRecentlyViewed(@AuthenticationPrincipal UserDetailsImpl user, @Valid @Valid PageOptions pageOptions)
      Gets the user's recently viewed items.
      Parameters:
      user - The authenticated user.
      pageOptions - The pagination options.
      Returns:
      A response containing the user's history.
    • deleteRecentlyViewed

      @DeleteMapping("/recently-viewed") @ResponseStatus(NO_CONTENT) public void deleteRecentlyViewed(@AuthenticationPrincipal UserDetailsImpl user)
      Deletes the user's recently viewed items.
      Parameters:
      user - The authenticated user.
    • submitFeedback

      @PutMapping("/feedback") @ResponseStatus(NO_CONTENT) public void submitFeedback(@AuthenticationPrincipal UserDetailsImpl user, @RequestBody @Valid @Valid UserFeedbackRequest request)
      Submits feedback from the user.
      Parameters:
      user - The authenticated user.
      request - The feedback request.
    • canRecommend

      @GetMapping("/can-recommend") @ResponseStatus(OK) public void canRecommend(@AuthenticationPrincipal UserDetailsImpl user)
      Checks if recommendations can be generated for the user.
      Parameters:
      user - The authenticated user.