懒得勤快 4 years ago
parent
commit
670ba8e1dd

+ 5 - 1
src/Masuit.MyBlogs.Core/Common/ImagebedClient.cs

@@ -56,7 +56,11 @@ namespace Masuit.MyBlogs.Core.Common
             }
 
             file = SnowFlake.NewId + Path.GetExtension(file);
-            var fallbackPolicy = Policy<(string url, bool success)>.Handle<Exception>().FallbackAsync(async _ => UploadOss(stream, file));
+            var fallbackPolicy = Policy<(string url, bool success)>.Handle<Exception>().FallbackAsync(async _ =>
+            {
+                await Task.CompletedTask;
+                return UploadOss(stream, file);
+            });
             var retryPolicy = Policy<(string url, bool success)>.Handle<Exception>().RetryAsync(3);
             return await fallbackPolicy.WrapAsync(retryPolicy).ExecuteAsync(() => UploadGitlab(stream, file));
         }

+ 3 - 3
src/Masuit.MyBlogs.Core/Extensions/Firewall/FirewallAttribute.cs

@@ -87,7 +87,7 @@ namespace Masuit.MyBlogs.Core.Extensions.Firewall
             throw new TempDenyException("访问频次限制");
         }
 
-        private void AccessDeny(string ip, HttpRequest request, string remark)
+        private async void AccessDeny(string ip, HttpRequest request, string remark)
         {
             var path = HttpUtility.UrlDecode(request.Path + request.QueryString, Encoding.UTF8);
             BackgroundJob.Enqueue(() => HangfireBackJob.InterceptLog(new IpIntercepter()
@@ -99,14 +99,14 @@ namespace Masuit.MyBlogs.Core.Extensions.Firewall
                 Remark = remark
             }));
             var limit = CommonHelper.SystemSettings.GetOrAdd("LimitIPInterceptTimes", "30").ToInt32();
-            RedisHelper.LRangeAsync<IpIntercepter>("intercept", 0, -1).ContinueWith(async t =>
+            await RedisHelper.LRangeAsync<IpIntercepter>("intercept", 0, -1).ContinueWith(async t =>
             {
                 if (t.Result.Count(x => x.IP == ip) >= limit)
                 {
                     LogManager.Info($"准备上报IP{ip}到{FirewallRepoter.ReporterName}");
                     await FirewallRepoter.ReportAsync(IPAddress.Parse(ip)).ContinueWith(_ => LogManager.Info($"访问频次限制,已上报IP{ip}至:" + FirewallRepoter.ReporterName));
                 }
-            }).ConfigureAwait(false);
+            });
         }
     }
 }

+ 3 - 3
src/Masuit.MyBlogs.Core/Masuit.MyBlogs.Core.csproj

@@ -33,7 +33,7 @@
     <ItemGroup>
         <PackageReference Include="Aliyun.OSS.SDK.NetCore" Version="2.12.0" />
         <PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
-        <PackageReference Include="AutoMapper.Extensions.ExpressionMapping" Version="4.0.2" />
+        <PackageReference Include="AutoMapper.Extensions.ExpressionMapping" Version="4.1.0" />
         <PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.1.0" />
         <PackageReference Include="CacheManager.Microsoft.Extensions.Caching.Memory" Version="2.0.0-beta-1629" />
         <PackageReference Include="CacheManager.Serialization.Json" Version="2.0.0-beta-1629" />
@@ -55,11 +55,11 @@
         <PackageReference Include="Polly" Version="7.2.1" />
         <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="5.0.0-alpha.2" />
         <PackageReference Include="Svg" Version="3.1.1" />
-        <PackageReference Include="System.Linq.Dynamic.Core" Version="1.2.5" />
+        <PackageReference Include="System.Linq.Dynamic.Core" Version="1.2.6" />
         <PackageReference Include="TimeZoneConverter" Version="3.3.0" />
         <PackageReference Include="WilderMinds.RssSyndication" Version="1.7.0" />
         <PackageReference Include="WinInsider.System.Net.Http.Formatting" Version="1.0.14" />
-        <PackageReference Include="Z.EntityFramework.Plus.EFCore" Version="5.1.2" />
+        <PackageReference Include="Z.EntityFramework.Plus.EFCore" Version="5.1.4" />
     </ItemGroup>
     <ItemGroup>
         <Content Update="appsettings.json">

+ 3 - 4
src/Masuit.MyBlogs.Core/Startup.cs

@@ -30,7 +30,6 @@ using Microsoft.AspNetCore.Http.Features;
 using Microsoft.AspNetCore.HttpOverrides;
 using Microsoft.AspNetCore.Rewrite;
 using Microsoft.AspNetCore.StaticFiles;
-using Microsoft.AspNetCore.WebSockets;
 using Microsoft.EntityFrameworkCore;
 using Microsoft.Extensions.Configuration;
 using Microsoft.Extensions.DependencyInjection;
@@ -107,12 +106,12 @@ namespace Masuit.MyBlogs.Core
             {
                 options.MultipartBodyLengthLimit = 104857600; // 100MB
             }); //配置请求长度
-            services.AddSession().AddAntiforgery(); //注入Session
-            services.AddWebSockets(opt => opt.ReceiveBufferSize = 4096 * 1024).AddSignalR().AddNewtonsoftJsonProtocol();
             services.AddHttpsRedirection(options =>
             {
                 options.RedirectStatusCode = StatusCodes.Status301MovedPermanently;
             });
+            services.AddSession().AddAntiforgery(); //注入Session
+            services.AddSignalR().AddNewtonsoftJsonProtocol();
 
             services.AddResponseCache().AddCacheConfig();
             services.AddHangfire((provider, configuration) =>
@@ -217,7 +216,7 @@ namespace Masuit.MyBlogs.Core
                 }
             }); //配置hangfire
             app.UseResponseCaching().UseResponseCompression(); //启动Response缓存
-            app.UseActivity();// 抽奖活动
+            //app.UseActivity();// 抽奖活动
             app.UseRouting(); // 放在 UseStaticFiles 之后
             app.UseEndpoints(endpoints =>
             {