Реализовал stub на новое событие редактирования уже существующего сообщения.
This commit is contained in:
parent
3c3b7f9447
commit
f3df86c90a
@ -13,9 +13,10 @@ public static class ServiceCollectionExtensions
|
|||||||
throw new ArgumentNullException(nameof(services));
|
throw new ArgumentNullException(nameof(services));
|
||||||
|
|
||||||
// Add registrations here
|
// Add registrations here
|
||||||
services.AddRebusHandler<MessageReceivedHandler>();
|
services.AddRebusHandler<NewMessageHandler>();
|
||||||
|
services.AddRebusHandler<EditedMessageHandler>();
|
||||||
services.AddScoped<ITextSubscriptionsService, TextSubscriptionsService>();
|
services.AddScoped<ITextSubscriptionsService, TextSubscriptionsService>();
|
||||||
|
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -0,0 +1,30 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Nocr.TelegramListener.Async.Api.Contracts.Events;
|
||||||
|
using Rebus.Handlers;
|
||||||
|
|
||||||
|
namespace Nocr.TextMatcher.AppServices.TextSubscriptions.EventHandlers;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handler for MessageEdited events from telegram-listener.
|
||||||
|
/// Currently logs the event without processing to avoid duplicate notifications.
|
||||||
|
/// </summary>
|
||||||
|
public sealed class MessageEditedHandler : IHandleMessages<MessageEdited>
|
||||||
|
{
|
||||||
|
private readonly ILogger<MessageEditedHandler> _logger;
|
||||||
|
|
||||||
|
public MessageEditedHandler(ILogger<MessageEditedHandler> 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -10,15 +10,15 @@ using Rebus.Handlers;
|
|||||||
|
|
||||||
namespace Nocr.TextMatcher.AppServices.TextSubscriptions.EventHandlers;
|
namespace Nocr.TextMatcher.AppServices.TextSubscriptions.EventHandlers;
|
||||||
|
|
||||||
public sealed class MessageReceivedHandler : IHandleMessages<MessageReceived>
|
public sealed class NewMessageHandler : IHandleMessages<MessageReceived>
|
||||||
{
|
{
|
||||||
private readonly ILogger<MessageReceivedHandler> _logger;
|
private readonly ILogger<NewMessageHandler> _logger;
|
||||||
private readonly IBus _bus;
|
private readonly IBus _bus;
|
||||||
private readonly ITextSubscriptionRepository _textSubscriptionRepository;
|
private readonly ITextSubscriptionRepository _textSubscriptionRepository;
|
||||||
private readonly ITextMatchRepository _textMatchRepository;
|
private readonly ITextMatchRepository _textMatchRepository;
|
||||||
private readonly ICurrentDateProvider _dateProvider;
|
private readonly ICurrentDateProvider _dateProvider;
|
||||||
|
|
||||||
public MessageReceivedHandler(ILogger<MessageReceivedHandler> logger,
|
public NewMessageHandler(ILogger<NewMessageHandler> logger,
|
||||||
IBus bus,
|
IBus bus,
|
||||||
ITextSubscriptionRepository textSubscriptionRepository,
|
ITextSubscriptionRepository textSubscriptionRepository,
|
||||||
ITextMatchRepository textMatchRepository,
|
ITextMatchRepository textMatchRepository,
|
||||||
Loading…
Reference in New Issue
Block a user