fix(backend): ignore proxied messages if the original is ignored
This commit is contained in:
parent
cb43ac1a50
commit
84c3b42874
2 changed files with 29 additions and 6 deletions
|
|
@ -144,6 +144,19 @@ public partial class PkMessageHandler(ILogger logger, IServiceProvider services)
|
|||
await using var messageRepository =
|
||||
scope.ServiceProvider.GetRequiredService<MessageRepository>();
|
||||
|
||||
if (await messageRepository.IsMessageIgnoredAsync(originalId))
|
||||
{
|
||||
_logger.Debug(
|
||||
"Proxied message {MessageId} should be ignored as trigger {OriginalId} is already ignored",
|
||||
msgId,
|
||||
originalId
|
||||
);
|
||||
|
||||
await messageRepository.IgnoreMessageAsync(originalId);
|
||||
await messageRepository.IgnoreMessageAsync(msgId);
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.Debug(
|
||||
"Setting proxy data for {MessageId} and ignoring {OriginalId}",
|
||||
msgId,
|
||||
|
|
@ -195,6 +208,19 @@ public partial class PkMessageHandler(ILogger logger, IServiceProvider services)
|
|||
pkMessage.Original
|
||||
);
|
||||
|
||||
if (await messageRepository.IsMessageIgnoredAsync(pkMessage.Original))
|
||||
{
|
||||
_logger.Debug(
|
||||
"Proxied message {MessageId} should be ignored as trigger {OriginalId} is already ignored",
|
||||
pkMessage.Id,
|
||||
pkMessage.Original
|
||||
);
|
||||
|
||||
await messageRepository.IgnoreMessageAsync(pkMessage.Original);
|
||||
await messageRepository.IgnoreMessageAsync(msgId);
|
||||
return;
|
||||
}
|
||||
|
||||
await messageRepository.SetProxiedMessageDataAsync(
|
||||
msgId,
|
||||
pkMessage.Original,
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ using Catalogger.Backend.Database.Repositories;
|
|||
using Catalogger.Backend.Extensions;
|
||||
using Catalogger.Backend.Services;
|
||||
using Humanizer;
|
||||
using NodaTime;
|
||||
using Remora.Discord.API;
|
||||
using Remora.Discord.API.Abstractions.Gateway.Events;
|
||||
using Remora.Discord.API.Abstractions.Objects;
|
||||
|
|
@ -27,7 +26,6 @@ using Remora.Discord.Extensions.Embeds;
|
|||
using Remora.Discord.Gateway.Responders;
|
||||
using Remora.Rest.Core;
|
||||
using Remora.Results;
|
||||
using Serilog.Context;
|
||||
|
||||
namespace Catalogger.Backend.Bot.Responders.Messages;
|
||||
|
||||
|
|
@ -38,7 +36,6 @@ public class MessageDeleteResponder(
|
|||
WebhookExecutorService webhookExecutor,
|
||||
ChannelCache channelCache,
|
||||
UserCache userCache,
|
||||
IClock clock,
|
||||
PluralkitApiService pluralkitApi
|
||||
) : IResponder<IMessageDelete>
|
||||
{
|
||||
|
|
@ -81,8 +78,8 @@ public class MessageDeleteResponder(
|
|||
new Embed(
|
||||
Title: "Message deleted",
|
||||
Description: $"A message not found in the database was deleted in <#{evt.ChannelID}> ({evt.ChannelID}).",
|
||||
Footer: new EmbedFooter(Text: $"ID: {evt.ID}"),
|
||||
Timestamp: clock.GetCurrentInstant().ToDateTimeOffset()
|
||||
Footer: new EmbedFooter(Text: $"ID: {evt.ID} | Original sent at"),
|
||||
Timestamp: evt.ID.Timestamp
|
||||
)
|
||||
);
|
||||
|
||||
|
|
@ -124,7 +121,7 @@ public class MessageDeleteResponder(
|
|||
.WithTitle("Message deleted")
|
||||
.WithDescription(msg.Content)
|
||||
.WithColour(DiscordUtils.Red)
|
||||
.WithFooter($"ID: {msg.Id}")
|
||||
.WithFooter($"ID: {msg.Id} | Original sent at")
|
||||
.WithTimestamp(evt.ID);
|
||||
|
||||
if (user != null)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue