🐛 Fix sending notification didn't set culture info for localization
This commit is contained in:
parent
a98bfec86f
commit
f961469db1
@ -1,3 +1,4 @@
|
||||
using System.Globalization;
|
||||
using DysonNetwork.Sphere.Auth;
|
||||
using DysonNetwork.Sphere.Storage;
|
||||
using EFCore.BulkExtensions;
|
||||
@ -14,6 +15,18 @@ public class AccountService(
|
||||
ICacheService cache
|
||||
)
|
||||
{
|
||||
public static void SetCultureInfo(Account account)
|
||||
{
|
||||
SetCultureInfo(account.Language);
|
||||
}
|
||||
|
||||
public static void SetCultureInfo(string? languageCode)
|
||||
{
|
||||
var info = new CultureInfo(languageCode ?? "en-us", false);
|
||||
CultureInfo.CurrentCulture = info;
|
||||
CultureInfo.CurrentUICulture = info;
|
||||
}
|
||||
|
||||
public const string AccountCachePrefix = "account:";
|
||||
|
||||
public async Task PurgeAccountCache(Account account)
|
||||
|
@ -78,10 +78,7 @@ public class MagicSpellService(
|
||||
.Where(a => a.Id == spell.AccountId)
|
||||
.Select(a => a.Language)
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
var cultureInfo = new CultureInfo(accountLanguage ?? "en-us", false);
|
||||
CultureInfo.CurrentCulture = cultureInfo;
|
||||
CultureInfo.CurrentUICulture = cultureInfo;
|
||||
AccountService.SetCultureInfo(accountLanguage);
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -741,6 +741,7 @@ public class ChatRoomController(
|
||||
? localizer["ChatInviteDirectBody", sender.Nick]
|
||||
: localizer["ChatInviteBody", member.ChatRoom.Name ?? "Unnamed"];
|
||||
|
||||
AccountService.SetCultureInfo(member.Account);
|
||||
await nty.SendNotification(member.Account, "invites.chats", title, null, body);
|
||||
}
|
||||
}
|
@ -261,6 +261,7 @@ public class PostService(
|
||||
|
||||
if (!isSelfReact && op is not null)
|
||||
{
|
||||
AccountService.SetCultureInfo(op);
|
||||
await nty.SendNotification(
|
||||
op,
|
||||
"posts.reactions.new",
|
||||
|
@ -71,6 +71,7 @@ public class PublisherSubscriptionService(
|
||||
{
|
||||
try
|
||||
{
|
||||
AccountService.SetCultureInfo(subscription.Account);
|
||||
await nty.SendNotification(
|
||||
subscription.Account,
|
||||
"posts.new",
|
||||
|
@ -9,6 +9,7 @@ public class RealmService(AppDatabase db, NotificationService nty, IStringLocali
|
||||
{
|
||||
public async Task SendInviteNotify(RealmMember member)
|
||||
{
|
||||
AccountService.SetCultureInfo(member.Account);
|
||||
await nty.SendNotification(
|
||||
member.Account,
|
||||
"invites.realms",
|
||||
|
Loading…
x
Reference in New Issue
Block a user