mirror of
https://github.com/sphildreth/roadie
synced 2025-02-16 13:08:25 +00:00
Performance and standards improvements via Roslynator
This commit is contained in:
parent
85dd7352c5
commit
bc227db418
8 changed files with 236 additions and 226 deletions
|
@ -39,24 +39,28 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(404)]
|
||||
public async Task<IActionResult> Get(Guid id, string inc = null)
|
||||
{
|
||||
var user = await CurrentUserModel();
|
||||
var user = await CurrentUserModel().ConfigureAwait(false);
|
||||
var result =
|
||||
await ArtistService.ById(user, id, (inc ?? models.Artist.DefaultIncludes).ToLower().Split(","));
|
||||
if (result == null || result.IsNotFoundResult) return NotFound();
|
||||
await ArtistService.ById(user, id, (inc ?? models.Artist.DefaultIncludes).ToLower().Split(",")).ConfigureAwait(false);
|
||||
if (result?.IsNotFoundResult != false)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
if (!result.IsSuccess) return StatusCode((int)HttpStatusCode.InternalServerError);
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> List([FromQuery] PagedRequest request, string inc, bool? doRandomize = false)
|
||||
public async Task<IActionResult> List([FromQuery] PagedRequest request, bool? doRandomize = false)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await ArtistService.List(await CurrentUserModel(),
|
||||
PagedResult<models.ArtistList> result = await ArtistService.List(await CurrentUserModel().ConfigureAwait(false),
|
||||
request,
|
||||
doRandomize ?? false,
|
||||
false);
|
||||
false).ConfigureAwait(false);
|
||||
if (!result.IsSuccess) return StatusCode((int)HttpStatusCode.InternalServerError);
|
||||
return Ok(result);
|
||||
}
|
||||
|
@ -78,9 +82,12 @@ namespace Roadie.Api.Controllers
|
|||
[Authorize(Policy = "Editor")]
|
||||
public async Task<IActionResult> MergeArtists(Guid artistToMergeId, Guid artistToMergeIntoId)
|
||||
{
|
||||
var result =
|
||||
await ArtistService.MergeArtists(await UserManager.GetUserAsync(User), artistToMergeId, artistToMergeIntoId);
|
||||
if (result == null || result.IsNotFoundResult) return NotFound();
|
||||
var result = await ArtistService.MergeArtists(await UserManager.GetUserAsync(User).ConfigureAwait(false), artistToMergeId, artistToMergeIntoId).ConfigureAwait(false);
|
||||
if (result?.IsNotFoundResult != false)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
if (!result.IsSuccess)
|
||||
{
|
||||
if (result.IsAccessDeniedResult)
|
||||
|
@ -103,8 +110,8 @@ namespace Roadie.Api.Controllers
|
|||
public async Task<IActionResult> SetArtistImageByUrl(Guid id, string imageUrl)
|
||||
{
|
||||
var result =
|
||||
await ArtistService.SetReleaseImageByUrl(await UserManager.GetUserAsync(User), id, HttpUtility.UrlDecode(imageUrl));
|
||||
if (result == null || result.IsNotFoundResult) return NotFound();
|
||||
await ArtistService.SetReleaseImageByUrl(await UserManager.GetUserAsync(User).ConfigureAwait(false), id, HttpUtility.UrlDecode(imageUrl)).ConfigureAwait(false);
|
||||
if (result?.IsNotFoundResult != false) return NotFound();
|
||||
if (!result.IsSuccess)
|
||||
{
|
||||
if (result.IsAccessDeniedResult)
|
||||
|
@ -130,8 +137,8 @@ namespace Roadie.Api.Controllers
|
|||
{
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
var result = await ArtistService.UpdateArtist(await UserManager.GetUserAsync(User), artist);
|
||||
if (result == null || result.IsNotFoundResult)
|
||||
var result = await ArtistService.UpdateArtist(await UserManager.GetUserAsync(User).ConfigureAwait(false), artist).ConfigureAwait(false);
|
||||
if (result?.IsNotFoundResult != false)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
@ -156,8 +163,12 @@ namespace Roadie.Api.Controllers
|
|||
[Authorize(Policy = "Editor")]
|
||||
public async Task<IActionResult> UploadImage(Guid id, IFormFile file)
|
||||
{
|
||||
var result = await ArtistService.UploadArtistImage(await UserManager.GetUserAsync(User), id, file);
|
||||
if (result == null || result.IsNotFoundResult) return NotFound();
|
||||
var result = await ArtistService.UploadArtistImage(await UserManager.GetUserAsync(User).ConfigureAwait(false), id, file).ConfigureAwait(false);
|
||||
if (result?.IsNotFoundResult != false)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
if (!result.IsSuccess)
|
||||
{
|
||||
if (result.IsAccessDeniedResult)
|
||||
|
|
|
@ -33,8 +33,8 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(404)]
|
||||
public async Task<IActionResult> ArtistImage(Guid id, int? width, int? height)
|
||||
{
|
||||
var result = await ImageService.ArtistImage(id, width ?? RoadieSettings.ThumbnailImageSize.Width, height ?? RoadieSettings.ThumbnailImageSize.Height);
|
||||
if (result == null || result.IsNotFoundResult)
|
||||
var result = await ImageService.ArtistImage(id, width ?? RoadieSettings.ThumbnailImageSize.Width, height ?? RoadieSettings.ThumbnailImageSize.Height).ConfigureAwait(false);
|
||||
if (result?.IsNotFoundResult != false)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
@ -50,8 +50,8 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(404)]
|
||||
public async Task<IActionResult> ArtistSecondaryImage(Guid id, int imageId, int? width, int? height)
|
||||
{
|
||||
var result = await ImageService.ArtistSecondaryImage(id, imageId, width, height);
|
||||
if (result == null || result.IsNotFoundResult)
|
||||
var result = await ImageService.ArtistSecondaryImage(id, imageId, width, height).ConfigureAwait(false);
|
||||
if (result?.IsNotFoundResult != false)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
@ -67,8 +67,8 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(404)]
|
||||
public async Task<IActionResult> CollectionImage(Guid id, int? width, int? height)
|
||||
{
|
||||
var result = await ImageService.CollectionImage(id, width ?? RoadieSettings.ThumbnailImageSize.Width, height ?? RoadieSettings.ThumbnailImageSize.Height);
|
||||
if (result == null || result.IsNotFoundResult)
|
||||
var result = await ImageService.CollectionImage(id, width ?? RoadieSettings.ThumbnailImageSize.Width, height ?? RoadieSettings.ThumbnailImageSize.Height).ConfigureAwait(false);
|
||||
if (result?.IsNotFoundResult != false)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
@ -84,8 +84,8 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(404)]
|
||||
public async Task<IActionResult> LabelImage(Guid id, int? width, int? height)
|
||||
{
|
||||
var result = await ImageService.LabelImage(id, width ?? RoadieSettings.ThumbnailImageSize.Width, height ?? RoadieSettings.ThumbnailImageSize.Height);
|
||||
if (result == null || result.IsNotFoundResult)
|
||||
var result = await ImageService.LabelImage(id, width ?? RoadieSettings.ThumbnailImageSize.Width, height ?? RoadieSettings.ThumbnailImageSize.Height).ConfigureAwait(false);
|
||||
if (result?.IsNotFoundResult != false)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
@ -101,8 +101,8 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(404)]
|
||||
public async Task<IActionResult> GenreImage(Guid id, int? width, int? height)
|
||||
{
|
||||
var result = await ImageService.GenreImage(id, width ?? RoadieSettings.ThumbnailImageSize.Width, height ?? RoadieSettings.ThumbnailImageSize.Height);
|
||||
if (result == null || result.IsNotFoundResult)
|
||||
var result = await ImageService.GenreImage(id, width ?? RoadieSettings.ThumbnailImageSize.Width, height ?? RoadieSettings.ThumbnailImageSize.Height).ConfigureAwait(false);
|
||||
if (result?.IsNotFoundResult != false)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
@ -118,8 +118,8 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(404)]
|
||||
public async Task<IActionResult> PlaylistImage(Guid id, int? width, int? height)
|
||||
{
|
||||
var result = await ImageService.PlaylistImage(id, width ?? RoadieSettings.ThumbnailImageSize.Width, height ?? RoadieSettings.ThumbnailImageSize.Height);
|
||||
if (result == null || result.IsNotFoundResult)
|
||||
var result = await ImageService.PlaylistImage(id, width ?? RoadieSettings.ThumbnailImageSize.Width, height ?? RoadieSettings.ThumbnailImageSize.Height).ConfigureAwait(false);
|
||||
if (result?.IsNotFoundResult != false)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
@ -135,8 +135,8 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(404)]
|
||||
public async Task<IActionResult> ReleaseImage(Guid id, int? width, int? height)
|
||||
{
|
||||
var result = await ImageService.ReleaseImage(id, width ?? RoadieSettings.ThumbnailImageSize.Width, height ?? RoadieSettings.ThumbnailImageSize.Height);
|
||||
if (result == null || result.IsNotFoundResult)
|
||||
var result = await ImageService.ReleaseImage(id, width ?? RoadieSettings.ThumbnailImageSize.Width, height ?? RoadieSettings.ThumbnailImageSize.Height).ConfigureAwait(false);
|
||||
if (result?.IsNotFoundResult != false)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
@ -152,8 +152,8 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(404)]
|
||||
public async Task<IActionResult> ReleaseSecondaryImage(Guid id, int imageId, int? width, int? height)
|
||||
{
|
||||
var result = await ImageService.ReleaseSecondaryImage(id, imageId, width ?? RoadieSettings.MaximumImageSize.Width, height ?? RoadieSettings.MaximumImageSize.Height);
|
||||
if (result == null || result.IsNotFoundResult)
|
||||
var result = await ImageService.ReleaseSecondaryImage(id, imageId, width ?? RoadieSettings.MaximumImageSize.Width, height ?? RoadieSettings.MaximumImageSize.Height).ConfigureAwait(false);
|
||||
if (result?.IsNotFoundResult != false)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
@ -169,8 +169,8 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(404)]
|
||||
public async Task<IActionResult> SearchForArtistImage(string query, int? resultsCount)
|
||||
{
|
||||
var result = await ImageService.Search(query, resultsCount ?? 10);
|
||||
if (result == null || result.IsNotFoundResult)
|
||||
var result = await ImageService.Search(query, resultsCount ?? 10).ConfigureAwait(false);
|
||||
if (result?.IsNotFoundResult != false)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
@ -186,8 +186,8 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(404)]
|
||||
public async Task<IActionResult> SearchForLabelImage(string query, int? resultsCount)
|
||||
{
|
||||
var result = await ImageService.Search(query, resultsCount ?? 10);
|
||||
if (result == null || result.IsNotFoundResult)
|
||||
var result = await ImageService.Search(query, resultsCount ?? 10).ConfigureAwait(false);
|
||||
if (result?.IsNotFoundResult != false)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
@ -203,8 +203,8 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(404)]
|
||||
public async Task<IActionResult> SearchForGenreImage(string query, int? resultsCount)
|
||||
{
|
||||
var result = await ImageService.Search(query, resultsCount ?? 10);
|
||||
if (result == null || result.IsNotFoundResult) return NotFound();
|
||||
var result = await ImageService.Search(query, resultsCount ?? 10).ConfigureAwait(false);
|
||||
if (result?.IsNotFoundResult != false) return NotFound();
|
||||
if (!result.IsSuccess) return StatusCode((int)HttpStatusCode.InternalServerError);
|
||||
return Ok(result);
|
||||
}
|
||||
|
@ -214,8 +214,8 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(404)]
|
||||
public async Task<IActionResult> SearchForReleaseCover(string query, int? resultsCount)
|
||||
{
|
||||
var result = await ImageService.Search(query, resultsCount ?? 10);
|
||||
if (result == null || result.IsNotFoundResult) return NotFound();
|
||||
var result = await ImageService.Search(query, resultsCount ?? 10).ConfigureAwait(false);
|
||||
if (result?.IsNotFoundResult != false) return NotFound();
|
||||
if (!result.IsSuccess) return StatusCode((int)HttpStatusCode.InternalServerError);
|
||||
return Ok(result);
|
||||
}
|
||||
|
@ -225,8 +225,8 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(404)]
|
||||
public async Task<IActionResult> TrackImage(Guid id, int? width, int? height)
|
||||
{
|
||||
var result = await ImageService.TrackImage(id, width ?? RoadieSettings.ThumbnailImageSize.Width, height ?? RoadieSettings.ThumbnailImageSize.Height);
|
||||
if (result == null || result.IsNotFoundResult)
|
||||
var result = await ImageService.TrackImage(id, width ?? RoadieSettings.ThumbnailImageSize.Width, height ?? RoadieSettings.ThumbnailImageSize.Height).ConfigureAwait(false);
|
||||
if (result?.IsNotFoundResult != false)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
@ -247,8 +247,8 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(404)]
|
||||
public async Task<IActionResult> UserImage(Guid id, int? width, int? height)
|
||||
{
|
||||
var result = await ImageService.UserImage(id, width ?? RoadieSettings.ThumbnailImageSize.Width, height ?? RoadieSettings.ThumbnailImageSize.Height);
|
||||
if (result == null || result.IsNotFoundResult)
|
||||
var result = await ImageService.UserImage(id, width ?? RoadieSettings.ThumbnailImageSize.Width, height ?? RoadieSettings.ThumbnailImageSize.Height).ConfigureAwait(false);
|
||||
if (result?.IsNotFoundResult != false)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> PlayActivity([FromQuery] PagedRequest request)
|
||||
{
|
||||
var result = await PlayActivityService.List(request);
|
||||
var result = await PlayActivityService.List(request).ConfigureAwait(false);
|
||||
if (!result.IsSuccess) return StatusCode((int)HttpStatusCode.InternalServerError);
|
||||
return Ok(result);
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ namespace Roadie.Api.Controllers
|
|||
var user = UserManager.Users.FirstOrDefault(x => x.RoadieId == userId);
|
||||
if (user == null) return NotFound();
|
||||
var result = await PlayActivityService.List(request,
|
||||
UserModelForUser(user));
|
||||
UserModelForUser(user)).ConfigureAwait(false);
|
||||
|
||||
if (!result.IsSuccess) return StatusCode((int)HttpStatusCode.InternalServerError);
|
||||
return Ok(result);
|
||||
|
|
|
@ -42,9 +42,9 @@ namespace Roadie.Api.Controllers
|
|||
[HttpGet("release/m3u/{id}.{m3u?}")]
|
||||
public async Task<FileResult> M3uForRelease(Guid id)
|
||||
{
|
||||
var user = await CurrentUserModel();
|
||||
var release = await ReleaseService.ById(user, id, new string[1] { "tracks" });
|
||||
if (release == null || release.IsNotFoundResult) Response.StatusCode = (int)HttpStatusCode.NotFound;
|
||||
var user = await CurrentUserModel().ConfigureAwait(false);
|
||||
var release = await ReleaseService.ById(user, id, new string[1] { "tracks" }).ConfigureAwait(false);
|
||||
if (release?.IsNotFoundResult != false) Response.StatusCode = (int)HttpStatusCode.NotFound;
|
||||
var m3u = M3uHelper.M3uContentForTracks(release.Data.Medias.SelectMany(x => x.Tracks));
|
||||
return File(Encoding.Default.GetBytes(m3u), "audio/mpeg-url");
|
||||
}
|
||||
|
@ -52,11 +52,11 @@ namespace Roadie.Api.Controllers
|
|||
[HttpGet("track/m3u/{id}.{m3u?}")]
|
||||
public async Task<FileResult> M3uForTrack(Guid id)
|
||||
{
|
||||
var user = await CurrentUserModel();
|
||||
var track = await TrackService.ById(user, id, null);
|
||||
if (track == null || track.IsNotFoundResult) Response.StatusCode = (int)HttpStatusCode.NotFound;
|
||||
var release = await ReleaseService.ById(user, track.Data.Release.Id, new string[1] { "tracks" });
|
||||
if (release == null || release.IsNotFoundResult) Response.StatusCode = (int)HttpStatusCode.NotFound;
|
||||
var user = await CurrentUserModel().ConfigureAwait(false);
|
||||
var track = await TrackService.ById(user, id, null).ConfigureAwait(false);
|
||||
if (track?.IsNotFoundResult != false) Response.StatusCode = (int)HttpStatusCode.NotFound;
|
||||
var release = await ReleaseService.ById(user, track.Data.Release.Id, new string[1] { "tracks" }).ConfigureAwait(false);
|
||||
if (release?.IsNotFoundResult != false) Response.StatusCode = (int)HttpStatusCode.NotFound;
|
||||
var m3u = M3uHelper.M3uContentForTracks(
|
||||
release.Data.Medias.SelectMany(x => x.Tracks).Where(x => x.Id == id));
|
||||
return File(Encoding.Default.GetBytes(m3u), "audio/mpeg-url");
|
||||
|
@ -71,13 +71,13 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(404)]
|
||||
public async Task<IActionResult> Scrobble(Guid id, string startedPlaying, bool isRandom)
|
||||
{
|
||||
var result = await PlayActivityService.Scrobble(await CurrentUserModel(), new ScrobbleInfo
|
||||
var result = await PlayActivityService.Scrobble(await CurrentUserModel().ConfigureAwait(false), new ScrobbleInfo
|
||||
{
|
||||
TrackId = id,
|
||||
TimePlayed = SafeParser.ToDateTime(startedPlaying) ?? DateTime.UtcNow,
|
||||
IsRandomizedScrobble = isRandom
|
||||
});
|
||||
if (result == null || result.IsNotFoundResult) return NotFound();
|
||||
}).ConfigureAwait(false);
|
||||
if (result?.IsNotFoundResult != false) return NotFound();
|
||||
if (!result.IsSuccess) return StatusCode((int)HttpStatusCode.InternalServerError);
|
||||
return Ok(result);
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ namespace Roadie.Api.Controllers
|
|||
{
|
||||
return StatusCode((int)HttpStatusCode.Unauthorized);
|
||||
}
|
||||
return await base.StreamTrack(id, TrackService, PlayActivityService, UserModelForUser(user));
|
||||
return await StreamTrack(id, TrackService, PlayActivityService, UserModelForUser(user)).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -30,7 +30,6 @@ namespace Roadie.Api.Controllers
|
|||
: base(cacheManager, roadieSettings, userManager)
|
||||
{
|
||||
Logger = logger;
|
||||
;
|
||||
ReleaseService = releaseService;
|
||||
}
|
||||
|
||||
|
@ -39,8 +38,8 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(404)]
|
||||
public async Task<IActionResult> Get(Guid id, string inc = null)
|
||||
{
|
||||
var result = await ReleaseService.ById(await CurrentUserModel(), id, (inc ?? Release.DefaultIncludes).ToLower().Split(","));
|
||||
if (result == null || result.IsNotFoundResult)
|
||||
var result = await ReleaseService.ById(await CurrentUserModel().ConfigureAwait(false), id, (inc ?? Release.DefaultIncludes).ToLower().Split(",")).ConfigureAwait(false);
|
||||
if (result?.IsNotFoundResult != false)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
@ -57,10 +56,10 @@ namespace Roadie.Api.Controllers
|
|||
{
|
||||
try
|
||||
{
|
||||
var result = await ReleaseService.List(await CurrentUserModel(),
|
||||
var result = await ReleaseService.List(await CurrentUserModel().ConfigureAwait(false),
|
||||
request,
|
||||
doRandomize ?? false,
|
||||
(inc ?? Release.DefaultListIncludes).ToLower().Split(","));
|
||||
(inc ?? Release.DefaultListIncludes).ToLower().Split(",")).ConfigureAwait(false);
|
||||
if (!result.IsSuccess) return StatusCode((int)HttpStatusCode.InternalServerError);
|
||||
return Ok(result);
|
||||
}
|
||||
|
@ -82,8 +81,8 @@ namespace Roadie.Api.Controllers
|
|||
[Authorize(Policy = "Editor")]
|
||||
public async Task<IActionResult> MergeReleases(Guid releaseToMergeId, Guid releaseToMergeIntoId, bool addAsMedia)
|
||||
{
|
||||
var result = await ReleaseService.MergeReleases(await UserManager.GetUserAsync(User), releaseToMergeId, releaseToMergeIntoId, addAsMedia);
|
||||
if (result == null || result.IsNotFoundResult) return NotFound();
|
||||
var result = await ReleaseService.MergeReleases(await UserManager.GetUserAsync(User).ConfigureAwait(false), releaseToMergeId, releaseToMergeIntoId, addAsMedia).ConfigureAwait(false);
|
||||
if (result?.IsNotFoundResult != false) return NotFound();
|
||||
if (!result.IsSuccess)
|
||||
{
|
||||
if (result.IsAccessDeniedResult)
|
||||
|
@ -105,8 +104,8 @@ namespace Roadie.Api.Controllers
|
|||
[Authorize(Policy = "Editor")]
|
||||
public async Task<IActionResult> SetReleaseImageByUrl(Guid id, string imageUrl)
|
||||
{
|
||||
var result = await ReleaseService.SetReleaseImageByUrl(await UserManager.GetUserAsync(User), id, HttpUtility.UrlDecode(imageUrl));
|
||||
if (result == null || result.IsNotFoundResult) return NotFound();
|
||||
var result = await ReleaseService.SetReleaseImageByUrl(await UserManager.GetUserAsync(User).ConfigureAwait(false), id, HttpUtility.UrlDecode(imageUrl)).ConfigureAwait(false);
|
||||
if (result?.IsNotFoundResult != false) return NotFound();
|
||||
if (!result.IsSuccess)
|
||||
{
|
||||
if (result.IsAccessDeniedResult)
|
||||
|
@ -132,8 +131,8 @@ namespace Roadie.Api.Controllers
|
|||
{
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
var result = await ReleaseService.UpdateRelease(await UserManager.GetUserAsync(User), release);
|
||||
if (result == null || result.IsNotFoundResult)
|
||||
var result = await ReleaseService.UpdateRelease(await UserManager.GetUserAsync(User).ConfigureAwait(false), release).ConfigureAwait(false);
|
||||
if (result?.IsNotFoundResult != false)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
@ -154,8 +153,8 @@ namespace Roadie.Api.Controllers
|
|||
[Authorize(Policy = "Editor")]
|
||||
public async Task<IActionResult> UploadImage(Guid id, IFormFile file)
|
||||
{
|
||||
var result = await ReleaseService.UploadReleaseImage(await UserManager.GetUserAsync(User), id, file);
|
||||
if (result == null || result.IsNotFoundResult) return NotFound();
|
||||
var result = await ReleaseService.UploadReleaseImage(await UserManager.GetUserAsync(User).ConfigureAwait(false), id, file).ConfigureAwait(false);
|
||||
if (result?.IsNotFoundResult != false) return NotFound();
|
||||
if (!result.IsSuccess)
|
||||
{
|
||||
if (result.IsAccessDeniedResult)
|
||||
|
|
|
@ -55,9 +55,9 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> AddChatMessage(SubsonicRequest request)
|
||||
{
|
||||
var authResult = await AuthenticateUser(request);
|
||||
var authResult = await AuthenticateUser(request).ConfigureAwait(false);
|
||||
if (authResult != null) return authResult;
|
||||
var result = await SubsonicService.AddChatMessage(request, SubsonicUser);
|
||||
var result = await SubsonicService.AddChatMessage(request, SubsonicUser).ConfigureAwait(false);
|
||||
return BuildResponse(request, result);
|
||||
}
|
||||
|
||||
|
@ -66,9 +66,9 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> CreateBookmark(SubsonicRequest request, int position, string comment)
|
||||
{
|
||||
var authResult = await AuthenticateUser(request);
|
||||
var authResult = await AuthenticateUser(request).ConfigureAwait(false);
|
||||
if (authResult != null) return authResult;
|
||||
var result = await SubsonicService.CreateBookmark(request, SubsonicUser, position, comment);
|
||||
var result = await SubsonicService.CreateBookmark(request, SubsonicUser, position, comment).ConfigureAwait(false);
|
||||
return BuildResponse(request, result);
|
||||
}
|
||||
|
||||
|
@ -78,9 +78,9 @@ namespace Roadie.Api.Controllers
|
|||
public async Task<IActionResult> CreatePlaylist(SubsonicRequest request, string playlistId, string name,
|
||||
string[] songId)
|
||||
{
|
||||
var authResult = await AuthenticateUser(request);
|
||||
var authResult = await AuthenticateUser(request).ConfigureAwait(false);
|
||||
if (authResult != null) return authResult;
|
||||
var result = await SubsonicService.CreatePlaylist(request, SubsonicUser, name, songId, playlistId);
|
||||
var result = await SubsonicService.CreatePlaylist(request, SubsonicUser, name, songId, playlistId).ConfigureAwait(false);
|
||||
return BuildResponse(request, result, "playlist");
|
||||
}
|
||||
|
||||
|
@ -89,9 +89,9 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> DeleteBookmark(SubsonicRequest request)
|
||||
{
|
||||
var authResult = await AuthenticateUser(request);
|
||||
var authResult = await AuthenticateUser(request).ConfigureAwait(false);
|
||||
if (authResult != null) return authResult;
|
||||
var result = await SubsonicService.DeleteBookmark(request, SubsonicUser);
|
||||
var result = await SubsonicService.DeleteBookmark(request, SubsonicUser).ConfigureAwait(false);
|
||||
return BuildResponse(request, result);
|
||||
}
|
||||
|
||||
|
@ -100,9 +100,9 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> DeletePlaylist(SubsonicRequest request)
|
||||
{
|
||||
var authResult = await AuthenticateUser(request);
|
||||
var authResult = await AuthenticateUser(request).ConfigureAwait(false);
|
||||
if (authResult != null) return authResult;
|
||||
var result = await SubsonicService.DeletePlaylist(request, SubsonicUser);
|
||||
var result = await SubsonicService.DeletePlaylist(request, SubsonicUser).ConfigureAwait(false);
|
||||
return BuildResponse(request, result);
|
||||
}
|
||||
|
||||
|
@ -111,15 +111,15 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> Download(SubsonicRequest request)
|
||||
{
|
||||
var authResult = await AuthenticateUser(request);
|
||||
var authResult = await AuthenticateUser(request).ConfigureAwait(false);
|
||||
if (authResult != null) return Unauthorized();
|
||||
var trackId = request.TrackId;
|
||||
if (trackId != null)
|
||||
return await base.StreamTrack(trackId.Value, TrackService, PlayActivityService, SubsonicUser);
|
||||
return await StreamTrack(trackId.Value, TrackService, PlayActivityService, SubsonicUser).ConfigureAwait(false);
|
||||
var releaseId = request.ReleaseId;
|
||||
if (releaseId != null)
|
||||
{
|
||||
var releaseZip = await ReleaseService.ReleaseZipped(SubsonicUser, releaseId.Value);
|
||||
var releaseZip = await ReleaseService.ReleaseZipped(SubsonicUser, releaseId.Value).ConfigureAwait(false);
|
||||
if (!releaseZip.IsSuccess) return NotFound("Unknown Release id");
|
||||
return File(releaseZip.Data, "application/zip", (string)releaseZip.AdditionalData["ZipFileName"]);
|
||||
}
|
||||
|
@ -132,9 +132,9 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> GetAlbum(SubsonicRequest request)
|
||||
{
|
||||
var authResult = await AuthenticateUser(request);
|
||||
var authResult = await AuthenticateUser(request).ConfigureAwait(false);
|
||||
if (authResult != null) return authResult;
|
||||
var result = await SubsonicService.GetAlbum(request, SubsonicUser);
|
||||
var result = await SubsonicService.GetAlbum(request, SubsonicUser).ConfigureAwait(false);
|
||||
return BuildResponse(request, result, "album");
|
||||
}
|
||||
|
||||
|
@ -143,9 +143,9 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> GetAlbumInfo(SubsonicRequest request)
|
||||
{
|
||||
var authResult = await AuthenticateUser(request);
|
||||
var authResult = await AuthenticateUser(request).ConfigureAwait(false);
|
||||
if (authResult != null) return authResult;
|
||||
var result = await SubsonicService.GetAlbumInfo(request, SubsonicUser, AlbumInfoVersion.One);
|
||||
var result = await SubsonicService.GetAlbumInfo(request, SubsonicUser, AlbumInfoVersion.One).ConfigureAwait(false);
|
||||
return BuildResponse(request, result, "albumInfo");
|
||||
}
|
||||
|
||||
|
@ -154,9 +154,9 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> GetAlbumInfo2(SubsonicRequest request)
|
||||
{
|
||||
var authResult = await AuthenticateUser(request);
|
||||
var authResult = await AuthenticateUser(request).ConfigureAwait(false);
|
||||
if (authResult != null) return authResult;
|
||||
var result = await SubsonicService.GetAlbumInfo(request, SubsonicUser, AlbumInfoVersion.Two);
|
||||
var result = await SubsonicService.GetAlbumInfo(request, SubsonicUser, AlbumInfoVersion.Two).ConfigureAwait(false);
|
||||
return BuildResponse(request, result, "albumInfo");
|
||||
}
|
||||
|
||||
|
@ -165,9 +165,9 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> GetAlbumList(SubsonicRequest request)
|
||||
{
|
||||
var authResult = await AuthenticateUser(request);
|
||||
var authResult = await AuthenticateUser(request).ConfigureAwait(false);
|
||||
if (authResult != null) return authResult;
|
||||
var result = await SubsonicService.GetAlbumList(request, SubsonicUser, AlbumListVersions.One);
|
||||
var result = await SubsonicService.GetAlbumList(request, SubsonicUser, AlbumListVersions.One).ConfigureAwait(false);
|
||||
return BuildResponse(request, result, "albumList");
|
||||
}
|
||||
|
||||
|
@ -176,9 +176,9 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> GetAlbumList2(SubsonicRequest request)
|
||||
{
|
||||
var authResult = await AuthenticateUser(request);
|
||||
var authResult = await AuthenticateUser(request).ConfigureAwait(false);
|
||||
if (authResult != null) return authResult;
|
||||
var result = await SubsonicService.GetAlbumList(request, SubsonicUser, AlbumListVersions.Two);
|
||||
var result = await SubsonicService.GetAlbumList(request, SubsonicUser, AlbumListVersions.Two).ConfigureAwait(false);
|
||||
return BuildResponse(request, result, "albumList");
|
||||
}
|
||||
|
||||
|
@ -187,9 +187,9 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> GetArtist(SubsonicRequest request)
|
||||
{
|
||||
var authResult = await AuthenticateUser(request);
|
||||
var authResult = await AuthenticateUser(request).ConfigureAwait(false);
|
||||
if (authResult != null) return authResult;
|
||||
var result = await SubsonicService.GetArtist(request, SubsonicUser);
|
||||
var result = await SubsonicService.GetArtist(request, SubsonicUser).ConfigureAwait(false);
|
||||
return BuildResponse(request, result, "artist");
|
||||
}
|
||||
|
||||
|
@ -198,10 +198,10 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> GetArtistInfo(SubsonicRequest request, int? count, bool? includeNotPresent)
|
||||
{
|
||||
var authResult = await AuthenticateUser(request);
|
||||
var authResult = await AuthenticateUser(request).ConfigureAwait(false);
|
||||
if (authResult != null) return authResult;
|
||||
var result =
|
||||
await SubsonicService.GetArtistInfo(request, count, includeNotPresent ?? false, ArtistInfoVersion.One);
|
||||
await SubsonicService.GetArtistInfo(request, count, includeNotPresent ?? false, ArtistInfoVersion.One).ConfigureAwait(false);
|
||||
return BuildResponse(request, result, "artistInfo");
|
||||
}
|
||||
|
||||
|
@ -210,10 +210,10 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> GetArtistInfo2(SubsonicRequest request, int? count, bool? includeNotPresent)
|
||||
{
|
||||
var authResult = await AuthenticateUser(request);
|
||||
var authResult = await AuthenticateUser(request).ConfigureAwait(false);
|
||||
if (authResult != null) return authResult;
|
||||
var result =
|
||||
await SubsonicService.GetArtistInfo(request, count, includeNotPresent ?? false, ArtistInfoVersion.Two);
|
||||
await SubsonicService.GetArtistInfo(request, count, includeNotPresent ?? false, ArtistInfoVersion.Two).ConfigureAwait(false);
|
||||
return BuildResponse(request, result, "artistInfo2");
|
||||
}
|
||||
|
||||
|
@ -222,18 +222,18 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> GetArtists(SubsonicRequest request)
|
||||
{
|
||||
var authResult = await AuthenticateUser(request);
|
||||
var authResult = await AuthenticateUser(request).ConfigureAwait(false);
|
||||
if (authResult != null) return authResult;
|
||||
var result = await SubsonicService.GetArtists(request, SubsonicUser);
|
||||
var result = await SubsonicService.GetArtists(request, SubsonicUser).ConfigureAwait(false);
|
||||
return BuildResponse(request, result, "artists");
|
||||
}
|
||||
|
||||
[HttpGet("getAvatar.view")]
|
||||
[HttpPost("getAvatar.view")]
|
||||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> GetAvatar(SubsonicRequest request, string username)
|
||||
public async Task<IActionResult> GetAvatar(string username)
|
||||
{
|
||||
var user = await UserManager.FindByNameAsync(username);
|
||||
var user = await UserManager.FindByNameAsync(username).ConfigureAwait(false);
|
||||
return Redirect(
|
||||
$"/images/user/{user.RoadieId}/{RoadieSettings.ThumbnailImageSize.Width}/{RoadieSettings.ThumbnailImageSize.Height}");
|
||||
}
|
||||
|
@ -243,9 +243,9 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> GetBookmarks(SubsonicRequest request)
|
||||
{
|
||||
var authResult = await AuthenticateUser(request);
|
||||
var authResult = await AuthenticateUser(request).ConfigureAwait(false);
|
||||
if (authResult != null) return authResult;
|
||||
var result = await SubsonicService.GetBookmarks(request, SubsonicUser);
|
||||
var result = await SubsonicService.GetBookmarks(request, SubsonicUser).ConfigureAwait(false);
|
||||
return BuildResponse(request, result, "bookmarks");
|
||||
}
|
||||
|
||||
|
@ -254,9 +254,9 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> GetChatMessages(SubsonicRequest request, long? since)
|
||||
{
|
||||
var authResult = await AuthenticateUser(request);
|
||||
var authResult = await AuthenticateUser(request).ConfigureAwait(false);
|
||||
if (authResult != null) return authResult;
|
||||
var result = await SubsonicService.GetChatMessages(request, SubsonicUser, since);
|
||||
var result = await SubsonicService.GetChatMessages(request, SubsonicUser, since).ConfigureAwait(false);
|
||||
return BuildResponse(request, result, "chatMessages");
|
||||
}
|
||||
|
||||
|
@ -265,8 +265,12 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> GetCoverArt(SubsonicRequest request, int? size)
|
||||
{
|
||||
var result = await SubsonicService.GetCoverArt(request, size);
|
||||
if (result == null || result.IsNotFoundResult) return NotFound();
|
||||
var result = await SubsonicService.GetCoverArt(request, size).ConfigureAwait(false);
|
||||
if (result?.IsNotFoundResult != false)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
if (!result.IsSuccess)
|
||||
{
|
||||
Logger.LogWarning($"GetCoverArt Failed For [{JsonConvert.SerializeObject(request)}]");
|
||||
|
@ -285,7 +289,7 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> GetGenres(SubsonicRequest request)
|
||||
{
|
||||
var result = await SubsonicService.GetGenres(request);
|
||||
var result = await SubsonicService.GetGenres(request).ConfigureAwait(false);
|
||||
return BuildResponse(request, result, "genres");
|
||||
}
|
||||
|
||||
|
@ -294,9 +298,9 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> GetIndexes(SubsonicRequest request, long? ifModifiedSince = null)
|
||||
{
|
||||
var authResult = await AuthenticateUser(request);
|
||||
var authResult = await AuthenticateUser(request).ConfigureAwait(false);
|
||||
if (authResult != null) return authResult;
|
||||
var result = await SubsonicService.GetIndexes(request, SubsonicUser, ifModifiedSince);
|
||||
var result = await SubsonicService.GetIndexes(request, SubsonicUser, ifModifiedSince).ConfigureAwait(false);
|
||||
return BuildResponse(request, result, "indexes");
|
||||
}
|
||||
|
||||
|
@ -323,9 +327,9 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> GetMusicDirectory(SubsonicRequest request)
|
||||
{
|
||||
var authResult = await AuthenticateUser(request);
|
||||
var authResult = await AuthenticateUser(request).ConfigureAwait(false);
|
||||
if (authResult != null) return authResult;
|
||||
var result = await SubsonicService.GetMusicDirectory(request, SubsonicUser);
|
||||
var result = await SubsonicService.GetMusicDirectory(request, SubsonicUser).ConfigureAwait(false);
|
||||
return BuildResponse(request, result, "directory");
|
||||
}
|
||||
|
||||
|
@ -334,7 +338,7 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> GetMusicFolders(SubsonicRequest request)
|
||||
{
|
||||
var result = await SubsonicService.GetMusicFolders(request);
|
||||
var result = await SubsonicService.GetMusicFolders(request).ConfigureAwait(false);
|
||||
return BuildResponse(request, result, "musicFolders");
|
||||
}
|
||||
|
||||
|
@ -343,9 +347,9 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> GetNowPlaying(SubsonicRequest request)
|
||||
{
|
||||
var authResult = await AuthenticateUser(request);
|
||||
var authResult = await AuthenticateUser(request).ConfigureAwait(false);
|
||||
if (authResult != null) return authResult;
|
||||
var result = await SubsonicService.GetNowPlaying(request, SubsonicUser);
|
||||
var result = await SubsonicService.GetNowPlaying(request, SubsonicUser).ConfigureAwait(false);
|
||||
return BuildResponse(request, result, "nowPlaying");
|
||||
}
|
||||
|
||||
|
@ -354,9 +358,9 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> GetPlaylist(SubsonicRequest request)
|
||||
{
|
||||
var authResult = await AuthenticateUser(request);
|
||||
var authResult = await AuthenticateUser(request).ConfigureAwait(false);
|
||||
if (authResult != null) return authResult;
|
||||
var result = await SubsonicService.GetPlaylist(request, SubsonicUser);
|
||||
var result = await SubsonicService.GetPlaylist(request, SubsonicUser).ConfigureAwait(false);
|
||||
return BuildResponse(request, result, "playlist");
|
||||
}
|
||||
|
||||
|
@ -365,9 +369,9 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> GetPlaylists(SubsonicRequest request, string username)
|
||||
{
|
||||
var authResult = await AuthenticateUser(request);
|
||||
var authResult = await AuthenticateUser(request).ConfigureAwait(false);
|
||||
if (authResult != null) return authResult;
|
||||
var result = await SubsonicService.GetPlaylists(request, SubsonicUser, username);
|
||||
var result = await SubsonicService.GetPlaylists(request, SubsonicUser, username).ConfigureAwait(false);
|
||||
return BuildResponse(request, result, "playlists");
|
||||
}
|
||||
|
||||
|
@ -376,9 +380,9 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> GetPlayQueue(SubsonicRequest request)
|
||||
{
|
||||
var authResult = await AuthenticateUser(request);
|
||||
var authResult = await AuthenticateUser(request).ConfigureAwait(false);
|
||||
if (authResult != null) return authResult;
|
||||
var result = await SubsonicService.GetPlayQueue(request, SubsonicUser);
|
||||
var result = await SubsonicService.GetPlayQueue(request, SubsonicUser).ConfigureAwait(false);
|
||||
if (result.IsEmptyResponse) return BuildResponse(request, result);
|
||||
return BuildResponse(request, result, "playQueue");
|
||||
}
|
||||
|
@ -386,11 +390,11 @@ namespace Roadie.Api.Controllers
|
|||
[HttpGet("getPodcasts.view")]
|
||||
[HttpPost("getPodcasts.view")]
|
||||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> GetPodcasts(SubsonicRequest request, bool includeEpisodes)
|
||||
public async Task<IActionResult> GetPodcasts(SubsonicRequest request)
|
||||
{
|
||||
var authResult = await AuthenticateUser(request);
|
||||
var authResult = await AuthenticateUser(request).ConfigureAwait(false);
|
||||
if (authResult != null) return authResult;
|
||||
var result = await SubsonicService.GetPodcasts(request);
|
||||
var result = await SubsonicService.GetPodcasts(request).ConfigureAwait(false);
|
||||
return BuildResponse(request, result, "podcasts");
|
||||
}
|
||||
|
||||
|
@ -399,9 +403,9 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> GetRandomSongs(SubsonicRequest request)
|
||||
{
|
||||
var authResult = await AuthenticateUser(request);
|
||||
var authResult = await AuthenticateUser(request).ConfigureAwait(false);
|
||||
if (authResult != null) return authResult;
|
||||
var result = await SubsonicService.GetRandomSongs(request, SubsonicUser);
|
||||
var result = await SubsonicService.GetRandomSongs(request, SubsonicUser).ConfigureAwait(false);
|
||||
return BuildResponse(request, result, "randomSongs");
|
||||
}
|
||||
|
||||
|
@ -410,9 +414,9 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> GetSimilarSongs(SubsonicRequest request, int? count = 50)
|
||||
{
|
||||
var authResult = await AuthenticateUser(request);
|
||||
var authResult = await AuthenticateUser(request).ConfigureAwait(false);
|
||||
if (authResult != null) return authResult;
|
||||
var result = await SubsonicService.GetSimliarSongs(request, SubsonicUser, SimilarSongsVersion.One, count);
|
||||
var result = await SubsonicService.GetSimliarSongs(request, SubsonicUser, SimilarSongsVersion.One, count).ConfigureAwait(false);
|
||||
return BuildResponse(request, result, "similarSongs");
|
||||
}
|
||||
|
||||
|
@ -421,9 +425,9 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> GetSimilarSongs2(SubsonicRequest request, int? count = 50)
|
||||
{
|
||||
var authResult = await AuthenticateUser(request);
|
||||
var authResult = await AuthenticateUser(request).ConfigureAwait(false);
|
||||
if (authResult != null) return authResult;
|
||||
var result = await SubsonicService.GetSimliarSongs(request, SubsonicUser, SimilarSongsVersion.Two, count);
|
||||
var result = await SubsonicService.GetSimliarSongs(request, SubsonicUser, SimilarSongsVersion.Two, count).ConfigureAwait(false);
|
||||
return BuildResponse(request, result, "similarSongs2");
|
||||
}
|
||||
|
||||
|
@ -432,9 +436,9 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> GetSong(SubsonicRequest request)
|
||||
{
|
||||
var authResult = await AuthenticateUser(request);
|
||||
var authResult = await AuthenticateUser(request).ConfigureAwait(false);
|
||||
if (authResult != null) return authResult;
|
||||
var result = await SubsonicService.GetSong(request, SubsonicUser);
|
||||
var result = await SubsonicService.GetSong(request, SubsonicUser).ConfigureAwait(false);
|
||||
return BuildResponse(request, result, "song");
|
||||
}
|
||||
|
||||
|
@ -443,9 +447,9 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> GetSongsByGenre(SubsonicRequest request)
|
||||
{
|
||||
var authResult = await AuthenticateUser(request);
|
||||
var authResult = await AuthenticateUser(request).ConfigureAwait(false);
|
||||
if (authResult != null) return authResult;
|
||||
var result = await SubsonicService.GetSongsByGenre(request, SubsonicUser);
|
||||
var result = await SubsonicService.GetSongsByGenre(request, SubsonicUser).ConfigureAwait(false);
|
||||
return BuildResponse(request, result, "songsByGenre");
|
||||
}
|
||||
|
||||
|
@ -454,9 +458,9 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> GetStarred(SubsonicRequest request)
|
||||
{
|
||||
var authResult = await AuthenticateUser(request);
|
||||
var authResult = await AuthenticateUser(request).ConfigureAwait(false);
|
||||
if (authResult != null) return authResult;
|
||||
var result = await SubsonicService.GetStarred(request, SubsonicUser, StarredVersion.One);
|
||||
var result = await SubsonicService.GetStarred(request, SubsonicUser, StarredVersion.One).ConfigureAwait(false);
|
||||
return BuildResponse(request, result, "starred");
|
||||
}
|
||||
|
||||
|
@ -465,9 +469,9 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> GetStarred2(SubsonicRequest request)
|
||||
{
|
||||
var authResult = await AuthenticateUser(request);
|
||||
var authResult = await AuthenticateUser(request).ConfigureAwait(false);
|
||||
if (authResult != null) return authResult;
|
||||
var result = await SubsonicService.GetStarred(request, SubsonicUser, StarredVersion.Two);
|
||||
var result = await SubsonicService.GetStarred(request, SubsonicUser, StarredVersion.Two).ConfigureAwait(false);
|
||||
return BuildResponse(request, result, "starred");
|
||||
}
|
||||
|
||||
|
@ -476,9 +480,9 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> GetTopSongs(SubsonicRequest request, int? count = 50)
|
||||
{
|
||||
var authResult = await AuthenticateUser(request);
|
||||
var authResult = await AuthenticateUser(request).ConfigureAwait(false);
|
||||
if (authResult != null) return authResult;
|
||||
var result = await SubsonicService.GetTopSongs(request, SubsonicUser, count);
|
||||
var result = await SubsonicService.GetTopSongs(request, SubsonicUser, count).ConfigureAwait(false);
|
||||
return BuildResponse(request, result, "topSongs");
|
||||
}
|
||||
|
||||
|
@ -487,9 +491,9 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> GetUser(SubsonicRequest request, string username)
|
||||
{
|
||||
var authResult = await AuthenticateUser(request);
|
||||
var authResult = await AuthenticateUser(request).ConfigureAwait(false);
|
||||
if (authResult != null) return authResult;
|
||||
var result = await SubsonicService.GetUser(request, username ?? request.u);
|
||||
var result = await SubsonicService.GetUser(request, username ?? request.u).ConfigureAwait(false);
|
||||
return BuildResponse(request, result, "user");
|
||||
}
|
||||
|
||||
|
@ -507,7 +511,7 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> Ping(SubsonicRequest request)
|
||||
{
|
||||
var authResult = await AuthenticateUser(request);
|
||||
var authResult = await AuthenticateUser(request).ConfigureAwait(false);
|
||||
if (authResult != null) return authResult;
|
||||
if (request.IsJSONRequest)
|
||||
{
|
||||
|
@ -523,12 +527,12 @@ namespace Roadie.Api.Controllers
|
|||
[HttpGet("savePlayQueue.view")]
|
||||
[HttpPost("savePlayQueue.view")]
|
||||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> SavePlayQueue(SubsonicRequest request, string username, string current,
|
||||
public async Task<IActionResult> SavePlayQueue(SubsonicRequest request, string current,
|
||||
long? position)
|
||||
{
|
||||
var authResult = await AuthenticateUser(request);
|
||||
var authResult = await AuthenticateUser(request).ConfigureAwait(false);
|
||||
if (authResult != null) return authResult;
|
||||
var result = await SubsonicService.SavePlayQueue(request, SubsonicUser, current, position);
|
||||
var result = await SubsonicService.SavePlayQueue(request, SubsonicUser, current, position).ConfigureAwait(false);
|
||||
return BuildResponse(request, result);
|
||||
}
|
||||
|
||||
|
@ -539,7 +543,7 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> Scrobble(SubsonicRequest request)
|
||||
{
|
||||
var authResult = await AuthenticateUser(request);
|
||||
var authResult = await AuthenticateUser(request).ConfigureAwait(false);
|
||||
if (authResult != null) return authResult;
|
||||
var timePlayed = string.IsNullOrEmpty(request.time)
|
||||
? DateTime.UtcNow.AddDays(-1)
|
||||
|
@ -548,7 +552,7 @@ namespace Roadie.Api.Controllers
|
|||
{
|
||||
TrackId = request.TrackId.Value,
|
||||
TimePlayed = timePlayed
|
||||
});
|
||||
}).ConfigureAwait(false);
|
||||
return BuildResponse(request, new SubsonicOperationResult<Response>
|
||||
{
|
||||
IsSuccess = scrobblerResponse.IsSuccess,
|
||||
|
@ -564,9 +568,9 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> Search(SubsonicRequest request)
|
||||
{
|
||||
var authResult = await AuthenticateUser(request);
|
||||
var authResult = await AuthenticateUser(request).ConfigureAwait(false);
|
||||
if (authResult != null) return authResult;
|
||||
var result = await SubsonicService.Search(request, SubsonicUser, SearchVersion.One);
|
||||
var result = await SubsonicService.Search(request, SubsonicUser, SearchVersion.One).ConfigureAwait(false);
|
||||
return BuildResponse(request, result, "searchResult");
|
||||
}
|
||||
|
||||
|
@ -575,9 +579,9 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> Search2(SubsonicRequest request)
|
||||
{
|
||||
var authResult = await AuthenticateUser(request);
|
||||
var authResult = await AuthenticateUser(request).ConfigureAwait(false);
|
||||
if (authResult != null) return authResult;
|
||||
var result = await SubsonicService.Search(request, SubsonicUser, SearchVersion.Two);
|
||||
var result = await SubsonicService.Search(request, SubsonicUser, SearchVersion.Two).ConfigureAwait(false);
|
||||
return BuildResponse(request, result, "searchResult2");
|
||||
}
|
||||
|
||||
|
@ -586,9 +590,9 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> Search3(SubsonicRequest request)
|
||||
{
|
||||
var authResult = await AuthenticateUser(request);
|
||||
var authResult = await AuthenticateUser(request).ConfigureAwait(false);
|
||||
if (authResult != null) return authResult;
|
||||
var result = await SubsonicService.Search(request, SubsonicUser, SearchVersion.Three);
|
||||
var result = await SubsonicService.Search(request, SubsonicUser, SearchVersion.Three).ConfigureAwait(false);
|
||||
return BuildResponse(request, result, "searchResult3");
|
||||
}
|
||||
|
||||
|
@ -597,21 +601,20 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> SetRating(SubsonicRequest request, short rating)
|
||||
{
|
||||
var authResult = await AuthenticateUser(request);
|
||||
var authResult = await AuthenticateUser(request).ConfigureAwait(false);
|
||||
if (authResult != null) return authResult;
|
||||
var result = await SubsonicService.SetRating(request, SubsonicUser, rating);
|
||||
var result = await SubsonicService.SetRating(request, SubsonicUser, rating).ConfigureAwait(false);
|
||||
return BuildResponse(request, result);
|
||||
}
|
||||
|
||||
[HttpGet("star.view")]
|
||||
[HttpPost("star.view")]
|
||||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> Star(SubsonicRequest request, [FromQueryAttribute] string[] albumId,
|
||||
[FromQueryAttribute] string[] artistId)
|
||||
public async Task<IActionResult> Star(SubsonicRequest request, [FromQuery] string[] albumId, [FromQuery] string[] artistId)
|
||||
{
|
||||
var authResult = await AuthenticateUser(request);
|
||||
var authResult = await AuthenticateUser(request).ConfigureAwait(false);
|
||||
if (authResult != null) return authResult;
|
||||
var result = await SubsonicService.ToggleStar(request, SubsonicUser, true, albumId, artistId);
|
||||
var result = await SubsonicService.ToggleStar(request, SubsonicUser, true, albumId, artistId).ConfigureAwait(false);
|
||||
return BuildResponse(request, result);
|
||||
}
|
||||
|
||||
|
@ -620,42 +623,41 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> StreamTrack(SubsonicRequest request)
|
||||
{
|
||||
var authResult = await AuthenticateUser(request);
|
||||
var authResult = await AuthenticateUser(request).ConfigureAwait(false);
|
||||
if (authResult != null) return Unauthorized();
|
||||
var trackId = request.TrackId;
|
||||
if (trackId == null) return NotFound("Invalid TrackId");
|
||||
return await base.StreamTrack(trackId.Value, TrackService, PlayActivityService, SubsonicUser);
|
||||
return await StreamTrack(trackId.Value, TrackService, PlayActivityService, SubsonicUser).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[HttpGet("unstar.view")]
|
||||
[HttpPost("unstar.view")]
|
||||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> UnStar(SubsonicRequest request, [FromQueryAttribute] string[] albumId,
|
||||
[FromQueryAttribute] string[] artistId)
|
||||
public async Task<IActionResult> UnStar(SubsonicRequest request, [FromQuery] string[] albumId, [FromQuery] string[] artistId)
|
||||
{
|
||||
var authResult = await AuthenticateUser(request);
|
||||
var authResult = await AuthenticateUser(request).ConfigureAwait(false);
|
||||
if (authResult != null) return authResult;
|
||||
var result = await SubsonicService.ToggleStar(request, SubsonicUser, false, albumId, artistId);
|
||||
var result = await SubsonicService.ToggleStar(request, SubsonicUser, false, albumId, artistId).ConfigureAwait(false);
|
||||
return BuildResponse(request, result);
|
||||
}
|
||||
|
||||
[HttpGet("updatePlaylist.view")]
|
||||
[HttpPost("updatePlaylist.view")]
|
||||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> UpdatePlaylist(SubsonicRequest request, [FromQueryAttribute] string playlistId,
|
||||
[FromQueryAttribute] string name, [FromQueryAttribute] string comment, [FromQueryAttribute] bool? @public,
|
||||
[FromQueryAttribute] string[] songIdToAdd, [FromQueryAttribute] int[] songIndexToRemove)
|
||||
public async Task<IActionResult> UpdatePlaylist(SubsonicRequest request, [FromQuery] string playlistId,
|
||||
[FromQuery] string name, [FromQuery] string comment, [FromQuery] bool? @public,
|
||||
[FromQuery] string[] songIdToAdd, [FromQuery] int[] songIndexToRemove)
|
||||
{
|
||||
var authResult = await AuthenticateUser(request);
|
||||
var authResult = await AuthenticateUser(request).ConfigureAwait(false);
|
||||
if (authResult != null) return authResult;
|
||||
var result = await SubsonicService.UpdatePlaylist(request, SubsonicUser, playlistId, name, comment, @public,
|
||||
songIdToAdd, songIndexToRemove);
|
||||
songIdToAdd, songIndexToRemove).ConfigureAwait(false);
|
||||
return BuildResponse(request, result);
|
||||
}
|
||||
|
||||
private async Task<IActionResult> AuthenticateUser(SubsonicRequest request)
|
||||
{
|
||||
var appUser = await SubsonicService.Authenticate(request);
|
||||
var appUser = await SubsonicService.Authenticate(request).ConfigureAwait(false);
|
||||
if (!(appUser?.IsSuccess ?? false) || (appUser?.IsNotFoundResult ?? false))
|
||||
{
|
||||
return BuildResponse(request, appUser.Adapt<SubsonicOperationResult<Response>>());
|
||||
|
@ -669,22 +671,19 @@ namespace Roadie.Api.Controllers
|
|||
private IActionResult BuildResponse(SubsonicRequest request, SubsonicOperationResult<Response> response = null,
|
||||
string responseType = null)
|
||||
{
|
||||
var acceptHeader = Request.Headers["Accept"];
|
||||
string postBody = null;
|
||||
var queryString = Request.QueryString.ToString();
|
||||
string queryPath = Request.Path;
|
||||
var method = Request.Method;
|
||||
|
||||
if (!Request.Method.Equals("GET", StringComparison.OrdinalIgnoreCase) &&
|
||||
!string.IsNullOrEmpty(Request.ContentType))
|
||||
{
|
||||
var formCollection = Request.Form;
|
||||
var formDictionary = new Dictionary<string, object>();
|
||||
if (formCollection != null && formCollection.Any())
|
||||
if (formCollection?.Any() == true)
|
||||
{
|
||||
foreach (var form in formCollection)
|
||||
{
|
||||
if (!formDictionary.ContainsKey(form.Key))
|
||||
formDictionary[form.Key] = form.Value.FirstOrDefault();
|
||||
postBody = JsonConvert.SerializeObject(formDictionary);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (response?.ErrorCode.HasValue ?? false) return SendError(request, response);
|
||||
|
@ -695,15 +694,23 @@ namespace Roadie.Api.Controllers
|
|||
var version = response?.Data?.version ?? Services.SubsonicService.SubsonicVersion;
|
||||
string jsonResult = null;
|
||||
if (responseType == null)
|
||||
{
|
||||
jsonResult = "{ \"subsonic-response\": { \"status\":\"" + status + "\", \"version\": \"" + version +
|
||||
"\" }}";
|
||||
}
|
||||
else
|
||||
{
|
||||
jsonResult = "{ \"subsonic-response\": { \"status\":\"" + status + "\", \"version\": \"" + version +
|
||||
"\", \"" + responseType + "\":" + (response?.Data != null
|
||||
? JsonConvert.SerializeObject(response.Data.Item)
|
||||
: string.Empty) + "}}";
|
||||
}
|
||||
|
||||
if ((request?.f ?? string.Empty).Equals("jsonp", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
jsonResult = request.callback + "(" + jsonResult + ");";
|
||||
}
|
||||
|
||||
return Content(jsonResult);
|
||||
}
|
||||
|
||||
|
|
|
@ -36,22 +36,22 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(404)]
|
||||
public async Task<IActionResult> Get(Guid id, string inc = null)
|
||||
{
|
||||
var result = await TrackService.ById(await CurrentUserModel(), id,
|
||||
(inc ?? models.Track.DefaultIncludes).ToLower().Split(","));
|
||||
if (result == null || result.IsNotFoundResult) return NotFound();
|
||||
Library.OperationResult<models.Track> result = await TrackService.ById(await CurrentUserModel().ConfigureAwait(false), id,
|
||||
(inc ?? models.Track.DefaultIncludes).ToLower().Split(",")).ConfigureAwait(false);
|
||||
if (result?.IsNotFoundResult != false) return NotFound();
|
||||
if (!result.IsSuccess) return StatusCode((int)HttpStatusCode.InternalServerError);
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> List([FromQuery] PagedRequest request, string inc, bool? doRandomize = false)
|
||||
public async Task<IActionResult> List([FromQuery] PagedRequest request, bool? doRandomize = false)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await TrackService.List(request,
|
||||
doRandomize: doRandomize,
|
||||
roadieUser: await CurrentUserModel());
|
||||
roadieUser: await CurrentUserModel().ConfigureAwait(false)).ConfigureAwait(false);
|
||||
if (!result.IsSuccess) return StatusCode((int)HttpStatusCode.InternalServerError);
|
||||
return Ok(result);
|
||||
}
|
||||
|
@ -74,8 +74,8 @@ namespace Roadie.Api.Controllers
|
|||
public async Task<IActionResult> Update(models.Track track)
|
||||
{
|
||||
if (!ModelState.IsValid) return BadRequest(ModelState);
|
||||
var result = await TrackService.UpdateTrack(await CurrentUserModel(), track);
|
||||
if (result == null || result.IsNotFoundResult) return NotFound();
|
||||
var result = await TrackService.UpdateTrack(await CurrentUserModel().ConfigureAwait(false), track).ConfigureAwait(false);
|
||||
if (result?.IsNotFoundResult != false) return NotFound();
|
||||
if (!result.IsSuccess)
|
||||
{
|
||||
if (result.IsAccessDeniedResult)
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Roadie.Api.Services;
|
||||
using Roadie.Library.Caching;
|
||||
|
@ -29,7 +28,7 @@ namespace Roadie.Api.Controllers
|
|||
private IUserService UserService { get; }
|
||||
|
||||
public UserController(IUserService userService, ILogger<UserController> logger, ICacheManager cacheManager,
|
||||
IConfiguration configuration, ITokenService tokenService, UserManager<Library.Identity.User> userManager,
|
||||
ITokenService tokenService, UserManager<Library.Identity.User> userManager,
|
||||
IHttpContext httpContext, IRoadieSettings roadieSettings)
|
||||
: base(cacheManager, roadieSettings, userManager)
|
||||
{
|
||||
|
@ -45,12 +44,9 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(404)]
|
||||
public async Task<IActionResult> GetAccountSettings(Guid id, string inc = null)
|
||||
{
|
||||
var user = await CurrentUserModel();
|
||||
var result = await CacheManager.GetAsync($"urn:user_edit_model_by_id:{id}", async () =>
|
||||
{
|
||||
return await UserService.ById(user, id, (inc ?? Library.Models.Users.User.DefaultIncludes).ToLower().Split(","), true);
|
||||
}, ControllerCacheRegionUrn);
|
||||
if (result == null || result.IsNotFoundResult)
|
||||
var user = await CurrentUserModel().ConfigureAwait(false);
|
||||
var result = await CacheManager.GetAsync($"urn:user_edit_model_by_id:{id}", async () => await UserService.ById(user, id, (inc ?? Library.Models.Users.User.DefaultIncludes).ToLower().Split(","), true).ConfigureAwait(false), ControllerCacheRegionUrn).ConfigureAwait(false);
|
||||
if (result?.IsNotFoundResult != false)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
@ -73,13 +69,10 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(404)]
|
||||
public async Task<IActionResult> Get(Guid id, string inc = null)
|
||||
{
|
||||
var user = await CurrentUserModel();
|
||||
var user = await CurrentUserModel().ConfigureAwait(false);
|
||||
var result = await CacheManager.GetAsync($"urn:user_model_by_id:{id}",
|
||||
async () =>
|
||||
{
|
||||
return await UserService.ById(user, id, (inc ?? Library.Models.Users.User.DefaultIncludes).ToLower().Split(","));
|
||||
}, ControllerCacheRegionUrn);
|
||||
if (result == null || result.IsNotFoundResult)
|
||||
async () => await UserService.ById(user, id, (inc ?? Library.Models.Users.User.DefaultIncludes).ToLower().Split(",")).ConfigureAwait(false), ControllerCacheRegionUrn).ConfigureAwait(false);
|
||||
if (result?.IsNotFoundResult != false)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
@ -95,7 +88,7 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> IntegrationGrant(Guid userId, string iname, string token)
|
||||
{
|
||||
var result = await UserService.UpdateIntegrationGrant(userId, iname, token);
|
||||
var result = await UserService.UpdateIntegrationGrant(userId, iname, token).ConfigureAwait(false);
|
||||
if (!result.IsSuccess) return Content("Error while attempting to enable integration");
|
||||
return Content("Successfully enabled integration!");
|
||||
}
|
||||
|
@ -104,7 +97,7 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> List([FromQuery] PagedRequest request)
|
||||
{
|
||||
var result = await UserService.List(request);
|
||||
var result = await UserService.List(request).ConfigureAwait(false);
|
||||
if (!result.IsSuccess) return StatusCode((int)HttpStatusCode.InternalServerError);
|
||||
return Ok(result);
|
||||
}
|
||||
|
@ -113,7 +106,7 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> SetArtistBookmark(Guid artistId, bool isBookmarked)
|
||||
{
|
||||
var result = await UserService.SetArtistBookmark(artistId, await CurrentUserModel(), isBookmarked);
|
||||
var result = await UserService.SetArtistBookmark(artistId, await CurrentUserModel().ConfigureAwait(false), isBookmarked).ConfigureAwait(false);
|
||||
if (!result.IsSuccess) return StatusCode((int)HttpStatusCode.InternalServerError);
|
||||
CacheManager.ClearRegion(ControllerCacheRegionUrn);
|
||||
return Ok(result);
|
||||
|
@ -123,7 +116,7 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> SetArtistDisliked(Guid artistId, bool isDisliked)
|
||||
{
|
||||
var result = await UserService.SetArtistDisliked(artistId, await CurrentUserModel(), isDisliked);
|
||||
var result = await UserService.SetArtistDisliked(artistId, await CurrentUserModel().ConfigureAwait(false), isDisliked).ConfigureAwait(false);
|
||||
if (!result.IsSuccess) return StatusCode((int)HttpStatusCode.InternalServerError);
|
||||
CacheManager.ClearRegion(ControllerCacheRegionUrn);
|
||||
return Ok(result);
|
||||
|
@ -133,7 +126,7 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> SetArtistFavorite(Guid artistId, bool isFavorite)
|
||||
{
|
||||
var result = await UserService.SetArtistFavorite(artistId, await CurrentUserModel(), isFavorite);
|
||||
var result = await UserService.SetArtistFavorite(artistId, await CurrentUserModel().ConfigureAwait(false), isFavorite).ConfigureAwait(false);
|
||||
if (!result.IsSuccess) return StatusCode((int)HttpStatusCode.InternalServerError);
|
||||
CacheManager.ClearRegion(ControllerCacheRegionUrn);
|
||||
return Ok(result);
|
||||
|
@ -143,7 +136,7 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> SetArtistRating(Guid releaseId, short rating)
|
||||
{
|
||||
var result = await UserService.SetArtistRating(releaseId, await CurrentUserModel(), rating);
|
||||
var result = await UserService.SetArtistRating(releaseId, await CurrentUserModel().ConfigureAwait(false), rating).ConfigureAwait(false);
|
||||
if (!result.IsSuccess) return StatusCode((int)HttpStatusCode.InternalServerError);
|
||||
CacheManager.ClearRegion(ControllerCacheRegionUrn);
|
||||
return Ok(result);
|
||||
|
@ -153,7 +146,7 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> DeleteAllBookmarks()
|
||||
{
|
||||
var result = await UserService.DeleteAllBookmarks(await CurrentUserModel());
|
||||
var result = await UserService.DeleteAllBookmarks(await CurrentUserModel().ConfigureAwait(false)).ConfigureAwait(false);
|
||||
if (!result.IsSuccess) return StatusCode((int)HttpStatusCode.InternalServerError);
|
||||
CacheManager.ClearRegion(ControllerCacheRegionUrn);
|
||||
return Ok(result);
|
||||
|
@ -163,7 +156,7 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> SetCollectionBookmark(Guid collectionId, bool isBookmarked)
|
||||
{
|
||||
var result = await UserService.SetCollectionBookmark(collectionId, await CurrentUserModel(), isBookmarked);
|
||||
var result = await UserService.SetCollectionBookmark(collectionId, await CurrentUserModel().ConfigureAwait(false), isBookmarked).ConfigureAwait(false);
|
||||
if (!result.IsSuccess) return StatusCode((int)HttpStatusCode.InternalServerError);
|
||||
CacheManager.ClearRegion(ControllerCacheRegionUrn);
|
||||
return Ok(result);
|
||||
|
@ -173,7 +166,7 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> SetLabelBookmark(Guid labelId, bool isBookmarked)
|
||||
{
|
||||
var result = await UserService.SetLabelBookmark(labelId, await CurrentUserModel(), isBookmarked);
|
||||
var result = await UserService.SetLabelBookmark(labelId, await CurrentUserModel().ConfigureAwait(false), isBookmarked).ConfigureAwait(false);
|
||||
if (!result.IsSuccess) return StatusCode((int)HttpStatusCode.InternalServerError);
|
||||
CacheManager.ClearRegion(ControllerCacheRegionUrn);
|
||||
return Ok(result);
|
||||
|
@ -183,7 +176,7 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> SetPlaylistBookmark(Guid playlistId, bool isBookmarked)
|
||||
{
|
||||
var result = await UserService.SetPlaylistBookmark(playlistId, await CurrentUserModel(), isBookmarked);
|
||||
var result = await UserService.SetPlaylistBookmark(playlistId, await CurrentUserModel().ConfigureAwait(false), isBookmarked).ConfigureAwait(false);
|
||||
if (!result.IsSuccess) return StatusCode((int)HttpStatusCode.InternalServerError);
|
||||
CacheManager.ClearRegion(ControllerCacheRegionUrn);
|
||||
return Ok(result);
|
||||
|
@ -193,7 +186,7 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> SetReleaseBookmark(Guid releaseId, bool isBookmarked)
|
||||
{
|
||||
var result = await UserService.SetReleaseBookmark(releaseId, await CurrentUserModel(), isBookmarked);
|
||||
var result = await UserService.SetReleaseBookmark(releaseId, await CurrentUserModel().ConfigureAwait(false), isBookmarked).ConfigureAwait(false);
|
||||
if (!result.IsSuccess) return StatusCode((int)HttpStatusCode.InternalServerError);
|
||||
CacheManager.ClearRegion(ControllerCacheRegionUrn);
|
||||
return Ok(result);
|
||||
|
@ -203,7 +196,7 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> SetReleaseDisliked(Guid releaseId, bool isDisliked)
|
||||
{
|
||||
var result = await UserService.SetReleaseDisliked(releaseId, await CurrentUserModel(), isDisliked);
|
||||
var result = await UserService.SetReleaseDisliked(releaseId, await CurrentUserModel().ConfigureAwait(false), isDisliked).ConfigureAwait(false);
|
||||
if (!result.IsSuccess) return StatusCode((int)HttpStatusCode.InternalServerError);
|
||||
CacheManager.ClearRegion(ControllerCacheRegionUrn);
|
||||
return Ok(result);
|
||||
|
@ -213,7 +206,7 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> SetReleaseFavorite(Guid releaseId, bool isFavorite)
|
||||
{
|
||||
var result = await UserService.SetReleaseFavorite(releaseId, await CurrentUserModel(), isFavorite);
|
||||
var result = await UserService.SetReleaseFavorite(releaseId, await CurrentUserModel().ConfigureAwait(false), isFavorite).ConfigureAwait(false);
|
||||
if (!result.IsSuccess) return StatusCode((int)HttpStatusCode.InternalServerError);
|
||||
CacheManager.ClearRegion(ControllerCacheRegionUrn);
|
||||
return Ok(result);
|
||||
|
@ -223,7 +216,7 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> SetReleaseRating(Guid releaseId, short rating)
|
||||
{
|
||||
var result = await UserService.SetReleaseRating(releaseId, await CurrentUserModel(), rating);
|
||||
var result = await UserService.SetReleaseRating(releaseId, await CurrentUserModel().ConfigureAwait(false), rating).ConfigureAwait(false);
|
||||
if (!result.IsSuccess) return StatusCode((int)HttpStatusCode.InternalServerError);
|
||||
CacheManager.ClearRegion(ControllerCacheRegionUrn);
|
||||
return Ok(result);
|
||||
|
@ -233,7 +226,7 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> SetTrackBookmark(Guid trackId, bool isBookmarked)
|
||||
{
|
||||
var result = await UserService.SetTrackBookmark(trackId, await CurrentUserModel(), isBookmarked);
|
||||
var result = await UserService.SetTrackBookmark(trackId, await CurrentUserModel().ConfigureAwait(false), isBookmarked).ConfigureAwait(false);
|
||||
if (!result.IsSuccess) return StatusCode((int)HttpStatusCode.InternalServerError);
|
||||
CacheManager.ClearRegion(ControllerCacheRegionUrn);
|
||||
return Ok(result);
|
||||
|
@ -243,7 +236,7 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> SetTrackDisliked(Guid trackId, bool isDisliked)
|
||||
{
|
||||
var result = await UserService.SetTrackDisliked(trackId, await CurrentUserModel(), isDisliked);
|
||||
var result = await UserService.SetTrackDisliked(trackId, await CurrentUserModel().ConfigureAwait(false), isDisliked).ConfigureAwait(false);
|
||||
if (!result.IsSuccess) return StatusCode((int)HttpStatusCode.InternalServerError);
|
||||
CacheManager.ClearRegion(ControllerCacheRegionUrn);
|
||||
return Ok(result);
|
||||
|
@ -253,7 +246,7 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> SetTrackFavorite(Guid trackId, bool isFavorite)
|
||||
{
|
||||
var result = await UserService.SetTrackFavorite(trackId, await CurrentUserModel(), isFavorite);
|
||||
var result = await UserService.SetTrackFavorite(trackId, await CurrentUserModel().ConfigureAwait(false), isFavorite).ConfigureAwait(false);
|
||||
if (!result.IsSuccess) return StatusCode((int)HttpStatusCode.InternalServerError);
|
||||
CacheManager.ClearRegion(ControllerCacheRegionUrn);
|
||||
return Ok(result);
|
||||
|
@ -263,7 +256,7 @@ namespace Roadie.Api.Controllers
|
|||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> SetTrackRating(Guid trackId, short rating)
|
||||
{
|
||||
var result = await UserService.SetTrackRating(trackId, await CurrentUserModel(), rating);
|
||||
var result = await UserService.SetTrackRating(trackId, await CurrentUserModel().ConfigureAwait(false), rating).ConfigureAwait(false);
|
||||
if (!result.IsSuccess) return StatusCode((int)HttpStatusCode.InternalServerError);
|
||||
CacheManager.ClearRegion(ControllerCacheRegionUrn);
|
||||
return Ok(result);
|
||||
|
@ -277,9 +270,9 @@ namespace Roadie.Api.Controllers
|
|||
{
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
var user = await CurrentUserModel();
|
||||
var result = await UserService.UpdateProfile(user, model);
|
||||
if (result == null || result.IsNotFoundResult) return NotFound();
|
||||
var user = await CurrentUserModel().ConfigureAwait(false);
|
||||
var result = await UserService.UpdateProfile(user, model).ConfigureAwait(false);
|
||||
if (result?.IsNotFoundResult != false) return NotFound();
|
||||
if (!result.IsSuccess)
|
||||
{
|
||||
if (result.IsAccessDeniedResult)
|
||||
|
@ -293,8 +286,8 @@ namespace Roadie.Api.Controllers
|
|||
return StatusCode((int)HttpStatusCode.InternalServerError);
|
||||
}
|
||||
CacheManager.ClearRegion(ControllerCacheRegionUrn);
|
||||
var modelUser = await UserManager.FindByNameAsync(model.UserName);
|
||||
var t = await TokenService.GenerateToken(modelUser, UserManager);
|
||||
var modelUser = await UserManager.FindByNameAsync(model.UserName).ConfigureAwait(false);
|
||||
var t = await TokenService.GenerateToken(modelUser, UserManager).ConfigureAwait(false);
|
||||
CacheManager.ClearRegion(ControllerCacheRegionUrn);
|
||||
var avatarUrl = $"{RoadieHttpContext.ImageBaseUrl}/user/{modelUser.RoadieId}/{RoadieSettings.ThumbnailImageSize.Width}/{RoadieSettings.ThumbnailImageSize.Height}";
|
||||
return Ok(new
|
||||
|
|
Loading…
Add table
Reference in a new issue