From 9fc439a5e8c13c208f25fe65201ba80eb0eb6f15 Mon Sep 17 00:00:00 2001 From: Marcel Baumgartner Date: Wed, 26 Apr 2023 18:25:39 +0200 Subject: [PATCH] Prevent message duplication with sender check --- .../App/Services/SupportChat/SupportChatAdminService.cs | 7 ++++++- .../App/Services/SupportChat/SupportChatClientService.cs | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Moonlight/App/Services/SupportChat/SupportChatAdminService.cs b/Moonlight/App/Services/SupportChat/SupportChatAdminService.cs index d613fb8f..6369f34a 100644 --- a/Moonlight/App/Services/SupportChat/SupportChatAdminService.cs +++ b/Moonlight/App/Services/SupportChat/SupportChatAdminService.cs @@ -36,8 +36,13 @@ public class SupportChatAdminService { await Event.On($"supportChat.{Recipient.Id}.message", this, async message => { - if(OnMessage != null) + if (OnMessage != null) + { + if(message.Sender != null && message.Sender.Id == User.Id) + return; + await OnMessage.Invoke(message); + } }); await Event.On($"supportChat.{Recipient.Id}.typing", this, async user => diff --git a/Moonlight/App/Services/SupportChat/SupportChatClientService.cs b/Moonlight/App/Services/SupportChat/SupportChatClientService.cs index 94060655..ad2b3eb7 100644 --- a/Moonlight/App/Services/SupportChat/SupportChatClientService.cs +++ b/Moonlight/App/Services/SupportChat/SupportChatClientService.cs @@ -35,8 +35,13 @@ public class SupportChatClientService : IDisposable { await Event.On($"supportChat.{User.Id}.message", this, async message => { - if(OnMessage != null) + if (OnMessage != null) + { + if(message.Sender != null && message.Sender.Id == User.Id) + return; + await OnMessage.Invoke(message); + } }); await Event.On($"supportChat.{User.Id}.typing", this, async user =>