33using Grand . Business . Core . Interfaces . Common . Localization ;
44using Grand . Business . Core . Interfaces . Common . Stores ;
55using Grand . Business . Core . Interfaces . Customers ;
6+ using Grand . Business . Core . Interfaces . Messages ;
67using Grand . Domain . Common ;
78using Grand . Domain . Customers ;
89using Grand . Domain . Localization ;
1920using Grand . Web . Features . Models . Common ;
2021using Grand . Web . Models . Common ;
2122using MediatR ;
23+ using Microsoft . AspNetCore . Authorization ;
2224using Microsoft . AspNetCore . Http ;
2325using Microsoft . AspNetCore . Mvc ;
2426using System . Net ;
@@ -375,7 +377,8 @@ public virtual async Task<IActionResult> PrivacyPreference([FromServices] StoreI
375377 Store = _workContext . CurrentStore
376378 } ) ;
377379
378- return Json ( new {
380+ return Json ( new
381+ {
379382 html = await this . RenderPartialViewToString ( "PrivacyPreference" , model , true ) ,
380383 model
381384 } ) ;
@@ -455,5 +458,43 @@ public virtual async Task<IActionResult> SaveCurrentPosition(
455458 return Content ( "" ) ;
456459 }
457460
461+ [ AllowAnonymous ]
462+ [ IgnoreApi ]
463+ [ HttpGet ]
464+ public virtual async Task < IActionResult > QueuedEmail ( [ FromServices ] IQueuedEmailService queuedEmailService , string emailId )
465+ {
466+ if ( string . IsNullOrEmpty ( emailId ) )
467+ {
468+ return GetTrackingPixel ( ) ;
469+ }
470+
471+ var isFromAdmin = Request . GetTypedHeaders ( ) . Referer ? . ToString ( ) ? . Contains ( "admin/queuedemail/edit/" ,
472+ StringComparison . OrdinalIgnoreCase ) ?? false ;
473+
474+ if ( ! isFromAdmin )
475+ {
476+ var queuedEmail = await queuedEmailService . GetQueuedEmailById ( emailId ) ;
477+ if ( queuedEmail != null && queuedEmail . ReadOnUtc == null )
478+ {
479+ queuedEmail . ReadOnUtc = DateTime . UtcNow ;
480+ await queuedEmailService . UpdateQueuedEmail ( queuedEmail ) ;
481+ }
482+ }
483+
484+ return GetTrackingPixel ( ) ;
485+
486+ IActionResult GetTrackingPixel ( )
487+ {
488+
489+ const string TRACKING_PIXEL = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=" ;
490+ return File (
491+ Convert . FromBase64String ( TRACKING_PIXEL ) ,
492+ "image/png" ,
493+ "pixel.png"
494+ ) ;
495+ }
496+
497+ }
498+
458499 #endregion
459500}
0 commit comments