Notification action URIs

This commit is contained in:
LittleSheep 2025-06-14 16:57:23 +08:00
parent e7942fc687
commit c8b1c1ba55
5 changed files with 13 additions and 5 deletions

View File

@ -67,6 +67,7 @@ public class NotificationService(
string? subtitle = null,
string? content = null,
Dictionary<string, object>? meta = null,
string? actionUri = null,
bool isSilent = false,
bool save = true
)
@ -74,6 +75,9 @@ public class NotificationService(
if (title is null && subtitle is null && content is null)
throw new ArgumentException("Unable to send notification that completely empty.");
meta ??= new Dictionary<string, object>();
if (actionUri is not null) meta["action_uri"] = actionUri;
var notification = new Notification
{
Topic = topic,

View File

@ -799,6 +799,6 @@ public class ChatRoomController(
: localizer["ChatInviteBody", member.ChatRoom.Name ?? "Unnamed"];
AccountService.SetCultureInfo(member.Account);
await nty.SendNotification(member.Account, "invites.chats", title, null, body);
await nty.SendNotification(member.Account, "invites.chats", title, null, body, actionUri: "/chat");
}
}

View File

@ -151,7 +151,8 @@ public class PostService(
null,
string.IsNullOrWhiteSpace(post.Title)
? localizer["PostReplyBody", sender.Nick, content]
: localizer["PostReplyContentBody", sender.Nick, post.Title, content]
: localizer["PostReplyContentBody", sender.Nick, post.Title, content],
actionUri: $"/posts/{post.Id}"
);
}
}
@ -324,7 +325,8 @@ public class PostService(
string.IsNullOrWhiteSpace(post.Title)
? localizer["PostReactBody", sender.Nick, reaction.Symbol]
: localizer["PostReactContentBody", sender.Nick, reaction.Symbol,
post.Title]
post.Title],
actionUri: $"/posts/{post.Id}"
);
}
}

View File

@ -76,7 +76,8 @@ public class PublisherSubscriptionService(
localizer["PostSubscriptionTitle", post.Publisher.Name, title],
null,
message,
data
data,
actionUri: $"/posts/{post.Id}"
);
notifiedCount++;

View File

@ -15,7 +15,8 @@ public class RealmService(AppDatabase db, NotificationService nty, IStringLocali
"invites.realms",
localizer["RealmInviteTitle"],
null,
localizer["RealmInviteBody", member.Realm.Name]
localizer["RealmInviteBody", member.Realm.Name],
actionUri: "/realms"
);
}