🐛 Fix chat room invites
This commit is contained in:
@@ -150,7 +150,7 @@ public class ChatRoomController(
|
|||||||
[Authorize]
|
[Authorize]
|
||||||
public async Task<ActionResult<ChatRoom>> GetDirectChatRoom(Guid accountId)
|
public async Task<ActionResult<ChatRoom>> GetDirectChatRoom(Guid accountId)
|
||||||
{
|
{
|
||||||
if (HttpContext.Items["CurrentUser"] is not Shared.Proto.Account currentUser)
|
if (HttpContext.Items["CurrentUser"] is not Account currentUser)
|
||||||
return Unauthorized();
|
return Unauthorized();
|
||||||
|
|
||||||
var room = await db.ChatRooms
|
var room = await db.ChatRooms
|
||||||
@@ -968,23 +968,29 @@ public class ChatRoomController(
|
|||||||
|
|
||||||
private async Task _SendInviteNotify(ChatMember member, Account sender)
|
private async Task _SendInviteNotify(ChatMember member, Account sender)
|
||||||
{
|
{
|
||||||
|
var account = await accounts.GetAccountAsync(new GetAccountRequest { Id = member.AccountId.ToString() });
|
||||||
|
CultureService.SetCultureInfo(account);
|
||||||
|
|
||||||
string title = localizer["ChatInviteTitle"];
|
string title = localizer["ChatInviteTitle"];
|
||||||
|
|
||||||
string body = member.ChatRoom.Type == ChatRoomType.DirectMessage
|
string body = member.ChatRoom.Type == ChatRoomType.DirectMessage
|
||||||
? localizer["ChatInviteDirectBody", sender.Nick]
|
? localizer["ChatInviteDirectBody", sender.Nick]
|
||||||
: localizer["ChatInviteBody", member.ChatRoom.Name ?? "Unnamed"];
|
: localizer["ChatInviteBody", member.ChatRoom.Name ?? "Unnamed"];
|
||||||
|
|
||||||
CultureService.SetCultureInfo(member.Account!.Language);
|
|
||||||
await pusher.SendPushNotificationToUserAsync(
|
await pusher.SendPushNotificationToUserAsync(
|
||||||
new SendPushNotificationToUserRequest
|
new SendPushNotificationToUserRequest
|
||||||
{
|
{
|
||||||
UserId = member.Account.Id.ToString(),
|
UserId = account.Id,
|
||||||
Notification = new PushNotification
|
Notification = new PushNotification
|
||||||
{
|
{
|
||||||
Topic = "invites.chats",
|
Topic = "invites.chats",
|
||||||
Title = title,
|
Title = title,
|
||||||
Body = body,
|
Body = body,
|
||||||
IsSavable = true
|
IsSavable = true,
|
||||||
|
Meta = GrpcTypeHelper.ConvertObjectToByteString(new
|
||||||
|
{
|
||||||
|
room_id = member.ChatRoomId
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user