[backend/masto-client] Catch GracefulExceptions correctly in push handler
This commit is contained in:
parent
fa75409923
commit
d4e8d7a6f6
1 changed files with 75 additions and 77 deletions
|
@ -38,9 +38,10 @@ public class PushService(
|
||||||
await using var scope = scopeFactory.CreateAsyncScope();
|
await using var scope = scopeFactory.CreateAsyncScope();
|
||||||
await using var db = scope.ServiceProvider.GetRequiredService<DatabaseContext>();
|
await using var db = scope.ServiceProvider.GetRequiredService<DatabaseContext>();
|
||||||
|
|
||||||
|
var type = NotificationEntity.EncodeType(notification.Type);
|
||||||
var subscriptions = await db.PushSubscriptions.Where(p => p.User == notification.Notifiee)
|
var subscriptions = await db.PushSubscriptions.Where(p => p.User == notification.Notifiee)
|
||||||
.Include(pushSubscription => pushSubscription.OauthToken)
|
.Include(pushSubscription => pushSubscription.OauthToken)
|
||||||
.Where(p => p.Types.Contains(NotificationEntity.EncodeType(notification.Type)))
|
.Where(p => p.Types.Contains(type))
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
if (subscriptions.Count == 0)
|
if (subscriptions.Count == 0)
|
||||||
|
@ -58,8 +59,6 @@ public class PushService(
|
||||||
await db.Followings.AnyAsync(p => p.Follower == notification.Notifier &&
|
await db.Followings.AnyAsync(p => p.Follower == notification.Notifier &&
|
||||||
p.Followee == notification.Notifiee);
|
p.Followee == notification.Notifiee);
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var renderer = scope.ServiceProvider.GetRequiredService<NotificationRenderer>();
|
var renderer = scope.ServiceProvider.GetRequiredService<NotificationRenderer>();
|
||||||
var rendered = await renderer.RenderAsync(notification, notification.Notifiee);
|
var rendered = await renderer.RenderAsync(notification, notification.Notifiee);
|
||||||
var name = rendered.Notifier.DisplayName;
|
var name = rendered.Notifier.DisplayName;
|
||||||
|
@ -143,7 +142,6 @@ public class PushService(
|
||||||
{
|
{
|
||||||
// Unsupported notification type
|
// Unsupported notification type
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
logger.LogError("Event handler MastodonPushHandler threw exception: {e}", e);
|
logger.LogError("Event handler MastodonPushHandler threw exception: {e}", e);
|
||||||
|
|
Loading…
Add table
Reference in a new issue