mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-19 12:59:39 -07:00
Merge pull request #4360 from Ombi-app/newsletter-fixes
fix(newsletter): 🐛 Fixed a few small bugs in the newsletter
This commit is contained in:
commit
7af084f5ca
3 changed files with 20 additions and 16 deletions
|
@ -29,6 +29,8 @@ namespace Ombi.Schedule.Tests
|
||||||
yield return new TestCaseData("https://google.com:3577/", "1").Returns("https://google.com:3577/unsubscribe/1").SetName("Port With Slash");
|
yield return new TestCaseData("https://google.com:3577/", "1").Returns("https://google.com:3577/unsubscribe/1").SetName("Port With Slash");
|
||||||
yield return new TestCaseData("", "1").Returns(string.Empty).SetName("Missing App URL empty");
|
yield return new TestCaseData("", "1").Returns(string.Empty).SetName("Missing App URL empty");
|
||||||
yield return new TestCaseData(null, "1").Returns(string.Empty).SetName("Missing App URL null");
|
yield return new TestCaseData(null, "1").Returns(string.Empty).SetName("Missing App URL null");
|
||||||
|
yield return new TestCaseData("hty", string.Empty).Returns(string.Empty).SetName("Missing ID empty");
|
||||||
|
yield return new TestCaseData("hty", null).Returns(string.Empty).SetName("Missing ID null");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -208,13 +208,7 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
|
|
||||||
if (!test)
|
if (!test)
|
||||||
{
|
{
|
||||||
// Get the users to send it to
|
var users = new List<OmbiUser>();
|
||||||
var users = await _userManager.GetUsersInRoleAsync(OmbiRoles.ReceivesNewsletter);
|
|
||||||
if (!users.Any())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var emails in settings.ExternalEmails)
|
foreach (var emails in settings.ExternalEmails)
|
||||||
{
|
{
|
||||||
users.Add(new OmbiUser
|
users.Add(new OmbiUser
|
||||||
|
@ -224,11 +218,23 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the users to send it to
|
||||||
|
users.AddRange(await _userManager.GetUsersInRoleAsync(OmbiRoles.ReceivesNewsletter));
|
||||||
|
if (!users.Any())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var messageContent = ParseTemplate(template, customization);
|
var messageContent = ParseTemplate(template, customization);
|
||||||
var email = new NewsletterTemplate();
|
var email = new NewsletterTemplate();
|
||||||
|
|
||||||
foreach (var user in users)
|
foreach (var user in users.DistinctBy(x => x.Email))
|
||||||
{
|
{ // Get the users to send it to
|
||||||
|
if (user.Email.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
var url = GenerateUnsubscribeLink(customization.ApplicationUrl, user.Id);
|
var url = GenerateUnsubscribeLink(customization.ApplicationUrl, user.Id);
|
||||||
var html = email.LoadTemplate(messageContent.Subject, messageContent.Message, body, customization.Logo, url);
|
var html = email.LoadTemplate(messageContent.Subject, messageContent.Message, body, customization.Logo, url);
|
||||||
|
|
||||||
|
@ -243,11 +249,6 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
Subject = messageContent.Subject
|
Subject = messageContent.Subject
|
||||||
};
|
};
|
||||||
|
|
||||||
// Get the users to send it to
|
|
||||||
if (user.Email.IsNullOrEmpty())
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// Send the message to the user
|
// Send the message to the user
|
||||||
message.To.Add(new MailboxAddress(user.Email.Trim(), user.Email.Trim()));
|
message.To.Add(new MailboxAddress(user.Email.Trim(), user.Email.Trim()));
|
||||||
|
|
||||||
|
@ -391,7 +392,7 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
|
|
||||||
public static string GenerateUnsubscribeLink(string applicationUrl, string id)
|
public static string GenerateUnsubscribeLink(string applicationUrl, string id)
|
||||||
{
|
{
|
||||||
if (!applicationUrl.HasValue())
|
if (!applicationUrl.HasValue() || !id.HasValue())
|
||||||
{
|
{
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
|
|
3
src/Ombi/.vscode/settings.json
vendored
3
src/Ombi/.vscode/settings.json
vendored
|
@ -16,6 +16,7 @@
|
||||||
"request-limits",
|
"request-limits",
|
||||||
"notifications",
|
"notifications",
|
||||||
"settings",
|
"settings",
|
||||||
"user-management"
|
"user-management",
|
||||||
|
"newsletter"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue