fixed expire settings not returned on api

This commit is contained in:
Toastie (DCS Team) 2024-10-23 19:32:12 +13:00
parent 1038576ff4
commit 746ffda946
Signed by: toastie_t0ast
GPG key ID: 27F3B6855AFD40A4
3 changed files with 5 additions and 3 deletions

View file

@ -118,7 +118,7 @@ public partial class Administration
[Priority(1)] [Priority(1)]
public async Task WarnExpire() public async Task WarnExpire()
{ {
var expireDays = await _service.GetWarnExpire(ctx.Guild.Id); var (expireDays, _) = await _service.GetWarnExpire(ctx.Guild.Id);
if (expireDays == 0) if (expireDays == 0)
await Response().Confirm(strs.warns_dont_expire).SendAsync(); await Response().Confirm(strs.warns_dont_expire).SendAsync();

View file

@ -330,11 +330,11 @@ public class UserPunishService : IEService, IReadyExecutor
await uow.SaveChangesAsync(); await uow.SaveChangesAsync();
} }
public Task<int> GetWarnExpire(ulong guildId) public Task<(int, bool)> GetWarnExpire(ulong guildId)
{ {
using var uow = _db.GetDbContext(); using var uow = _db.GetDbContext();
var config = uow.GuildConfigsForId(guildId, set => set); var config = uow.GuildConfigsForId(guildId, set => set);
return Task.FromResult(config.WarnExpireHours / 24); return Task.FromResult((config.WarnExpireHours / 24, config.WarnExpireAction == WarnExpireAction.Delete));
} }
public async Task WarnExpireAsync(ulong guildId, int days, bool delete) public async Task WarnExpireAsync(ulong guildId, int days, bool delete)

View file

@ -27,6 +27,8 @@ public sealed class WarnSvc : GrpcWarn.GrpcWarnBase, IGrpcSvc, IEService
var wsr = new WarnSettingsReply(); var wsr = new WarnSettingsReply();
(wsr.ExpiryDays, wsr.DeleteOnExpire) = await _ups.GetWarnExpire(request.GuildId);
wsr.Punishments.AddRange(list.Select(x => new WarnPunishment() wsr.Punishments.AddRange(list.Select(x => new WarnPunishment()
{ {
Action = x.Punishment.ToString(), Action = x.Punishment.ToString(),