mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-14 02:26:55 -07:00
more wip on whatsapp
This commit is contained in:
parent
952db09e28
commit
0c7b6a8ed0
14 changed files with 289 additions and 100 deletions
|
@ -7,8 +7,14 @@ namespace Ombi.Core.Models.UI
|
|||
/// <summary>
|
||||
/// The view model for the notification settings page
|
||||
/// </summary>
|
||||
/// <seealso cref="WhatsAppNotificationsViewModel" />
|
||||
public class WhatsAppNotificationsViewModel : WhatsAppSettings
|
||||
/// <seealso cref="TwilioSettingsViewModel" />
|
||||
public class TwilioSettingsViewModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public WhatsAppSettingsViewModel WhatsAppSettings { get; set; } = new WhatsAppSettingsViewModel();
|
||||
}
|
||||
|
||||
public class WhatsAppSettingsViewModel : WhatsAppSettings
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the notification templates.
|
|
@ -20,6 +20,8 @@ namespace Ombi.Mapping.Profiles
|
|||
CreateMap<MobileNotificationsViewModel, MobileNotificationSettings>().ReverseMap();
|
||||
CreateMap<NewsletterNotificationViewModel, NewsletterSettings>().ReverseMap();
|
||||
CreateMap<GotifyNotificationViewModel, GotifySettings>().ReverseMap();
|
||||
CreateMap<WhatsAppSettingsViewModel, WhatsAppSettings>().ReverseMap();
|
||||
CreateMap<TwilioSettingsViewModel, TwilioSettings>().ReverseMap();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -13,9 +13,9 @@ using Ombi.Api.Twilio;
|
|||
|
||||
namespace Ombi.Notifications.Agents
|
||||
{
|
||||
public class WhatsAppNotification : BaseNotification<WhatsAppSettings>
|
||||
public class WhatsAppNotification : BaseNotification<TwilioSettings>
|
||||
{
|
||||
public WhatsAppNotification(IWhatsAppApi api, ISettingsService<WhatsAppSettings> sn, ILogger<WhatsAppNotification> log,
|
||||
public WhatsAppNotification(IWhatsAppApi api, ISettingsService<TwilioSettings> sn, ILogger<WhatsAppNotification> log,
|
||||
INotificationTemplatesRepository r, IMovieRequestRepository m,
|
||||
ITvRequestRepository t, ISettingsService<CustomizationSettings> s
|
||||
, IRepository<RequestSubscription> sub, IMusicRequestRepository music,
|
||||
|
@ -30,66 +30,66 @@ namespace Ombi.Notifications.Agents
|
|||
private IWhatsAppApi Api { get; }
|
||||
private ILogger Logger { get; }
|
||||
|
||||
protected override bool ValidateConfiguration(WhatsAppSettings settings)
|
||||
protected override bool ValidateConfiguration(TwilioSettings settings)
|
||||
{
|
||||
if (!settings.Enabled)
|
||||
if (!settings.WhatsAppSettings?.Enabled ?? false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return !settings.AccountSid.IsNullOrEmpty() && !settings.AuthToken.IsNullOrEmpty() && !settings.From.IsNullOrEmpty();
|
||||
return !settings.WhatsAppSettings.AccountSid.IsNullOrEmpty() && !settings.WhatsAppSettings.AuthToken.IsNullOrEmpty() && !settings.WhatsAppSettings.From.IsNullOrEmpty();
|
||||
}
|
||||
|
||||
protected override async Task NewRequest(NotificationOptions model, WhatsAppSettings settings)
|
||||
protected override async Task NewRequest(NotificationOptions model, TwilioSettings settings)
|
||||
{
|
||||
await Run(model, settings, NotificationType.NewRequest);
|
||||
}
|
||||
|
||||
protected override async Task NewIssue(NotificationOptions model, WhatsAppSettings settings)
|
||||
protected override async Task NewIssue(NotificationOptions model, TwilioSettings settings)
|
||||
{
|
||||
await Run(model, settings, NotificationType.Issue);
|
||||
}
|
||||
|
||||
protected override async Task IssueComment(NotificationOptions model, WhatsAppSettings settings)
|
||||
protected override async Task IssueComment(NotificationOptions model, TwilioSettings settings)
|
||||
{
|
||||
await Run(model, settings, NotificationType.IssueComment);
|
||||
}
|
||||
|
||||
protected override async Task IssueResolved(NotificationOptions model, WhatsAppSettings settings)
|
||||
protected override async Task IssueResolved(NotificationOptions model, TwilioSettings settings)
|
||||
{
|
||||
await Run(model, settings, NotificationType.IssueResolved);
|
||||
}
|
||||
|
||||
protected override async Task AddedToRequestQueue(NotificationOptions model, WhatsAppSettings settings)
|
||||
protected override async Task AddedToRequestQueue(NotificationOptions model, TwilioSettings settings)
|
||||
{
|
||||
await Run(model, settings, NotificationType.ItemAddedToFaultQueue);
|
||||
}
|
||||
|
||||
protected override async Task RequestDeclined(NotificationOptions model, WhatsAppSettings settings)
|
||||
protected override async Task RequestDeclined(NotificationOptions model, TwilioSettings settings)
|
||||
{
|
||||
await Run(model, settings, NotificationType.RequestDeclined);
|
||||
}
|
||||
|
||||
protected override async Task RequestApproved(NotificationOptions model, WhatsAppSettings settings)
|
||||
protected override async Task RequestApproved(NotificationOptions model, TwilioSettings settings)
|
||||
{
|
||||
await Run(model, settings, NotificationType.RequestApproved);
|
||||
}
|
||||
|
||||
protected override async Task AvailableRequest(NotificationOptions model, WhatsAppSettings settings)
|
||||
protected override async Task AvailableRequest(NotificationOptions model, TwilioSettings settings)
|
||||
{
|
||||
await Run(model, settings, NotificationType.RequestAvailable);
|
||||
}
|
||||
|
||||
protected override async Task Send(NotificationMessage model, WhatsAppSettings settings)
|
||||
protected override async Task Send(NotificationMessage model, TwilioSettings settings)
|
||||
{
|
||||
try
|
||||
{
|
||||
var whatsApp = new WhatsAppModel
|
||||
{
|
||||
Message = model.Message,
|
||||
From = settings.From,
|
||||
From = settings.WhatsAppSettings.From,
|
||||
To = ""// TODO
|
||||
};
|
||||
await Api.SendMessage(whatsApp, settings.AccountSid, settings.AuthToken);
|
||||
await Api.SendMessage(whatsApp, settings.WhatsAppSettings.AccountSid, settings.WhatsAppSettings.AuthToken);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -97,7 +97,7 @@ namespace Ombi.Notifications.Agents
|
|||
}
|
||||
}
|
||||
|
||||
protected override async Task Test(NotificationOptions model, WhatsAppSettings settings)
|
||||
protected override async Task Test(NotificationOptions model, TwilioSettings settings)
|
||||
{
|
||||
var message = $"This is a test from Ombi, if you can see this then we have successfully pushed a notification!";
|
||||
var notification = new NotificationMessage
|
||||
|
@ -107,7 +107,7 @@ namespace Ombi.Notifications.Agents
|
|||
await Send(notification, settings);
|
||||
}
|
||||
|
||||
private async Task Run(NotificationOptions model, WhatsAppSettings settings, NotificationType type)
|
||||
private async Task Run(NotificationOptions model, TwilioSettings settings, NotificationType type)
|
||||
{
|
||||
var parsed = await LoadTemplate(NotificationAgent.WhatsApp, type, model);
|
||||
if (parsed.Disabled)
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
namespace Ombi.Settings.Settings.Models.Notifications
|
||||
{
|
||||
public class WhatsAppSettings : Settings
|
||||
public class TwilioSettings : Settings
|
||||
{
|
||||
public WhatsAppSettings WhatsAppSettings { get; set; }
|
||||
}
|
||||
|
||||
public class WhatsAppSettings
|
||||
{
|
||||
public bool Enabled { get; set; }
|
||||
public string From { get; set; }
|
||||
public string AccountSid { get; set; }
|
||||
public string AuthToken { get; set; }
|
||||
public string From { get; set; }
|
||||
}
|
||||
}
|
|
@ -27,11 +27,16 @@ export interface INotificationTemplates {
|
|||
}
|
||||
|
||||
export enum NotificationAgent {
|
||||
Email,
|
||||
Discord,
|
||||
Pushbullet,
|
||||
Pushover,
|
||||
Telegram,
|
||||
Email = 0,
|
||||
Discord = 1,
|
||||
Pushbullet = 2,
|
||||
Pushover = 3,
|
||||
Telegram = 4,
|
||||
Slack = 5,
|
||||
Mattermost = 6,
|
||||
Mobile = 7,
|
||||
Gotify = 8,
|
||||
WhatsApp = 9
|
||||
}
|
||||
|
||||
export enum NotificationType {
|
||||
|
@ -47,6 +52,7 @@ export enum NotificationType {
|
|||
IssueResolved = 9,
|
||||
IssueComment = 10,
|
||||
Newsletter = 11,
|
||||
WhatsApp = 12,
|
||||
}
|
||||
|
||||
export interface IDiscordNotifcationSettings extends INotificationSettings {
|
||||
|
@ -85,6 +91,18 @@ export interface IPushbulletNotificationSettings extends INotificationSettings {
|
|||
channelTag: string;
|
||||
}
|
||||
|
||||
export interface ITwilioSettings extends ISettings {
|
||||
whatsAppSettings: IWhatsAppSettings;
|
||||
}
|
||||
|
||||
export interface IWhatsAppSettings {
|
||||
enabled: number;
|
||||
from: string;
|
||||
accountSid: string;
|
||||
authToken: string;
|
||||
notificationTemplates: INotificationTemplates[];
|
||||
}
|
||||
|
||||
export interface IPushoverNotificationSettings extends INotificationSettings {
|
||||
accessToken: string;
|
||||
notificationTemplates: INotificationTemplates[];
|
||||
|
|
|
@ -36,6 +36,7 @@ import {
|
|||
IUpdateSettings,
|
||||
IUserManagementSettings,
|
||||
IVoteSettings,
|
||||
ITwilioSettings,
|
||||
} from "../interfaces";
|
||||
|
||||
import { ServiceHelpers } from "./service.helpers";
|
||||
|
@ -254,6 +255,15 @@ export class SettingsService extends ServiceHelpers {
|
|||
.post<boolean>(`${this.url}/notifications/telegram`, JSON.stringify(settings), {headers: this.headers});
|
||||
}
|
||||
|
||||
public getTwilioSettings(): Observable<ITwilioSettings> {
|
||||
return this.http.get<ITwilioSettings>(`${this.url}/notifications/twilio`, {headers: this.headers});
|
||||
}
|
||||
|
||||
public saveTwilioSettings(settings: ITwilioSettings): Observable<boolean> {
|
||||
return this.http
|
||||
.post<boolean>(`${this.url}/notifications/twilio`, JSON.stringify(settings), {headers: this.headers});
|
||||
}
|
||||
|
||||
public getJobSettings(): Observable<IJobSettings> {
|
||||
return this.http.get<IJobSettings>(`${this.url}/jobs`, {headers: this.headers});
|
||||
}
|
||||
|
|
|
@ -1,36 +1,26 @@
|
|||
|
||||
<wiki [url]="'https://github.com/tidusjar/Ombi/wiki/Notification-Template-Variables'" [text]="'Notification Variables'"></wiki>
|
||||
<wiki [url]="'https://github.com/tidusjar/Ombi/wiki/Notification-Template-Variables'" [text]="'Notification Variables'">
|
||||
</wiki>
|
||||
<br><br>
|
||||
|
||||
<mat-accordion>
|
||||
<mat-expansion-panel *ngFor="let template of templates">
|
||||
<mat-expansion-panel-header>
|
||||
<mat-panel-title>
|
||||
{{NotificationType[template.notificationType] | humanize}}
|
||||
</mat-panel-title>
|
||||
</mat-expansion-panel-header>
|
||||
|
||||
<ngb-accordion [closeOthers]="true" activeIds="0-header">
|
||||
<ngb-panel *ngFor="let template of templates" id="{{template.notificationType}}" title="{{NotificationType[template.notificationType] | humanize}}">
|
||||
<ng-template ngbPanelContent>
|
||||
<div class="panel panel-default a">
|
||||
<div class="panel-body">
|
||||
|
||||
<div class="form-group">
|
||||
<div class="checkbox">
|
||||
<input type="checkbox" id="enabled" [(ngModel)]="template.enabled" ng-checked="template.enabled"><label for="enabled">Enable</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group" *ngIf="showSubject">
|
||||
<label class="control-label">Subject</label>
|
||||
<div>
|
||||
<input type="text" class="form-control form-control-custom" [(ngModel)]="template.subject" value="{{template.subject}}">
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<mat-slide-toggle [(ngModel)]="template.enabled">Enable</mat-slide-toggle>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label">Message</label>
|
||||
<div>
|
||||
<textarea type="text" class="form-control form-control-custom" [(ngModel)]="template.message" value="{{template.message}}"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<mat-form-field *ngIf="showSubject">
|
||||
<input matInput placeholder="Subject" [(ngModel)]="template.subject">
|
||||
</mat-form-field>
|
||||
|
||||
</ng-template>
|
||||
</ngb-panel>
|
||||
</ngb-accordion>
|
||||
<mat-form-field>
|
||||
<textarea matInput placeholder="Message" [(ngModel)]="template.message"></textarea>
|
||||
</mat-form-field>
|
||||
</mat-expansion-panel>
|
||||
|
||||
</mat-accordion>
|
|
@ -0,0 +1,21 @@
|
|||
<settings-menu>
|
||||
</settings-menu>
|
||||
<div *ngIf="form" class="container">
|
||||
<fieldset>
|
||||
<legend>Twilio</legend>
|
||||
<form novalidate [formGroup]="form" (ngSubmit)="onSubmit(form)">
|
||||
|
||||
<mat-tab-group>
|
||||
<mat-tab label="WhatsApp">
|
||||
<app-whatsapp [form]="form" [templates]="templates"></app-whatsapp>
|
||||
</mat-tab>
|
||||
</mat-tab-group>
|
||||
|
||||
<div class=" md-form-field ">
|
||||
<div>
|
||||
<button mat-raised-button type="submit " color="primary" [disabled]="form.invalid ">Submit</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</fieldset>
|
||||
</div>
|
|
@ -0,0 +1,55 @@
|
|||
import { Component, OnInit } from "@angular/core";
|
||||
import { FormBuilder, FormGroup, Validators } from "@angular/forms";
|
||||
|
||||
import { INotificationTemplates, ITwilioSettings, NotificationType } from "../../../interfaces";
|
||||
import { TesterService } from "../../../services";
|
||||
import { NotificationService } from "../../../services";
|
||||
import { SettingsService } from "../../../services";
|
||||
|
||||
@Component({
|
||||
templateUrl: "./twilio.component.html",
|
||||
})
|
||||
export class TwilioComponent implements OnInit {
|
||||
public NotificationType = NotificationType;
|
||||
public templates: INotificationTemplates[];
|
||||
public form: FormGroup;
|
||||
|
||||
constructor(private settingsService: SettingsService,
|
||||
private notificationService: NotificationService,
|
||||
private fb: FormBuilder,
|
||||
private testerService: TesterService) { }
|
||||
|
||||
public ngOnInit() {
|
||||
this.settingsService.getTwilioSettings().subscribe(x => {
|
||||
this.templates = x.whatsAppSettings.notificationTemplates;
|
||||
|
||||
this.form = this.fb.group({
|
||||
whatsAppSettings: this.fb.group({
|
||||
enabled: [x.whatsAppSettings.enabled],
|
||||
accountSid: [x.whatsAppSettings.accountSid],
|
||||
authToken: [x.whatsAppSettings.authToken],
|
||||
from: [x.whatsAppSettings.from],
|
||||
}),
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public onSubmit(form: FormGroup) {
|
||||
if (form.invalid) {
|
||||
this.notificationService.error("Please check your entered values");
|
||||
return;
|
||||
}
|
||||
|
||||
const settings = <ITwilioSettings> form.value;
|
||||
settings.whatsAppSettings.notificationTemplates = this.templates;
|
||||
|
||||
this.settingsService.saveTwilioSettings(settings).subscribe(x => {
|
||||
if (x) {
|
||||
this.notificationService.success("Successfully saved the Twilio settings");
|
||||
} else {
|
||||
this.notificationService.success("There was an error when saving the Twilio settings");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
<div [formGroup]="form" class="col">
|
||||
<div formGroupName="whatsAppSettings">
|
||||
<div class="col">
|
||||
<div>
|
||||
<mat-slide-toggle formControlName="enabled">Enable</mat-slide-toggle>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="md-form-field">
|
||||
<mat-form-field>
|
||||
<input matInput placeholder="From Number" formControlName="from">
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="md-form-field">
|
||||
<mat-form-field>
|
||||
<input matInput placeholder="Account SID" formControlName="accountSid">
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="md-form-field">
|
||||
<mat-form-field>
|
||||
<input matInput placeholder="Authentication Token" formControlName="authToken">
|
||||
</mat-form-field>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col">
|
||||
<notification-templates [templates]="templates" [showSubject]="false"></notification-templates>
|
||||
</div>
|
||||
<div class="md-form-field">
|
||||
<div>
|
||||
<button mat-raised-button type="button" color="primary">Test</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,37 @@
|
|||
import { Component, Input } from "@angular/core";
|
||||
import { FormGroup } from "@angular/forms";
|
||||
import { TesterService, NotificationService } from "../../../services";
|
||||
import { INotificationTemplates, NotificationType } from "../../../interfaces";
|
||||
|
||||
|
||||
|
||||
@Component({
|
||||
templateUrl: "./whatsapp.component.html",
|
||||
selector: "app-whatsapp"
|
||||
})
|
||||
export class WhatsAppComponent {
|
||||
|
||||
public NotificationType = NotificationType;
|
||||
@Input() public templates: INotificationTemplates[];
|
||||
@Input() public form: FormGroup;
|
||||
|
||||
constructor(private testerService: TesterService,
|
||||
private notificationService: NotificationService) { }
|
||||
|
||||
|
||||
public test(form: FormGroup) {
|
||||
if (form.invalid) {
|
||||
this.notificationService.error("Please check your entered values");
|
||||
return;
|
||||
}
|
||||
|
||||
this.testerService.mattermostTest(form.value).subscribe(x => {
|
||||
if (x) {
|
||||
this.notificationService.success( "Successfully sent a Mattermost message, please check the appropriate channel");
|
||||
} else {
|
||||
this.notificationService.error("There was an error when sending the Mattermost message. Please check your settings");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
|
@ -55,6 +55,8 @@ import { MatMenuModule} from "@angular/material";
|
|||
import { SharedModule } from "../shared/shared.module";
|
||||
import { HubService } from "../services/hub.service";
|
||||
import { LogsComponent } from "./logs/logs.component";
|
||||
import { TwilioComponent } from "./notifications/twilio/twilio.component";
|
||||
import { WhatsAppComponent } from "./notifications/twilio/whatsapp.component";
|
||||
|
||||
const routes: Routes = [
|
||||
{ path: "Ombi", component: OmbiComponent, canActivate: [AuthGuard] },
|
||||
|
@ -72,6 +74,7 @@ const routes: Routes = [
|
|||
{ path: "Pushbullet", component: PushbulletComponent, canActivate: [AuthGuard] },
|
||||
{ path: "Gotify", component: GotifyComponent, canActivate: [AuthGuard] },
|
||||
{ path: "Mattermost", component: MattermostComponent, canActivate: [AuthGuard] },
|
||||
{ path: "Twilio", component: TwilioComponent, canActivate: [AuthGuard] },
|
||||
{ path: "UserManagement", component: UserManagementComponent, canActivate: [AuthGuard] },
|
||||
{ path: "Update", component: UpdateComponent, canActivate: [AuthGuard] },
|
||||
{ path: "CouchPotato", component: CouchPotatoComponent, canActivate: [AuthGuard] },
|
||||
|
@ -149,6 +152,8 @@ const routes: Routes = [
|
|||
TheMovieDbComponent,
|
||||
FailedRequestsComponent,
|
||||
LogsComponent,
|
||||
TwilioComponent,
|
||||
WhatsAppComponent
|
||||
],
|
||||
exports: [
|
||||
RouterModule,
|
||||
|
|
|
@ -2,62 +2,63 @@
|
|||
|
||||
<button mat-button [matMenuTriggerFor]="configurationmenu"><i class="fa fa-cogs" aria-hidden="true"></i> Configuration</button>
|
||||
<mat-menu #configurationmenu="matMenu">
|
||||
<button mat-menu-item [routerLink]="['/Settings/Customization']">Customization</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/LandingPage']">Landing Page</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/Issues']">Issues</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/UserManagement']">User Management</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/Authentication']">Authentication</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/Vote']">Vote</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/TheMovieDb']">The Movie Database</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/Customization']">Customization</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/LandingPage']">Landing Page</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/Issues']">Issues</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/UserManagement']">User Management</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/Authentication']">Authentication</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/Vote']">Vote</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/TheMovieDb']">The Movie Database</button>
|
||||
</mat-menu>
|
||||
|
||||
<button mat-button [matMenuTriggerFor]="mediaservermenu"><i class="fa fa-server" aria-hidden="true"></i> Media Server</button>
|
||||
<mat-menu #mediaservermenu="matMenu">
|
||||
<button mat-menu-item [routerLink]="['/Settings/Plex']">Plex</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/Emby']">Emby/Jellyfin</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/Plex']">Plex</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/Emby']">Emby/Jellyfin</button>
|
||||
</mat-menu>
|
||||
|
||||
<button mat-button [matMenuTriggerFor]="tvmenu"><i class="fa fa-television" aria-hidden="true"></i> TV</button>
|
||||
<mat-menu #tvmenu="matMenu">
|
||||
<button mat-menu-item [routerLink]="['/Settings/Sonarr']">Sonarr</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/DogNzb']">DogNzb</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/SickRage']">SickRage</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/Sonarr']">Sonarr</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/DogNzb']">DogNzb</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/SickRage']">SickRage</button>
|
||||
</mat-menu>
|
||||
|
||||
<button mat-button [matMenuTriggerFor]="movieMenu"><i class="fa fa-film" aria-hidden="true"></i> Movies</button>
|
||||
<mat-menu #movieMenu="matMenu">
|
||||
<button mat-menu-item [routerLink]="['/Settings/CouchPotato']">CouchPotato</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/DogNzb']">DogNzb</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/Radarr']">Radarr</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/CouchPotato']">CouchPotato</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/DogNzb']">DogNzb</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/Radarr']">Radarr</button>
|
||||
</mat-menu>
|
||||
|
||||
<button mat-button [matMenuTriggerFor]="musicMenu"><i class="fa fa-music" aria-hidden="true"></i> Music</button>
|
||||
<mat-menu #musicMenu="matMenu">
|
||||
<button mat-menu-item [routerLink]="['/Settings/Lidarr']">Lidarr</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/Lidarr']">Lidarr</button>
|
||||
</mat-menu>
|
||||
|
||||
<button mat-button [matMenuTriggerFor]="notificationMenu"><i class="fa fa-bell-o" aria-hidden="true"></i> Notifications</button>
|
||||
<mat-menu #notificationMenu="matMenu">
|
||||
<button mat-menu-item [routerLink]="['/Settings/Mobile']">Mobile</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/Email']">Email</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/MassEmail']">MassEmail</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/Newsletter']">Newsletter</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/Discord']">Discord</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/Slack']">Slack</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/Pushbullet']">Pushbullet</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/Pushover']">Pushover</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/Mattermost']">Mattermost</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/Telegram']">Telegram</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/Gotify']">Gotify</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/Mobile']">Mobile</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/Email']">Email</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/MassEmail']">MassEmail</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/Newsletter']">Newsletter</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/Discord']">Discord</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/Slack']">Slack</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/Pushbullet']">Pushbullet</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/Pushover']">Pushover</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/Mattermost']">Mattermost</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/Telegram']">Telegram</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/Gotify']">Gotify</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/Twilio']">Twilio</button>
|
||||
</mat-menu>
|
||||
|
||||
<button mat-button [matMenuTriggerFor]="systemMenu"><i class="fa fa-tachometer" aria-hidden="true"></i> System</button>
|
||||
<mat-menu #systemMenu="matMenu">
|
||||
<button mat-menu-item [routerLink]="['/Settings/About']">About</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/FailedRequests']">Failed Requests</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/Update']">Update</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/Jobs']">Scheduled Tasks</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/Logs']">Logs</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/About']">About</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/FailedRequests']">Failed Requests</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/Update']">Update</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/Jobs']">Scheduled Tasks</button>
|
||||
<button mat-menu-item [routerLink]="['/Settings/Logs']">Logs</button>
|
||||
</mat-menu>
|
||||
|
||||
<hr/>
|
|
@ -964,17 +964,21 @@ namespace Ombi.Controllers.V1
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the WhatsApp Notification Settings.
|
||||
/// Gets the Twilio Notification Settings.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("notifications/whatsapp")]
|
||||
public async Task<WhatsAppNotificationsViewModel> WhatsAppNotificationSettings()
|
||||
[HttpGet("notifications/twilio")]
|
||||
public async Task<TwilioSettingsViewModel> TwilioNotificationSettings()
|
||||
{
|
||||
var settings = await Get<WhatsAppSettings>();
|
||||
var model = Mapper.Map<WhatsAppNotificationsViewModel>(settings);
|
||||
var settings = await Get<TwilioSettings>();
|
||||
var model = Mapper.Map<TwilioSettingsViewModel>(settings);
|
||||
|
||||
// Lookup to see if we have any templates saved
|
||||
model.NotificationTemplates = BuildTemplates(NotificationAgent.WhatsApp);
|
||||
if(model.WhatsAppSettings == null)
|
||||
{
|
||||
model.WhatsAppSettings = new WhatsAppSettingsViewModel();
|
||||
}
|
||||
model.WhatsAppSettings.NotificationTemplates = BuildTemplates(NotificationAgent.WhatsApp);
|
||||
|
||||
return model;
|
||||
}
|
||||
|
@ -984,15 +988,15 @@ namespace Ombi.Controllers.V1
|
|||
/// </summary>
|
||||
/// <param name="model">The model.</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("notifications/whatsapp")]
|
||||
public async Task<bool> WhatsAppNotificationSettings([FromBody] WhatsAppNotificationsViewModel model)
|
||||
[HttpPost("notifications/twilio")]
|
||||
public async Task<bool> TwilioNotificationSettings([FromBody] TwilioSettingsViewModel model)
|
||||
{
|
||||
// Save the email settings
|
||||
var settings = Mapper.Map<WhatsAppSettings>(model);
|
||||
var settings = Mapper.Map<TwilioSettings>(model);
|
||||
var result = await Save(settings);
|
||||
|
||||
// Save the templates
|
||||
await TemplateRepository.UpdateRange(model.NotificationTemplates);
|
||||
await TemplateRepository.UpdateRange(model.WhatsAppSettings.NotificationTemplates);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue