aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Messaging
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2025-07-26 19:27:44 -0500
committerJP Dillingham <jp@dillingham.me>2025-07-26 19:27:44 -0500
commit7f5e0287bd26affa613bbf855dc785216af0e22c (patch)
tree328031b1d9f22e559be0a4b7707858f4a01c0f83 /src/slskd/Messaging
parent47e2eff5029d903e59b422ddcce5e279183f8aec (diff)
downloadslskd-7f5e0287bd26affa613bbf855dc785216af0e22c.tar.gz
use slskd's semantics for PMs instead of soulseek.net's
Diffstat (limited to 'src/slskd/Messaging')
-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;
}