Add support for priority
Set default title to topic unique, as displayed in subscriptions list, if not provided Increase toast timeout to 5 seconds
This commit is contained in:
@@ -85,7 +85,7 @@ namespace ntfysh_client.Notifications
|
||||
lines.RemoveAt(partialLineIndex);
|
||||
|
||||
//Process the full lines
|
||||
foreach (string line in lines) ProcessMessage(line);
|
||||
foreach (string line in lines) ProcessMessage(topic, line);
|
||||
|
||||
//Write back the partial line
|
||||
mainBuffer.Clear();
|
||||
@@ -189,7 +189,7 @@ namespace ntfysh_client.Notifications
|
||||
lines.RemoveAt(partialLineIndex);
|
||||
|
||||
//Process the full lines
|
||||
foreach (string line in lines) ProcessMessage(line);
|
||||
foreach (string line in lines) ProcessMessage(topic, line);
|
||||
|
||||
//Write back the partial line
|
||||
mainBuffer.Clear();
|
||||
@@ -244,7 +244,7 @@ namespace ntfysh_client.Notifications
|
||||
}
|
||||
}
|
||||
|
||||
private void ProcessMessage(string message)
|
||||
private void ProcessMessage(SubscribedTopic topic, string message)
|
||||
{
|
||||
#if DEBUG
|
||||
Debug.WriteLine(message);
|
||||
@@ -257,7 +257,7 @@ namespace ntfysh_client.Notifications
|
||||
|
||||
if (evt.Event == "message")
|
||||
{
|
||||
OnNotificationReceive?.Invoke(this, new NotificationReceiveEventArgs(evt.Title, evt.Message));
|
||||
OnNotificationReceive?.Invoke(this, new NotificationReceiveEventArgs(topic, evt.Title ?? "", evt.Message, evt.Priority ?? NotificationPriority.Default));
|
||||
}
|
||||
}
|
||||
|
||||
|
11
ntfysh_client/Notifications/NotificationPriority.cs
Normal file
11
ntfysh_client/Notifications/NotificationPriority.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace ntfysh_client.Notifications
|
||||
{
|
||||
public enum NotificationPriority
|
||||
{
|
||||
Min = 1,
|
||||
Low = 2,
|
||||
Default = 3,
|
||||
High = 4,
|
||||
Max = 5
|
||||
}
|
||||
}
|
@@ -4,13 +4,17 @@ namespace ntfysh_client.Notifications
|
||||
{
|
||||
public class NotificationReceiveEventArgs : EventArgs
|
||||
{
|
||||
public SubscribedTopic Sender { get; }
|
||||
public string Title { get; }
|
||||
public string Message { get; }
|
||||
public NotificationPriority Priority { get; set; }
|
||||
|
||||
public NotificationReceiveEventArgs(string title, string message)
|
||||
public NotificationReceiveEventArgs(SubscribedTopic sender, string title, string message, NotificationPriority priority)
|
||||
{
|
||||
Sender = sender;
|
||||
Title = title;
|
||||
Message = message;
|
||||
Priority = priority;
|
||||
}
|
||||
}
|
||||
}
|
@@ -20,6 +20,9 @@ namespace ntfysh_client.Notifications
|
||||
public string Message { get; set; } = null!;
|
||||
|
||||
[JsonProperty("title")]
|
||||
public string Title { get; set; } = null!;
|
||||
public string? Title { get; set; }
|
||||
|
||||
[JsonProperty("priority")]
|
||||
public NotificationPriority? Priority { get; set; }
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user