Major database refactor (again)

This commit is contained in:
Ske
2020-08-29 13:46:27 +02:00
parent 3996cd48c7
commit c7612df37e
55 changed files with 1014 additions and 1100 deletions

View File

@@ -14,14 +14,16 @@ namespace PluralKit.Bot
private readonly LastMessageCacheService _lastMessageCache;
private readonly ProxyService _proxy;
private readonly IDatabase _db;
private readonly ModelRepository _repo;
private readonly IMetrics _metrics;
public MessageEdited(LastMessageCacheService lastMessageCache, ProxyService proxy, IDatabase db, IMetrics metrics)
public MessageEdited(LastMessageCacheService lastMessageCache, ProxyService proxy, IDatabase db, IMetrics metrics, ModelRepository repo)
{
_lastMessageCache = lastMessageCache;
_proxy = proxy;
_db = db;
_metrics = metrics;
_repo = repo;
}
public async Task Handle(MessageUpdateEventArgs evt)
@@ -36,7 +38,7 @@ namespace PluralKit.Bot
MessageContext ctx;
await using (var conn = await _db.Obtain())
using (_metrics.Measure.Timer.Time(BotMetrics.MessageContextQueryTime))
ctx = await conn.QueryMessageContext(evt.Author.Id, evt.Channel.GuildId, evt.Channel.Id);
ctx = await _repo.GetMessageContext(conn, evt.Author.Id, evt.Channel.GuildId, evt.Channel.Id);
await _proxy.HandleIncomingMessage(evt.Message, ctx, allowAutoproxy: false);
}
}