mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-23 06:25:24 -07:00
Send new request email notifications to power users
This commit is contained in:
parent
1a17da325d
commit
8d35a3dd7b
5 changed files with 23 additions and 2 deletions
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using MailKit.Net.Smtp;
|
||||
|
@ -114,7 +115,20 @@ namespace Ombi.Notifications.Agents
|
|||
var plaintext = await LoadPlainTextMessage(NotificationType.NewRequest, model, settings);
|
||||
message.Other.Add("PlainTextBody", plaintext);
|
||||
|
||||
await Send(message, settings);
|
||||
IEnumerable<OmbiUser> recipients = await _userManager.GetUsersInRoleAsync(OmbiRoles.Admin);
|
||||
if (settings.SendNewRequestToPowerUsers)
|
||||
{
|
||||
recipients = recipients.Concat(await _userManager.GetUsersInRoleAsync(OmbiRoles.PowerUser));
|
||||
}
|
||||
foreach (var recipient in recipients.DistinctBy(x => x.Email))
|
||||
{
|
||||
if (recipient.Email.IsNullOrEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
message.To = recipient.Email;
|
||||
await Send(message, settings);
|
||||
}
|
||||
}
|
||||
|
||||
protected override async Task NewIssue(NotificationOptions model, EmailNotificationSettings settings)
|
||||
|
|
|
@ -13,5 +13,6 @@
|
|||
public string AdminEmail { get; set; }
|
||||
public bool DisableTLS { get; set; }
|
||||
public bool DisableCertificateChecking { get; set; }
|
||||
public bool SendNewRequestToPowerUsers{ get; set; }
|
||||
}
|
||||
}
|
|
@ -15,6 +15,7 @@ export interface IEmailNotificationSettings extends INotificationSettings {
|
|||
adminEmail: string;
|
||||
disableTLS: boolean;
|
||||
disableCertificateChecking: boolean;
|
||||
sendNewRequestToPowerUsers: boolean;
|
||||
notificationTemplates: INotificationTemplates[];
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,10 @@
|
|||
<mat-slide-toggle formControlName="disableCertificateChecking">Disable Certificate
|
||||
Checking</mat-slide-toggle>
|
||||
</div>
|
||||
<div class="md-form-field">
|
||||
<mat-slide-toggle formControlName="sendNewRequestToPowerUsers">Send New Request
|
||||
To Power Users</mat-slide-toggle>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -61,7 +65,7 @@
|
|||
<div class="md-form-field">
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Admin Email</mat-label>
|
||||
<input matInput formControlName="adminEmail" matTooltip="The administrator email will be used to send emails for admin only notifications (e.g. New Requests that require approvals)">
|
||||
<input matInput formControlName="adminEmail" matTooltip="The administrator email will be used to send emails for admin only notifications (e.g. raised issues)">
|
||||
<mat-error *ngIf="emailForm.get('adminEmail').hasError('required')">
|
||||
Admin Email is <strong>required</strong>
|
||||
</mat-error>
|
||||
|
|
|
@ -38,6 +38,7 @@ export class EmailNotificationComponent implements OnInit {
|
|||
adminEmail: [x.adminEmail, [Validators.required, Validators.email]],
|
||||
disableTLS: [x.disableTLS],
|
||||
disableCertificateChecking: [x.disableCertificateChecking],
|
||||
sendNewRequestToPowerUsers: [x.sendNewRequestToPowerUsers],
|
||||
});
|
||||
|
||||
if (x.authentication) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue