[store] Make store use AllowNSFW option

This commit is contained in:
Andriy
2023-07-21 18:40:24 +03:00
parent 613ac5ae22
commit 4893c1240d
11 changed files with 47 additions and 46 deletions
@@ -0,0 +1,19 @@
using Telegram.Bot.Types;
using West.TelegramBot.ContentStore.Model;
using West.TelegramBot.ContentStore.Option;
namespace West.TelegramBot.ContentStore.Service;
public abstract class AbstractNsfwService : IRandomMediaService
{
private readonly AllowNsfw _allowNsfw;
public abstract StoreItem StoreItem { get; }
public abstract Task<RandomMedia> GetRandomMediaAsync();
protected AbstractNsfwService(AllowNsfw allowNsfw)
{
_allowNsfw = allowNsfw;
}
public async Task<bool> CanView(Chat chat, User user) => await _allowNsfw.GetValueAsync(chat.Id);
}