Skip to content

Commit

Permalink
#2363 Added the ability to pass any username into the API using the A…
Browse files Browse the repository at this point in the history
…piAlias header
  • Loading branch information
tidusjar committed Jan 16, 2019
1 parent 359d191 commit 3b91392
Show file tree
Hide file tree
Showing 18 changed files with 1,455 additions and 116 deletions.
3 changes: 2 additions & 1 deletion src/Ombi.Core/Engine/MovieRequestEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ public async Task<RequestEngineResult> RequestMovie(MovieRequestViewModel model)
Approved = false,
RequestedUserId = userDetails.Id,
Background = movieInfo.BackdropPath,
LangCode = model.LanguageCode
LangCode = model.LanguageCode,
RequestedByAlias = model.RequestedByAlias
};

var usDates = movieInfo.ReleaseDates?.Results?.FirstOrDefault(x => x.IsoCode == "US");
Expand Down
3 changes: 2 additions & 1 deletion src/Ombi.Core/Engine/MusicRequestEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ public async Task<RequestEngineResult> RequestAlbum(MusicAlbumRequestViewModel m
Title = album.title,
Disk = album.images?.FirstOrDefault(x => x.coverType.Equals("disc"))?.url,
Cover = album.images?.FirstOrDefault(x => x.coverType.Equals("cover"))?.url,
ForeignArtistId = album?.artist?.foreignArtistId ?? string.Empty
ForeignArtistId = album?.artist?.foreignArtistId ?? string.Empty,
RequestedByAlias = model.RequestedByAlias
};
if (requestModel.Cover.IsNullOrEmpty())
{
Expand Down
1 change: 1 addition & 0 deletions src/Ombi.Core/Helpers/TvShowRequestBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public TvShowRequestBuilder CreateChild(TvRequestViewModel model, string userId)
SeasonRequests = new List<SeasonRequests>(),
Title = ShowInfo.name,
ReleaseYear = FirstAir,
RequestedByAlias = model.RequestedByAlias,
SeriesType = ShowInfo.genres.Any( s => s.Equals("Anime", StringComparison.InvariantCultureIgnoreCase)) ? SeriesType.Anime : SeriesType.Standard
};

Expand Down
9 changes: 9 additions & 0 deletions src/Ombi.Core/Models/Requests/MovieRequestViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,20 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ************************************************************************/
#endregion

using Newtonsoft.Json;

namespace Ombi.Core.Models.Requests
{
public class MovieRequestViewModel
{
public int TheMovieDbId { get; set; }
public string LanguageCode { get; set; } = "en";

/// <summary>
/// This is only set from a HTTP Header
/// </summary>
[JsonIgnore]
public string RequestedByAlias { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
public class MusicAlbumRequestViewModel
{
public string ForeignAlbumId { get; set; }
public string RequestedByAlias { get; set; }
}
}
3 changes: 3 additions & 0 deletions src/Ombi.Core/Models/Requests/TvRequestViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using Newtonsoft.Json;

namespace Ombi.Core.Models.Requests
{
Expand All @@ -9,6 +10,8 @@ public class TvRequestViewModel
public bool FirstSeason { get; set; }
public int TvDbId { get; set; }
public List<SeasonsViewModel> Seasons { get; set; } = new List<SeasonsViewModel>();
[JsonIgnore]
public string RequestedByAlias { get; set; }
}

public class SeasonsViewModel
Expand Down
2 changes: 1 addition & 1 deletion src/Ombi.Store/Entities/OmbiUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class OmbiUser : IdentityUser
public bool IsEmbyConnect => UserType == UserType.EmbyUser && EmbyConnectUserId.HasValue();

[NotMapped]
public string UserAlias => string.IsNullOrEmpty(Alias) ? UserName : Alias;
public virtual string UserAlias => string.IsNullOrEmpty(Alias) ? UserName : Alias;

[NotMapped]
public bool EmailLogin { get; set; }
Expand Down
1 change: 1 addition & 0 deletions src/Ombi.Store/Entities/Requests/BaseRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class BaseRequest : Entity
public DateTime MarkedAsDenied { get; set; }
public string DeniedReason { get; set; }
public RequestType RequestType { get; set; }
public string RequestedByAlias { get; set; }

[ForeignKey(nameof(RequestedUserId))]
public OmbiUser RequestedUser { get; set; }
Expand Down
Loading

0 comments on commit 3b91392

Please sign in to comment.