Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow set timestamp for messages #11

Merged
merged 1 commit into from
Mar 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions PushoverClient/PushOverRequestArguments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class PushoverRequestArguments
public string title { get; set; }
public string message { get; set; }
public int priority { get; set; }
public int timestamp { get; set; }
public string sound { get; set; }
}
}
11 changes: 6 additions & 5 deletions PushoverClient/Pushover.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ public Pushover(string appKey, string defaultSendKey) : this(appKey)
/// <param name="priority">Priority of the message (optional) default value set to Normal</param>
/// <param name="notificationSound">If set sends the notification sound</param>
/// <returns></returns>
public PushResponse Push(string title, string message, string userKey = "", string device = "", Priority priority = Priority.Normal, NotificationSound notificationSound = NotificationSound.NotSet)
public PushResponse Push(string title, string message, string userKey = "", string device = "", Priority priority = Priority.Normal, DateTime? timestamp = null, NotificationSound notificationSound = NotificationSound.NotSet)
{
var args = CreateArgs(title, message, userKey, device, priority, notificationSound);
var args = CreateArgs(title, message, userKey, device, priority, timestamp ?? DateTime.UtcNow, notificationSound);
try
{
return BASE_API_URL.PostToUrl(args).FromJson<PushResponse>();
Expand All @@ -87,9 +87,9 @@ public PushResponse Push(string title, string message, string userKey = "", stri
/// <param name="priority">Priority of the message (optional) default value set to Normal</param>
/// <param name="notificationSound">If set sends the notification sound</param>
/// <returns></returns>
public async Task<PushResponse> PushAsync(string title, string message, string userKey = "", string device = "", Priority priority = Priority.Normal, NotificationSound notificationSound = NotificationSound.NotSet)
public async Task<PushResponse> PushAsync(string title, string message, string userKey = "", string device = "", Priority priority = Priority.Normal, DateTime? timestamp = null, NotificationSound notificationSound = NotificationSound.NotSet)
{
var args = CreateArgs(title, message, userKey, device, priority, notificationSound);
var args = CreateArgs(title, message, userKey, device, priority, timestamp?? DateTime.UtcNow, notificationSound);
try
{
return (await BASE_API_URL.PostToUrlAsync(args)).FromJson<PushResponse>();
Expand All @@ -102,7 +102,7 @@ public async Task<PushResponse> PushAsync(string title, string message, string u



private object CreateArgs(string title, string message, string userKey, string device, Priority priority, NotificationSound notificationSound)
private object CreateArgs(string title, string message, string userKey, string device, Priority priority, DateTime timestamp, NotificationSound notificationSound)
{
// Try the passed user key or fall back to default
var userGroupKey = string.IsNullOrEmpty(userKey) ? DefaultUserGroupSendKey : userKey;
Expand All @@ -119,6 +119,7 @@ private object CreateArgs(string title, string message, string userKey, string d
device = device,
title = title,
message = message,
timestamp = (int)timestamp.Subtract(new DateTime(1970, 1, 1)).TotalSeconds,
priority = (int)priority
};

Expand Down