💥 Update push notification
This commit is contained in:
parent
57775eb0a1
commit
7dee2a15e7
@ -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<string, object>(),
|
||||
["data"] = new Dictionary<string, object>
|
||||
{
|
||||
["d_topic"] = notification.Topic,
|
||||
["type"] = notification.Topic,
|
||||
["meta"] = notification.Meta ?? new Dictionary<string, object>(),
|
||||
},
|
||||
["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;
|
||||
|
@ -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<ActionResult> UpdateMessage([FromBody] SendMessageRequest request, Guid roomId, Guid messageId)
|
||||
|
@ -33,7 +33,7 @@ public class ChatRoomService(AppDatabase db, ICacheService cache)
|
||||
return members;
|
||||
}
|
||||
|
||||
public async Task<ChatMember?> GetChannelMember(Guid accountId, Guid chatRoomId)
|
||||
public async Task<ChatMember?> GetRoomMember(Guid accountId, Guid chatRoomId)
|
||||
{
|
||||
var cacheKey = string.Format(ChatMemberCacheKey, accountId, chatRoomId);
|
||||
var member = await cache.GetAsync<ChatMember?>(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();
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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(
|
||||
|
@ -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(
|
||||
|
Loading…
x
Reference in New Issue
Block a user