[backend/masto-client] Fix errors in WebSocket notification handler
This commit is contained in:
parent
fe5e02e791
commit
64fc07ff53
1 changed files with 14 additions and 1 deletions
|
@ -1,7 +1,9 @@
|
|||
using System.Text.Json;
|
||||
using Iceshrimp.Backend.Controllers.Mastodon.Renderers;
|
||||
using Iceshrimp.Backend.Controllers.Mastodon.Schemas.Entities;
|
||||
using Iceshrimp.Backend.Core.Database;
|
||||
using Iceshrimp.Backend.Core.Database.Tables;
|
||||
using Iceshrimp.Backend.Core.Middleware;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Iceshrimp.Backend.Controllers.Mastodon.Streaming.Channels;
|
||||
|
@ -123,7 +125,18 @@ public class UserChannel(WebSocketConnection connection, bool notificationsOnly)
|
|||
if (!IsApplicable(notification)) return;
|
||||
var provider = connection.ScopeFactory.CreateScope().ServiceProvider;
|
||||
var renderer = provider.GetRequiredService<NotificationRenderer>();
|
||||
var rendered = await renderer.RenderAsync(notification, connection.Token.User);
|
||||
|
||||
NotificationEntity rendered;
|
||||
try
|
||||
{
|
||||
rendered = await renderer.RenderAsync(notification, connection.Token.User);
|
||||
}
|
||||
catch (GracefulException)
|
||||
{
|
||||
// Unsupported notification type
|
||||
return;
|
||||
}
|
||||
|
||||
var message = new StreamingUpdateMessage
|
||||
{
|
||||
Stream = [Name], Event = "notification", Payload = JsonSerializer.Serialize(rendered)
|
||||
|
|
Loading…
Add table
Reference in a new issue