diff --git a/DysonNetwork.Sphere/Account/NotificationService.cs b/DysonNetwork.Sphere/Account/NotificationService.cs index aa4f934..dd5e5e8 100644 --- a/DysonNetwork.Sphere/Account/NotificationService.cs +++ b/DysonNetwork.Sphere/Account/NotificationService.cs @@ -206,12 +206,10 @@ public class NotificationService( ["notif_id"] = notification.Id.ToString(), ["apns_id"] = notification.Id.ToString(), ["topic"] = _notifyTopic, - ["category"] = notification.Topic, ["tokens"] = deviceTokens, - ["alert"] = new Dictionary(), ["data"] = new Dictionary { - ["d_topic"] = notification.Topic, + ["type"] = notification.Topic, ["meta"] = notification.Meta ?? new Dictionary(), }, ["mutable_content"] = true, @@ -237,7 +235,7 @@ public class NotificationService( } if (notification.Priority >= 5) - dict["sound"] = "default"; + dict["name"] = "default"; dict["platform"] = platformCode; dict["alert"] = alertDict; diff --git a/DysonNetwork.Sphere/Chat/ChatController.cs b/DysonNetwork.Sphere/Chat/ChatController.cs index ef4a5ab..035c50f 100644 --- a/DysonNetwork.Sphere/Chat/ChatController.cs +++ b/DysonNetwork.Sphere/Chat/ChatController.cs @@ -12,7 +12,7 @@ namespace DysonNetwork.Sphere.Chat; [ApiController] [Route("/chat")] -public partial class ChatController(AppDatabase db, ChatService cs) : ControllerBase +public partial class ChatController(AppDatabase db, ChatService cs, ChatRoomService crs) : ControllerBase { public class MarkMessageReadRequest { @@ -148,13 +148,7 @@ public partial class ChatController(AppDatabase db, ChatService cs) : Controller (request.AttachmentsId == null || request.AttachmentsId.Count == 0)) return BadRequest("You cannot send an empty message."); - var member = await db.ChatMembers - .Where(m => m.AccountId == currentUser.Id && m.ChatRoomId == roomId) - .Include(m => m.ChatRoom) - .Include(m => m.ChatRoom.Realm) - .Include(m => m.Account) - .Include(m => m.Account.Profile) - .FirstOrDefaultAsync(); + var member = await crs.GetRoomMember(currentUser.Id, roomId); if (member == null || member.Role < ChatMemberRole.Member) return StatusCode(403, "You need to be a normal member to send messages here."); @@ -219,7 +213,6 @@ public partial class ChatController(AppDatabase db, ChatService cs) : Controller return Ok(result); } - [HttpPatch("{roomId:guid}/messages/{messageId:guid}")] [Authorize] public async Task UpdateMessage([FromBody] SendMessageRequest request, Guid roomId, Guid messageId) diff --git a/DysonNetwork.Sphere/Chat/ChatRoomService.cs b/DysonNetwork.Sphere/Chat/ChatRoomService.cs index 516864a..82dfff9 100644 --- a/DysonNetwork.Sphere/Chat/ChatRoomService.cs +++ b/DysonNetwork.Sphere/Chat/ChatRoomService.cs @@ -33,7 +33,7 @@ public class ChatRoomService(AppDatabase db, ICacheService cache) return members; } - public async Task GetChannelMember(Guid accountId, Guid chatRoomId) + public async Task GetRoomMember(Guid accountId, Guid chatRoomId) { var cacheKey = string.Format(ChatMemberCacheKey, accountId, chatRoomId); var member = await cache.GetAsync(cacheKey); @@ -42,6 +42,8 @@ public class ChatRoomService(AppDatabase db, ICacheService cache) member = await db.ChatMembers .Include(m => m.Account) .ThenInclude(m => m.Profile) + .Include(m => m.ChatRoom) + .ThenInclude(m => m.Realm) .Where(m => m.AccountId == accountId && m.ChatRoomId == chatRoomId) .FirstOrDefaultAsync(); diff --git a/DysonNetwork.Sphere/Chat/RealtimeCallController.cs b/DysonNetwork.Sphere/Chat/RealtimeCallController.cs index d06997e..5694dc5 100644 --- a/DysonNetwork.Sphere/Chat/RealtimeCallController.cs +++ b/DysonNetwork.Sphere/Chat/RealtimeCallController.cs @@ -119,7 +119,7 @@ public class RealtimeCallController( // Fetch the ChatMember profile if we have an account ID if (p.AccountId.HasValue) - participant.Profile = await chatRoomService.GetChannelMember(p.AccountId.Value, roomId); + participant.Profile = await chatRoomService.GetRoomMember(p.AccountId.Value, roomId); participants.Add(participant); } diff --git a/DysonNetwork.Sphere/Connection/Handlers/MessageReadHandler.cs b/DysonNetwork.Sphere/Connection/Handlers/MessageReadHandler.cs index c0841e9..4018e10 100644 --- a/DysonNetwork.Sphere/Connection/Handlers/MessageReadHandler.cs +++ b/DysonNetwork.Sphere/Connection/Handlers/MessageReadHandler.cs @@ -42,7 +42,7 @@ public class MessageReadHandler( return; } - var sender = await crs.GetChannelMember(currentUser.Id, request.ChatRoomId); + var sender = await crs.GetRoomMember(currentUser.Id, request.ChatRoomId); if (sender is null) { await socket.SendAsync( diff --git a/DysonNetwork.Sphere/Connection/Handlers/MessageTypingHandler.cs b/DysonNetwork.Sphere/Connection/Handlers/MessageTypingHandler.cs index e3bf75e..723eac7 100644 --- a/DysonNetwork.Sphere/Connection/Handlers/MessageTypingHandler.cs +++ b/DysonNetwork.Sphere/Connection/Handlers/MessageTypingHandler.cs @@ -33,7 +33,7 @@ public class MessageTypingHandler(ChatRoomService crs) : IWebSocketPacketHandler return; } - var sender = await crs.GetChannelMember(currentUser.Id, request.ChatRoomId); + var sender = await crs.GetRoomMember(currentUser.Id, request.ChatRoomId); if (sender is null) { await socket.SendAsync(