mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 13:23:20 -07:00
Reworked the custom notifications... again. Need to figure out how to find the view to the model
This commit is contained in:
parent
f0ce5556c3
commit
a19e81d1f8
6 changed files with 112 additions and 35 deletions
37
PlexRequests.Core/NotificationMessage.cs
Normal file
37
PlexRequests.Core/NotificationMessage.cs
Normal file
|
@ -0,0 +1,37 @@
|
|||
#region Copyright
|
||||
// /************************************************************************
|
||||
// Copyright (c) 2016 Jamie Rees
|
||||
// File: NotificationMessage.cs
|
||||
// Created By: Jamie Rees
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ************************************************************************/
|
||||
#endregion
|
||||
using PlexRequests.Core.Models;
|
||||
|
||||
namespace PlexRequests.Core
|
||||
{
|
||||
public class NotificationMessage
|
||||
{
|
||||
public NotificationType NotificationType { get; set; }
|
||||
public string Body { get; set; }
|
||||
public string Subject { get; set; }
|
||||
}
|
||||
}
|
|
@ -38,10 +38,11 @@ namespace PlexRequests.Core
|
|||
private const char EndChar = (char)125;
|
||||
public NotificationMessageContent ParseMessage<T>(T notification, NotificationType type, NotificationMessageCurlys c) where T : NotificationSettings
|
||||
{
|
||||
var content = notification.Message.FirstOrDefault(x => x.Key == type).Value;
|
||||
|
||||
//if (string.IsNullOrEmpty(notificationToParse))
|
||||
// return string.Empty;
|
||||
var content = notification.Message.FirstOrDefault(x => x.NotificationType == type);
|
||||
if (content == null)
|
||||
{
|
||||
return new NotificationMessageContent();
|
||||
}
|
||||
|
||||
return Resolve(content.Body, content.Subject, c.Curlys);
|
||||
}
|
||||
|
|
|
@ -67,6 +67,7 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="CacheKeys.cs" />
|
||||
<Compile Include="NotificationMessage.cs" />
|
||||
<Compile Include="NotificationMessageContent.cs" />
|
||||
<Compile Include="NotificationMessageCurlys.cs" />
|
||||
<Compile Include="NotificationMessageResolver.cs" />
|
||||
|
|
|
@ -34,17 +34,16 @@ namespace PlexRequests.Core.SettingModels
|
|||
{
|
||||
public NotificationSettings()
|
||||
{
|
||||
Message = new Dictionary<NotificationType, NotificationMessageContent>
|
||||
Message = new List<NotificationMessage>
|
||||
{
|
||||
{NotificationType.NewRequest, new NotificationMessageContent() },
|
||||
{NotificationType.Issue, new NotificationMessageContent() },
|
||||
{NotificationType.AdminNote, new NotificationMessageContent() },
|
||||
{NotificationType.RequestApproved, new NotificationMessageContent() },
|
||||
{NotificationType.RequestAvailable, new NotificationMessageContent() },
|
||||
{NotificationType.Test, new NotificationMessageContent() },
|
||||
new NotificationMessage { NotificationType = NotificationType.NewRequest },
|
||||
new NotificationMessage { NotificationType = NotificationType.Issue },
|
||||
new NotificationMessage { NotificationType = NotificationType.AdminNote },
|
||||
new NotificationMessage { NotificationType = NotificationType.RequestApproved },
|
||||
new NotificationMessage { NotificationType = NotificationType.RequestAvailable },
|
||||
};
|
||||
}
|
||||
public Dictionary<NotificationType, NotificationMessageContent> Message { get; set; }
|
||||
public List<NotificationMessage> Message { get; set; }
|
||||
}
|
||||
|
||||
public static class NotificationCurly
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue