This update implements a comprehensive solution to prevent duplicate notifications when Telegram messages are edited, while maintaining a full history of changes. Features: - New TextMatch entity to store match history with versioning - Database migration for TextMatches table with proper indexes - TextMatchRepository for managing match records - TextSubscriptionUpdated event for message update notifications - Enhanced MessageReceivedHandler with deduplication logic: * First match creates version 1 and publishes TextSubscriptionMatched * Subsequent updates create new versions and publish TextSubscriptionUpdated * Skips notifications if message text hasn't changed Technical details: - MessageId changed from int to long to match Telegram API types - Proper indexes on (MessageId, SubscriptionId) and UserId - Full audit trail of message edits in database 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
26 lines
822 B
C#
26 lines
822 B
C#
using Microsoft.EntityFrameworkCore;
|
|
using Nocr.TextMatcher.AppServices.TextMatches;
|
|
using Nocr.TextMatcher.AppServices.TextSubscriptions;
|
|
using Nocr.TextMatcher.Persistence.TextMatches;
|
|
using Nocr.TextMatcher.Persistence.TextSubscriptions;
|
|
|
|
namespace Nocr.TextMatcher.Persistence;
|
|
|
|
public class TextMatcherContext : DbContext
|
|
{
|
|
public DbSet<TextSubscription> TextSubscriptions { get; set; }
|
|
public DbSet<TextMatch> TextMatches { get; set; }
|
|
|
|
public TextMatcherContext(DbContextOptions options)
|
|
: base(options)
|
|
{
|
|
}
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
modelBuilder.ApplyConfiguration(new TextSubscriptionConfiguration());
|
|
modelBuilder.ApplyConfiguration(new TextMatchConfiguration());
|
|
|
|
base.OnModelCreating(modelBuilder);
|
|
}
|
|
} |