mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2024-10-02 12:09:07 +00:00
dev: .qid cleaned up
This commit is contained in:
parent
c31c2e8d8e
commit
d24e6fd8e7
2 changed files with 10 additions and 11 deletions
|
@ -106,13 +106,7 @@ public partial class Utility
|
|||
[RequireContext(ContextType.Guild)]
|
||||
public async Task QuoteShow(kwum quoteId)
|
||||
{
|
||||
Quote? quote;
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
quote = uow.Set<Quote>().GetById(quoteId);
|
||||
if (quote?.GuildId != ctx.Guild.Id)
|
||||
quote = null;
|
||||
}
|
||||
var quote = await _service.GetQuoteByIdAsync(ctx.Guild.Id, quoteId);
|
||||
|
||||
if (quote is null)
|
||||
{
|
||||
|
@ -224,9 +218,9 @@ public partial class Utility
|
|||
if (quoteId < 0)
|
||||
return;
|
||||
|
||||
var quote = await _service.GetQuoteByIdAsync(quoteId);
|
||||
var quote = await _service.GetQuoteByIdAsync(ctx.Guild.Id, quoteId);
|
||||
|
||||
if (quote is null || quote.GuildId != ctx.Guild.Id)
|
||||
if (quote is null)
|
||||
{
|
||||
await Response().Error(strs.quotes_notfound).SendAsync();
|
||||
return;
|
||||
|
|
|
@ -118,9 +118,14 @@ public sealed class QuoteService : IQuoteService, INService
|
|||
return count;
|
||||
}
|
||||
|
||||
public async Task<Quote> GetQuoteByIdAsync(kwum quoteId)
|
||||
public async Task<Quote?> GetQuoteByIdAsync(ulong guildId, kwum quoteId)
|
||||
{
|
||||
await using var uow = _db.GetDbContext();
|
||||
return uow.Set<Quote>().GetById(quoteId);
|
||||
|
||||
var quote = await uow.GetTable<Quote>()
|
||||
.Where(x => x.Id == quoteId && x.GuildId == guildId)
|
||||
.FirstOrDefaultAsyncLinqToDB();
|
||||
|
||||
return quote;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue