diff --git a/src/Nocr.TextMatcher.AppServices/ServiceCollectionExtensions.cs b/src/Nocr.TextMatcher.AppServices/ServiceCollectionExtensions.cs index e62de2f..3bc3be7 100644 --- a/src/Nocr.TextMatcher.AppServices/ServiceCollectionExtensions.cs +++ b/src/Nocr.TextMatcher.AppServices/ServiceCollectionExtensions.cs @@ -13,9 +13,10 @@ public static class ServiceCollectionExtensions throw new ArgumentNullException(nameof(services)); // Add registrations here - services.AddRebusHandler(); + services.AddRebusHandler(); + services.AddRebusHandler(); services.AddScoped(); - + return services; } } \ No newline at end of file diff --git a/src/Nocr.TextMatcher.AppServices/TextSubscriptions/EventHandlers/MessageEditedHandler.cs b/src/Nocr.TextMatcher.AppServices/TextSubscriptions/EventHandlers/MessageEditedHandler.cs new file mode 100644 index 0000000..f05e2b7 --- /dev/null +++ b/src/Nocr.TextMatcher.AppServices/TextSubscriptions/EventHandlers/MessageEditedHandler.cs @@ -0,0 +1,30 @@ +using Microsoft.Extensions.Logging; +using Nocr.TelegramListener.Async.Api.Contracts.Events; +using Rebus.Handlers; + +namespace Nocr.TextMatcher.AppServices.TextSubscriptions.EventHandlers; + +/// +/// Handler for MessageEdited events from telegram-listener. +/// Currently logs the event without processing to avoid duplicate notifications. +/// +public sealed class MessageEditedHandler : IHandleMessages +{ + private readonly ILogger _logger; + + public MessageEditedHandler(ILogger logger) + { + _logger = logger ?? throw new ArgumentNullException(nameof(logger)); + } + + public Task Handle(MessageEdited message) + { + _logger.LogInformation("Received edited message event for MessageId={MessageId}, ChatUsername={ChatUsername}. Event logged but not processed to avoid duplicates.", + message.MessageId, message.ChatUsername); + + // TODO: In the future, we can implement logic to handle edited messages differently + // For now, we rely on the deduplication logic in MessageReceivedHandler + + return Task.CompletedTask; + } +} diff --git a/src/Nocr.TextMatcher.AppServices/TextSubscriptions/EventHandlers/MessageReceivedHandler.cs b/src/Nocr.TextMatcher.AppServices/TextSubscriptions/EventHandlers/NewMessageHandler.cs similarity index 96% rename from src/Nocr.TextMatcher.AppServices/TextSubscriptions/EventHandlers/MessageReceivedHandler.cs rename to src/Nocr.TextMatcher.AppServices/TextSubscriptions/EventHandlers/NewMessageHandler.cs index eed958b..9c1c7ad 100644 --- a/src/Nocr.TextMatcher.AppServices/TextSubscriptions/EventHandlers/MessageReceivedHandler.cs +++ b/src/Nocr.TextMatcher.AppServices/TextSubscriptions/EventHandlers/NewMessageHandler.cs @@ -10,15 +10,15 @@ using Rebus.Handlers; namespace Nocr.TextMatcher.AppServices.TextSubscriptions.EventHandlers; -public sealed class MessageReceivedHandler : IHandleMessages +public sealed class NewMessageHandler : IHandleMessages { - private readonly ILogger _logger; + private readonly ILogger _logger; private readonly IBus _bus; private readonly ITextSubscriptionRepository _textSubscriptionRepository; private readonly ITextMatchRepository _textMatchRepository; private readonly ICurrentDateProvider _dateProvider; - public MessageReceivedHandler(ILogger logger, + public NewMessageHandler(ILogger logger, IBus bus, ITextSubscriptionRepository textSubscriptionRepository, ITextMatchRepository textMatchRepository,