mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-21 05:43:19 -07:00
Added the language to the user profile and fixed a putin bug
This commit is contained in:
parent
e1265046b5
commit
282f5a5d4e
10 changed files with 2403 additions and 9 deletions
|
@ -72,7 +72,7 @@ namespace Ombi.Core.Engine.V2
|
|||
}
|
||||
|
||||
// Setup the task so we can get the data later on if we have a IMDBID
|
||||
Task<TraktShow> traktInfoTask = new Task<TraktShow>(() => null);
|
||||
Task<TraktShow> traktInfoTask = null;
|
||||
if (show.externals?.imdb.HasValue() ?? false)
|
||||
{
|
||||
traktInfoTask = Cache.GetOrAdd("GetExtendedTvInfoTrakt" + show.externals?.imdb,
|
||||
|
@ -168,16 +168,18 @@ namespace Ombi.Core.Engine.V2
|
|||
|
||||
private async Task<SearchFullInfoTvShowViewModel> GetExtraInfo(Task<TraktShow> showInfoTask, SearchFullInfoTvShowViewModel model)
|
||||
{
|
||||
var result = await showInfoTask;
|
||||
if (result == null)
|
||||
if (showInfoTask != null)
|
||||
{
|
||||
return model;
|
||||
var result = await showInfoTask;
|
||||
if (result == null)
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
model.Trailer = result.Trailer?.AbsoluteUri ?? string.Empty;
|
||||
model.Certification = result.Certification;
|
||||
model.Homepage = result.Homepage?.AbsoluteUri ?? string.Empty;
|
||||
}
|
||||
|
||||
model.Trailer = result.Trailer?.AbsoluteUri ?? string.Empty;
|
||||
model.Certification = result.Certification;
|
||||
model.Homepage = result.Homepage?.AbsoluteUri ?? string.Empty;
|
||||
|
||||
return model;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,8 @@ namespace Ombi.Store.Entities
|
|||
|
||||
public string EmbyConnectUserId { get; set; }
|
||||
|
||||
public string Language { get; set; }
|
||||
|
||||
public int? MovieRequestLimit { get; set; }
|
||||
public int? EpisodeRequestLimit { get; set; }
|
||||
public int? MusicRequestLimit { get; set; }
|
||||
|
|
1155
src/Ombi.Store/Migrations/OmbiMySql/20200610223540_UserProfile.Designer.cs
generated
Normal file
1155
src/Ombi.Store/Migrations/OmbiMySql/20200610223540_UserProfile.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,23 @@
|
|||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace Ombi.Store.Migrations.OmbiMySql
|
||||
{
|
||||
public partial class UserProfile : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "Language",
|
||||
table: "AspNetUsers",
|
||||
nullable: true);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Language",
|
||||
table: "AspNetUsers");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -269,6 +269,9 @@ namespace Ombi.Store.Migrations.OmbiMySql
|
|||
b.Property<int?>("EpisodeRequestLimit")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Language")
|
||||
.HasColumnType("longtext CHARACTER SET utf8mb4");
|
||||
|
||||
b.Property<DateTime?>("LastLoggedIn")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
|
@ -592,6 +595,9 @@ namespace Ombi.Store.Migrations.OmbiMySql
|
|||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("CreatedDate")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasColumnType("longtext CHARACTER SET utf8mb4");
|
||||
|
||||
|
|
1154
src/Ombi.Store/Migrations/OmbiSqlite/20200610223651_UserProfile.Designer.cs
generated
Normal file
1154
src/Ombi.Store/Migrations/OmbiSqlite/20200610223651_UserProfile.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,22 @@
|
|||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace Ombi.Store.Migrations.OmbiSqlite
|
||||
{
|
||||
public partial class UserProfile : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "Language",
|
||||
table: "AspNetUsers",
|
||||
nullable: true);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Language",
|
||||
table: "AspNetUsers");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -268,6 +268,9 @@ namespace Ombi.Store.Migrations.OmbiSqlite
|
|||
b.Property<int?>("EpisodeRequestLimit")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Language")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime?>("LastLoggedIn")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
|
|
|
@ -286,6 +286,21 @@ namespace Ombi.Controllers.V1
|
|||
return await GetUserWithRoles(user);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the current users language
|
||||
/// </summary>
|
||||
[HttpPost("language")]
|
||||
[Authorize]
|
||||
public async Task<IActionResult> SetCurrentUserLanguage([FromBody] UserLanguage model)
|
||||
{
|
||||
var username = User.Identity.Name.ToUpper();
|
||||
var user = await UserManager.Users.FirstOrDefaultAsync(x => x.NormalizedUserName == username);
|
||||
user.Language = model.Lang;
|
||||
|
||||
await UserManager.UpdateAsync(user);
|
||||
return Ok();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the user by the user id.
|
||||
/// </summary>
|
||||
|
|
12
src/Ombi/Models/Identity/UserLanguage.cs
Normal file
12
src/Ombi/Models/Identity/UserLanguage.cs
Normal file
|
@ -0,0 +1,12 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Ombi.Models.Identity
|
||||
{
|
||||
public class UserLanguage
|
||||
{
|
||||
public string Lang { get; set; }
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue