mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-16 02:02:55 -07:00
Added rich notifications for mobile
This commit is contained in:
parent
505bd06035
commit
b7c0c07534
4 changed files with 34 additions and 19 deletions
|
@ -6,6 +6,6 @@ namespace Ombi.Api.Notifications
|
|||
{
|
||||
public interface IOneSignalApi
|
||||
{
|
||||
Task<OneSignalNotificationResponse> PushNotification(List<string> playerIds, string message);
|
||||
Task<OneSignalNotificationResponse> PushNotification(List<string> playerIds, string message, bool isAdminNotification, int requestId, int requestType);
|
||||
}
|
||||
}
|
|
@ -4,18 +4,22 @@
|
|||
{
|
||||
public string app_id { get; set; }
|
||||
public string[] include_player_ids { get; set; }
|
||||
public Data data { get; set; }
|
||||
public object data { get; set; }
|
||||
public Button[] buttons { get; set; }
|
||||
public Contents contents { get; set; }
|
||||
}
|
||||
|
||||
public class Data
|
||||
{
|
||||
public string foo { get; set; }
|
||||
}
|
||||
|
||||
public class Contents
|
||||
{
|
||||
public string en { get; set; }
|
||||
}
|
||||
|
||||
public class Button
|
||||
{
|
||||
public string id { get; set; }
|
||||
public string text { get; set; }
|
||||
//public string icon { get; set; }
|
||||
}
|
||||
|
||||
}
|
|
@ -20,7 +20,7 @@ namespace Ombi.Api.Notifications
|
|||
private readonly IApplicationConfigRepository _appConfig;
|
||||
private const string ApiUrl = "https://onesignal.com/api/v1/notifications";
|
||||
|
||||
public async Task<OneSignalNotificationResponse> PushNotification(List<string> playerIds, string message)
|
||||
public async Task<OneSignalNotificationResponse> PushNotification(List<string> playerIds, string message, bool isAdminNotification, int requestId, int requestType)
|
||||
{
|
||||
if (!playerIds.Any())
|
||||
{
|
||||
|
@ -39,6 +39,17 @@ namespace Ombi.Api.Notifications
|
|||
include_player_ids = playerIds.ToArray()
|
||||
};
|
||||
|
||||
if (isAdminNotification)
|
||||
{
|
||||
// Add the action buttons
|
||||
body.data = new { requestid = requestId, requestType = requestType};
|
||||
body.buttons = new[]
|
||||
{
|
||||
new Button {id = "approve", text = "Approve Request"},
|
||||
new Button {id = "deny", text = "Deny Request"},
|
||||
};
|
||||
}
|
||||
|
||||
request.AddJsonBody(body);
|
||||
|
||||
var result = await _api.Request<OneSignalNotificationResponse>(request);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue