aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Messaging/ConversationService.cs
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2025-07-30 20:44:58 -0500
committerGitHub <noreply@github.com>2025-07-30 20:44:58 -0500
commitda71a74850b837ce6e831b9212714e510e72ca5e (patch)
tree523dc96ed715cf8098758365c6c9277c79b89fa1 /src/slskd/Messaging/ConversationService.cs
parent1fade356f1b8b38e269408aeec89e96e5fae5cb6 (diff)
parent5beeea03a1bc4f0c05467a7668c7f8a104f69206 (diff)
downloadslskd-da71a74850b837ce6e831b9212714e510e72ca5e.tar.gz
Merge pull request #1399 from slskd/msg-events
Add chat events for webhooks and scripts
Diffstat (limited to 'src/slskd/Messaging/ConversationService.cs')
-rw-r--r--src/slskd/Messaging/ConversationService.cs17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/slskd/Messaging/ConversationService.cs b/src/slskd/Messaging/ConversationService.cs
index de772ff0..b39162d6 100644
--- a/src/slskd/Messaging/ConversationService.cs
+++ b/src/slskd/Messaging/ConversationService.cs
@@ -24,6 +24,7 @@ namespace slskd.Messaging
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Serilog;
+ using slskd.Events;
using Soulseek;
/// <summary>
@@ -112,12 +113,15 @@ namespace slskd.Messaging
{
public ConversationService(
ISoulseekClient soulseekClient,
+ EventBus eventBus,
IDbContextFactory<MessagingDbContext> contextFactory)
{
SoulseekClient = soulseekClient;
+ EventBus = eventBus;
ContextFactory = contextFactory;
}
+ private EventBus EventBus { get; }
private IDbContextFactory<MessagingDbContext> ContextFactory { get; }
private ILogger Log { get; } = Serilog.Log.ForContext<ConversationService>();
private ISoulseekClient SoulseekClient { get; }
@@ -301,8 +305,12 @@ namespace slskd.Messaging
if (existing != null)
{
- // the message was replayed. ensure the local ack bit is in sync with the server
- existing.IsAcknowledged = message.IsAcknowledged;
+ // the message was replayed. either we haven't ACKed it, or we did and the ACK didn't make it to the
+ // server. either way we need to ensure that the local db understands the message needs to be ACKed, so
+ // force the bit false. we shouldn't need to update any other part of the message because IDs are unique
+ // on the soulseek server
+ existing.IsAcknowledged = false;
+ existing.WasReplayed = message.WasReplayed;
}
else
{
@@ -312,6 +320,11 @@ namespace slskd.Messaging
context.SaveChanges();
+ EventBus.Raise(new PrivateMessageReceivedEvent
+ {
+ Message = message,
+ });
+
return Task.CompletedTask;
}