mirror of
				https://github.com/zoriya/Kyoo.git
				synced 2025-10-31 02:27:11 -04:00 
			
		
		
		
	Fix gravatar proxy
This commit is contained in:
		
							parent
							
								
									b43b6d6f75
								
							
						
					
					
						commit
						c26a95ed60
					
				| @ -1,7 +1,7 @@ | |||||||
| <Project> | <Project> | ||||||
| 	<PropertyGroup> | 	<PropertyGroup> | ||||||
| 		<TargetFramework>net7.0</TargetFramework> | 		<TargetFramework>net7.0</TargetFramework> | ||||||
| 		<LangVersion>default</LangVersion> | 		<LangVersion>preview</LangVersion> | ||||||
| 		<Company>Kyoo</Company> | 		<Company>Kyoo</Company> | ||||||
| 		<Authors>Kyoo</Authors> | 		<Authors>Kyoo</Authors> | ||||||
| 		<Copyright>Copyright (c) Kyoo</Copyright> | 		<Copyright>Copyright (c) Kyoo</Copyright> | ||||||
|  | |||||||
| @ -30,7 +30,8 @@ namespace Kyoo.Abstractions.Models.Exceptions | |||||||
| 		/// <summary> | 		/// <summary> | ||||||
| 		/// Create a default <see cref="ItemNotFoundException"/> with no message. | 		/// Create a default <see cref="ItemNotFoundException"/> with no message. | ||||||
| 		/// </summary> | 		/// </summary> | ||||||
| 		public ItemNotFoundException() { } | 		public ItemNotFoundException() | ||||||
|  | 			: base("Item not found") { } | ||||||
| 
 | 
 | ||||||
| 		/// <summary> | 		/// <summary> | ||||||
| 		/// Create a new <see cref="ItemNotFoundException"/> with a message | 		/// Create a new <see cref="ItemNotFoundException"/> with a message | ||||||
|  | |||||||
| @ -219,17 +219,18 @@ namespace Kyoo.Core.Controllers | |||||||
| 			try | 			try | ||||||
| 			{ | 			{ | ||||||
| 				await using FileStream img = File.Open( | 				await using FileStream img = File.Open( | ||||||
| 					$"/metadata/user/${userId}.webp", | 					$"/metadata/user/{userId}.webp", | ||||||
| 					FileMode.Open | 					FileMode.Open | ||||||
| 				); | 				); | ||||||
| 				return img; | 				return img; | ||||||
| 			} | 			} | ||||||
| 			catch (FileNotFoundException) { } | 			catch (FileNotFoundException) { } | ||||||
|  | 			catch (DirectoryNotFoundException) { } | ||||||
| 
 | 
 | ||||||
| 			User user = await users.Value.Get(userId); | 			User user = await users.Value.Get(userId); | ||||||
| 			if (user.Email == null) throw new ItemNotFoundException(); | 			if (user.Email == null) throw new ItemNotFoundException(); | ||||||
| 			using MD5 md5 = MD5.Create(); | 			using MD5 md5 = MD5.Create(); | ||||||
| 			string hash = Convert.ToHexString(md5.ComputeHash(Encoding.ASCII.GetBytes(user.Email))); | 			string hash = Convert.ToHexString(md5.ComputeHash(Encoding.ASCII.GetBytes(user.Email))).ToLower(); | ||||||
| 			try | 			try | ||||||
| 			{ | 			{ | ||||||
| 				HttpClient client = clientFactory.CreateClient(); | 				HttpClient client = clientFactory.CreateClient(); | ||||||
| @ -250,7 +251,8 @@ namespace Kyoo.Core.Controllers | |||||||
| 			info.ColorType = SKColorType.Rgba8888; | 			info.ColorType = SKColorType.Rgba8888; | ||||||
| 			using SKBitmap original = SKBitmap.Decode(codec, info); | 			using SKBitmap original = SKBitmap.Decode(codec, info); | ||||||
| 			using SKBitmap ret = original.Resize(new SKSizeI(250, 250), SKFilterQuality.High); | 			using SKBitmap ret = original.Resize(new SKSizeI(250, 250), SKFilterQuality.High); | ||||||
| 			await _WriteTo(ret, $"/metadata/user/${userId}.webp", 75); | 			Directory.CreateDirectory("/metadata/user"); | ||||||
|  | 			await _WriteTo(ret, $"/metadata/user/{userId}.webp", 75); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  | |||||||
| @ -30,19 +30,12 @@ namespace Kyoo.Core | |||||||
| 	/// <summary> | 	/// <summary> | ||||||
| 	/// A middleware to handle errors globally. | 	/// A middleware to handle errors globally. | ||||||
| 	/// </summary> | 	/// </summary> | ||||||
| 	public class ExceptionFilter : IExceptionFilter | 	/// <remarks> | ||||||
| 	{ |  | ||||||
| 		private readonly ILogger _logger; |  | ||||||
| 
 |  | ||||||
| 		/// <summary> |  | ||||||
| 	/// Initializes a new instance of the <see cref="ExceptionFilter"/> class. | 	/// Initializes a new instance of the <see cref="ExceptionFilter"/> class. | ||||||
| 		/// </summary> | 	/// </remarks> | ||||||
| 	/// <param name="logger">The logger used to log errors.</param> | 	/// <param name="logger">The logger used to log errors.</param> | ||||||
| 		public ExceptionFilter(ILogger<ExceptionFilter> logger) | 	public class ExceptionFilter(ILogger<ExceptionFilter> logger) : IExceptionFilter | ||||||
| 	{ | 	{ | ||||||
| 			_logger = logger; |  | ||||||
| 		} |  | ||||||
| 
 |  | ||||||
| 		/// <inheritdoc/> | 		/// <inheritdoc/> | ||||||
| 		public void OnException(ExceptionContext context) | 		public void OnException(ExceptionContext context) | ||||||
| 		{ | 		{ | ||||||
| @ -65,7 +58,7 @@ namespace Kyoo.Core | |||||||
| 					context.Result = new UnauthorizedObjectResult(new RequestError(ex.Message)); | 					context.Result = new UnauthorizedObjectResult(new RequestError(ex.Message)); | ||||||
| 					break; | 					break; | ||||||
| 				case Exception ex: | 				case Exception ex: | ||||||
| 					_logger.LogError(ex, "Unhandled error"); | 					logger.LogError(ex, "Unhandled error"); | ||||||
| 					context.Result = new ServerErrorObjectResult( | 					context.Result = new ServerErrorObjectResult( | ||||||
| 						new RequestError("Internal Server Error") | 						new RequestError("Internal Server Error") | ||||||
| 					); | 					); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user