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