This commit is contained in:
2023-02-21 23:15:23 +00:00
parent 27a43e5e38
commit 7d8bbb651d
7 changed files with 806 additions and 792 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -41,7 +41,7 @@ namespace Sockeye.Biz
////////////////////////////////////////////////////////////////////////////////////////////////
//CREATE
//
internal async Task<TrialLicenseRequest> CreateAsync(TrialLicenseRequest newObject, bool importingDoNotNotify = false)
internal async Task<TrialLicenseRequest> CreateAsync(TrialLicenseRequest newObject)
{
await ValidateAsync(newObject, null);
if (HasErrors)
@@ -53,8 +53,7 @@ namespace Sockeye.Biz
//Process a new request / Generate an email confirm code
newObject.EmailConfirmCode = StringUtil.GenFetchCode();
newObject.EmailValidated = false;
if (!importingDoNotNotify)
newObject.Status = TrialRequestStatus.AwaitingEmailValidation;
newObject.Status = TrialRequestStatus.AwaitingEmailValidation;
await ct.TrialLicenseRequest.AddAsync(newObject);
await ct.SaveChangesAsync();
@@ -63,37 +62,36 @@ namespace Sockeye.Biz
await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null);
if (!importingDoNotNotify)
//## ------------------ DEFAULT NOTIFICATIONS TO CUSTOMER ----------------
//ValidateEmail request message,RavenTrialApproved (which sends pending manual generation message) and RavenTrialRejected messages are sent in this block
//
//Send verification request
var verifyUrl = ServerGlobalOpsSettingsCache.Notify.SockeyeServerURL.Trim().TrimEnd('/') + $"/rvr/verify/{newObject.EmailConfirmCode}";
var body = ServerGlobalBizSettings.Cache.ValidateEmail.Replace("{verifyUrl}", verifyUrl);//$"Please verify your email address by clicking the link below or copy and pasting into a browser\r\n{verifyUrl}\r\nOnce your email is verified the request will be processed manually during business hours.\r\n(If you did not request this you can ignore this message)";
var notifyDirectSMTP = new Sockeye.Api.Controllers.NotifyController.NotifyDirectSMTP()
{
//## ------------------ DEFAULT NOTIFICATIONS TO CUSTOMER ----------------
//ValidateEmail request message,RavenTrialApproved (which sends pending manual generation message) and RavenTrialRejected messages are sent in this block
//
//Send verification request
var verifyUrl = ServerGlobalOpsSettingsCache.Notify.SockeyeServerURL.Trim().TrimEnd('/') + $"/rvr/verify/{newObject.EmailConfirmCode}";
var body = ServerGlobalBizSettings.Cache.ValidateEmail.Replace("{verifyUrl}", verifyUrl);//$"Please verify your email address by clicking the link below or copy and pasting into a browser\r\n{verifyUrl}\r\nOnce your email is verified the request will be processed manually during business hours.\r\n(If you did not request this you can ignore this message)";
var notifyDirectSMTP = new Sockeye.Api.Controllers.NotifyController.NotifyDirectSMTP()
{
ToAddress = newObject.Email,
Subject = "AyaNova trial request email verification",
TextBody = body
};
ToAddress = newObject.Email,
Subject = "AyaNova trial request email verification",
TextBody = body
};
IMailer m = Sockeye.Util.ServiceProviderProvider.Mailer;
try
{
await m.SendEmailAsync(notifyDirectSMTP.ToAddress, notifyDirectSMTP.Subject, notifyDirectSMTP.TextBody, ServerGlobalOpsSettingsCache.Notify, null, null, null);
await EventLogProcessor.LogEventToDatabaseAsync(new Event(1, notifyDirectSMTP.ObjectId, notifyDirectSMTP.SockType, SockEvent.DirectSMTP, $"\"{notifyDirectSMTP.Subject}\"->{notifyDirectSMTP.ToAddress}"), ct);
}
catch (Exception ex)
{
var err = "TrialLicenseRequest sending email confirmation request: SMTP direct message failed";
await NotifyEventHelper.AddOpsProblemEvent(err, ex);
AddError(ApiErrorCode.API_SERVER_ERROR, null, err + ExceptionUtil.ExtractAllExceptionMessages(ex));
return null;
}
IMailer m = Sockeye.Util.ServiceProviderProvider.Mailer;
try
{
await m.SendEmailAsync(notifyDirectSMTP.ToAddress, notifyDirectSMTP.Subject, notifyDirectSMTP.TextBody, ServerGlobalOpsSettingsCache.Notify, null, null, null);
await EventLogProcessor.LogEventToDatabaseAsync(new Event(1, notifyDirectSMTP.ObjectId, notifyDirectSMTP.SockType, SockEvent.DirectSMTP, $"\"{notifyDirectSMTP.Subject}\"->{notifyDirectSMTP.ToAddress}"), ct);
}
catch (Exception ex)
{
var err = "TrialLicenseRequest sending email confirmation request: SMTP direct message failed";
await NotifyEventHelper.AddOpsProblemEvent(err, ex);
AddError(ApiErrorCode.API_SERVER_ERROR, null, err + ExceptionUtil.ExtractAllExceptionMessages(ex));
return null;
}
await HandlePotentialNotificationEvent(SockEvent.Created, newObject);
return newObject;
@@ -591,7 +589,7 @@ namespace Sockeye.Biz
SockType = BizType,
ObjectId = o.Id,
NotifySubscriptionId = sub.Id,
Name = $"{o.CompanyName} - trial license requested"
Name = o.CompanyName
};
await ct.NotifyEvent.AddAsync(n);
log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]");