Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

Cleanup (#548)

Krzysztof Pajak97c689950dbc
diff --git a/src/Core/Grand.Domain/Common/CommonSettings.cs b/src/Core/Grand.Domain/Common/CommonSettings.cs
index 1ba09927e..465504c5b 100644
--- a/src/Core/Grand.Domain/Common/CommonSettings.cs
+++ b/src/Core/Grand.Domain/Common/CommonSettings.cs
@@ -39,9 +39,4 @@ public class CommonSettings : ISettings
/// Gets or sets to edit product where auction ended
/// </summary>
public bool AllowEditProductEndedAuction { get; set; }
-
- /// <summary>
- /// Gets or sets - allow user to read "let's encrypted file"
- /// </summary>
- public bool AllowToReadLetsEncryptFile { get; set; }
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Admin/App_Data/GeoLite2-Country.mmdb b/src/Web/Grand.Web.Admin/App_Data/GeoLite2-Country.mmdb
deleted file mode 100644
index 6948a5244..000000000
Binary files a/src/Web/Grand.Web.Admin/App_Data/GeoLite2-Country.mmdb and /dev/null differ
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Setting/Partials/GeneralCommon.TabStoreInformationSettings.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Setting/Partials/GeneralCommon.TabStoreInformationSettings.cshtml
index a8d1a6c28..bee83c203 100644
--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Setting/Partials/GeneralCommon.TabStoreInformationSettings.cshtml
+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Setting/Partials/GeneralCommon.TabStoreInformationSettings.cshtml
@@ -253,18 +253,6 @@
<span asp-validation-for="CommonSettings.UseSystemEmailForContactUsForm"></span>
</div>
</div>
-<div class="form-group">
- <div class="col-8 col-md-4 col-sm-4 text-right">
- <admin-label asp-for="CommonSettings.AllowToReadLetsEncryptFile" class="control-label"/>
- </div>
- <div class="col-4 col-md-8 col-sm-8">
- <label class="mt-checkbox mt-checkbox-outline control control-checkbox">
- <admin-input asp-for="CommonSettings.AllowToReadLetsEncryptFile"/>
- <div class="control__indicator"></div>
- </label>
- <span asp-validation-for="CommonSettings.AllowToReadLetsEncryptFile"></span>
- </div>
-</div>
<div class="form-group">
<div class="col-8 col-md-4 col-sm-4 text-right">
<admin-label asp-for="CommonSettings.AllowToSelectStore" class="control-label"/>
diff --git a/src/Web/Grand.Web.Admin/Models/Settings/GeneralCommonSettingsModel.cs b/src/Web/Grand.Web.Admin/Models/Settings/GeneralCommonSettingsModel.cs
index 8f9d27e44..fffb72f50 100644
--- a/src/Web/Grand.Web.Admin/Models/Settings/GeneralCommonSettingsModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Settings/GeneralCommonSettingsModel.cs
@@ -94,9 +94,6 @@ public class GeneralCommonSettingsModel : BaseModel
[GrandResourceDisplayName("Admin.Settings.GeneralCommon.UseSystemEmailForContactUsForm")]
public bool UseSystemEmailForContactUsForm { get; set; }
- [GrandResourceDisplayName("Admin.Settings.GeneralCommon.AllowToReadLetsEncryptFile")]
- public bool AllowToReadLetsEncryptFile { get; set; }
-
[GrandResourceDisplayName("Admin.Settings.GeneralCommon.AllowToSelectStore")]
public bool AllowToSelectStore { get; set; }
diff --git a/src/Web/Grand.Web.Vendor/App_Data/GeoLite2-Country.mmdb b/src/Web/Grand.Web.Vendor/App_Data/GeoLite2-Country.mmdb
deleted file mode 100644
index 6948a5244..000000000
Binary files a/src/Web/Grand.Web.Vendor/App_Data/GeoLite2-Country.mmdb and /dev/null differ
diff --git a/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xml b/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xml
index c92c6ce0d..c1cf91358 100644
--- a/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xml
+++ b/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xml
@@ -10107,9 +10107,6 @@
<Resource Name="Admin.Settings.GeneralCommon.AllowSlashChar" Area="Admin">
<Value>Allow to use slash char</Value>
</Resource>
- <Resource Name="Admin.Settings.GeneralCommon.AllowToReadLetsEncryptFile" Area="Admin">
- <Value>Allow to read Let's Encrypt file</Value>
- </Resource>
<Resource Name="Admin.Settings.GeneralCommon.AllowToSelectAdminTheme" Area="Admin">
<Value>Allow to select admin theme</Value>
</Resource>
diff --git a/src/Web/Grand.Web/Controllers/CommonController.cs b/src/Web/Grand.Web/Controllers/CommonController.cs
index 1d03af0a6..080c23cda 100644
--- a/src/Web/Grand.Web/Controllers/CommonController.cs
+++ b/src/Web/Grand.Web/Controllers/CommonController.cs
@@ -3,6 +3,7 @@ using Grand.Business.Core.Interfaces.Common.Directory;
using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Business.Core.Interfaces.Common.Stores;
using Grand.Business.Core.Interfaces.Customers;
+using Grand.Business.Core.Interfaces.Messages;
using Grand.Domain.Common;
using Grand.Domain.Customers;
using Grand.Domain.Localization;
@@ -19,6 +20,7 @@ using Grand.Web.Events;
using Grand.Web.Features.Models.Common;
using Grand.Web.Models.Common;
using MediatR;
+using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Net;
@@ -375,7 +377,8 @@ public class CommonController : BasePublicController
Store = _workContext.CurrentStore
});
- return Json(new {
+ return Json(new
+ {
html = await this.RenderPartialViewToString("PrivacyPreference", model, true),
model
});
@@ -455,5 +458,43 @@ public class CommonController : BasePublicController
return Content("");
}
+ [AllowAnonymous]
+ [IgnoreApi]
+ [HttpGet]
+ public virtual async Task<IActionResult> QueuedEmail([FromServices] IQueuedEmailService queuedEmailService, string emailId)
+ {
+ if (string.IsNullOrEmpty(emailId))
+ {
+ return GetTrackingPixel();
+ }
+
+ var isFromAdmin = Request.GetTypedHeaders().Referer?.ToString()?.Contains("admin/queuedemail/edit/",
+ StringComparison.OrdinalIgnoreCase) ?? false;
+
+ if (!isFromAdmin)
+ {
+ var queuedEmail = await queuedEmailService.GetQueuedEmailById(emailId);
+ if (queuedEmail != null && queuedEmail.ReadOnUtc == null)
+ {
+ queuedEmail.ReadOnUtc = DateTime.UtcNow;
+ await queuedEmailService.UpdateQueuedEmail(queuedEmail);
+ }
+ }
+
+ return GetTrackingPixel();
+
+ IActionResult GetTrackingPixel()
+ {
+
+ const string TRACKING_PIXEL = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=";
+ return File(
+ Convert.FromBase64String(TRACKING_PIXEL),
+ "image/png",
+ "pixel.png"
+ );
+ }
+
+ }
+
#endregion
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Controllers/LetsEncryptController.cs b/src/Web/Grand.Web/Controllers/LetsEncryptController.cs
deleted file mode 100644
index b00e36952..000000000
--- a/src/Web/Grand.Web/Controllers/LetsEncryptController.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using Grand.Business.Core.Interfaces.Storage;
-using Grand.Domain.Common;
-using Microsoft.AspNetCore.Authorization;
-using Microsoft.AspNetCore.Mvc;
-
-namespace Grand.Web.Controllers;
-
-[AllowAnonymous]
-public class LetsEncryptController : Controller
-{
- private readonly CommonSettings _commonSettings;
- private readonly IMediaFileStore _mediaFileStore;
-
- public LetsEncryptController(CommonSettings commonSettings, IMediaFileStore mediaFileStore)
- {
- _commonSettings = commonSettings;
- _mediaFileStore = mediaFileStore;
- }
-
- public virtual async Task<IActionResult> Index(string fileName)
- {
- if (!_commonSettings.AllowToReadLetsEncryptFile)
- return Content("");
-
- if (fileName == null)
- return Content("");
-
- var filepath = _mediaFileStore.Combine("assets", "acme", Path.GetFileName(fileName));
- var fileInfo = await _mediaFileStore.GetFileInfo(filepath);
- if (fileInfo != null) return File(await _mediaFileStore.ReadAllText(filepath), "text/plain");
- return Content("");
- }
-}
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Controllers/PixelController.cs b/src/Web/Grand.Web/Controllers/PixelController.cs
deleted file mode 100644
index d406b149d..000000000
--- a/src/Web/Grand.Web/Controllers/PixelController.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-using Grand.Business.Core.Interfaces.Messages;
-using Grand.Web.Common.Controllers;
-using Microsoft.AspNetCore.Authorization;
-using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Mvc;
-
-namespace Grand.Web.Controllers;
-
-[AllowAnonymous]
-public class PixelController : BaseController
-{
- public virtual async Task<IActionResult> QueuedEmail(
- [FromServices] IQueuedEmailService queuedEmailService,
- string emailId)
- {
- if (!string.IsNullOrEmpty(emailId) && !(Request.GetTypedHeaders().Referer?.ToString() is { } referer &&
- referer.ToLowerInvariant()
- .Contains("admin/queuedemail/edit/".ToLowerInvariant())))
- {
- var eueuedEmail = await queuedEmailService.GetQueuedEmailById(emailId);
- if (eueuedEmail is not { ReadOnUtc: null })
- return File(
- Convert.FromBase64String(
- "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="),
- "image/png", "pixel.png");
- eueuedEmail.ReadOnUtc = DateTime.UtcNow;
- await queuedEmailService.UpdateQueuedEmail(eueuedEmail);
- }
-
- return File(
- Convert.FromBase64String(
- "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="),
- "image/png", "pixel.png");
- }
-}
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Endpoints/EndpointProvider.cs b/src/Web/Grand.Web/Endpoints/EndpointProvider.cs
index b6b41f456..e7948a550 100644
--- a/src/Web/Grand.Web/Endpoints/EndpointProvider.cs
+++ b/src/Web/Grand.Web/Endpoints/EndpointProvider.cs
@@ -453,7 +453,7 @@ public class EndpointProvider : IEndpointProvider
//pixel
endpointRouteBuilder.MapControllerRoute("PixelQueuedEmail",
"queuedemail/pixel.png",
- new { controller = "Pixel", action = "QueuedEmail" });
+ new { controller = "Common", action = "QueuedEmail" });
}
private void RegisterBlogRoute(IEndpointRouteBuilder endpointRouteBuilder, string pattern)