⏪ Uncomments code that prevents errors when missing services
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using DysonNetwork.Shared.Models;
|
||||
using DysonNetwork.Pass.Auth;
|
||||
using DysonNetwork.Pass.Permission;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
@ -49,7 +50,7 @@ public class NotificationController(AppDatabase db, NotificationService nty) : C
|
||||
.ToListAsync();
|
||||
|
||||
Response.Headers["X-Total"] = totalCount.ToString();
|
||||
// await nty.MarkNotificationsViewed(notifications);
|
||||
await nty.MarkNotificationsViewed(notifications);
|
||||
|
||||
return Ok(notifications);
|
||||
}
|
||||
@ -73,9 +74,8 @@ public class NotificationController(AppDatabase db, NotificationService nty) : C
|
||||
var currentSession = currentSessionValue as Session;
|
||||
if (currentSession == null) return Unauthorized();
|
||||
|
||||
// var result =
|
||||
// await nty.SubscribePushNotification(currentUser, request.Provider, currentSession.Challenge.DeviceId!,
|
||||
// request.DeviceToken);
|
||||
await nty.SubscribePushNotification(currentUser, request.Provider, currentSession.Challenge.DeviceId!,
|
||||
request.DeviceToken);
|
||||
|
||||
return Ok();
|
||||
}
|
||||
@ -111,26 +111,26 @@ public class NotificationController(AppDatabase db, NotificationService nty) : C
|
||||
|
||||
[HttpPost("broadcast")]
|
||||
[Authorize]
|
||||
// [RequiredPermission("global", "notifications.broadcast")]
|
||||
[RequiredPermission("global", "notifications.broadcast")]
|
||||
public async Task<ActionResult> BroadcastNotification(
|
||||
[FromBody] NotificationRequest request,
|
||||
[FromQuery] bool save = false
|
||||
)
|
||||
{
|
||||
// await nty.BroadcastNotification(
|
||||
// new Notification
|
||||
// {
|
||||
// CreatedAt = SystemClock.Instance.GetCurrentInstant(),
|
||||
// UpdatedAt = SystemClock.Instance.GetCurrentInstant(),
|
||||
// Topic = request.Topic,
|
||||
// Title = request.Title,
|
||||
// Subtitle = request.Subtitle,
|
||||
// Content = request.Content,
|
||||
// Meta = request.Meta,
|
||||
// Priority = request.Priority,
|
||||
// },
|
||||
// save
|
||||
// );
|
||||
await nty.BroadcastNotification(
|
||||
new Notification
|
||||
{
|
||||
CreatedAt = SystemClock.Instance.GetCurrentInstant(),
|
||||
UpdatedAt = SystemClock.Instance.GetCurrentInstant(),
|
||||
Topic = request.Topic,
|
||||
Title = request.Title,
|
||||
Subtitle = request.Subtitle,
|
||||
Content = request.Content,
|
||||
Meta = request.Meta,
|
||||
Priority = request.Priority,
|
||||
},
|
||||
save
|
||||
);
|
||||
return Ok();
|
||||
}
|
||||
|
||||
@ -141,27 +141,27 @@ public class NotificationController(AppDatabase db, NotificationService nty) : C
|
||||
|
||||
[HttpPost("send")]
|
||||
[Authorize]
|
||||
// [RequiredPermission("global", "notifications.send")]
|
||||
[RequiredPermission("global", "notifications.send")]
|
||||
public async Task<ActionResult> SendNotification(
|
||||
[FromBody] NotificationWithAimRequest request,
|
||||
[FromQuery] bool save = false
|
||||
)
|
||||
{
|
||||
var accounts = await db.Accounts.Where(a => request.AccountId.Contains(a.Id)).ToListAsync();
|
||||
// await nty.SendNotificationBatch(
|
||||
// new Notification
|
||||
// {
|
||||
// CreatedAt = SystemClock.Instance.GetCurrentInstant(),
|
||||
// UpdatedAt = SystemClock.Instance.GetCurrentInstant(),
|
||||
// Topic = request.Topic,
|
||||
// Title = request.Title,
|
||||
// Subtitle = request.Subtitle,
|
||||
// Content = request.Content,
|
||||
// Meta = request.Meta,
|
||||
// },
|
||||
// accounts,
|
||||
// save
|
||||
// );
|
||||
await nty.SendNotificationBatch(
|
||||
new Notification
|
||||
{
|
||||
CreatedAt = SystemClock.Instance.GetCurrentInstant(),
|
||||
UpdatedAt = SystemClock.Instance.GetCurrentInstant(),
|
||||
Topic = request.Topic,
|
||||
Title = request.Title,
|
||||
Subtitle = request.Subtitle,
|
||||
Content = request.Content,
|
||||
Meta = request.Meta,
|
||||
},
|
||||
accounts,
|
||||
save
|
||||
);
|
||||
return Ok();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user