mirror of
https://github.com/Bubuni-Team/telegram-bot.git
synced 2026-07-31 00:29:24 +03:00
[store] Make store use AllowNSFW option
This commit is contained in:
@@ -1,25 +1,23 @@
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
using BotFramework.Utils;
|
||||
using Kruzya.TelegramBot.Core.Data;
|
||||
using Kruzya.TelegramBot.Core.Extensions;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Telegram.Bot.Types;
|
||||
using West.TelegramBot.ContentStore.Model;
|
||||
using West.TelegramBot.ContentStore.Option;
|
||||
|
||||
namespace West.TelegramBot.ContentStore.Service;
|
||||
|
||||
public abstract class AbstractKittiesService : IRandomMediaService
|
||||
{
|
||||
private readonly CoreContext _db;
|
||||
private readonly AllowNsfw _allowNsfw;
|
||||
protected abstract string VideoType { get; }
|
||||
|
||||
public abstract StoreItem StoreItem { get; }
|
||||
private readonly HttpClient _httpClient;
|
||||
|
||||
protected AbstractKittiesService(IConfiguration configuration, CoreContext db)
|
||||
protected AbstractKittiesService(IConfiguration configuration, AllowNsfw allowNsfw)
|
||||
{
|
||||
_db = db;
|
||||
var section = configuration.GetSection("KittiesService");
|
||||
|
||||
var uri = section.GetValue<Uri>("Uri");
|
||||
@@ -33,6 +31,7 @@ public abstract class AbstractKittiesService : IRandomMediaService
|
||||
Authorization = new AuthenticationHeaderValue("Bearer", token)
|
||||
}
|
||||
};
|
||||
_allowNsfw = allowNsfw;
|
||||
}
|
||||
|
||||
public async Task<RandomMedia> GetRandomMediaAsync()
|
||||
@@ -52,8 +51,6 @@ public abstract class AbstractKittiesService : IRandomMediaService
|
||||
|
||||
public async Task<bool> CanView(Chat chat, User user)
|
||||
{
|
||||
var option = await _db.UserValues.FindOrCreateOption(chat.Id, "AllowNSFW");
|
||||
|
||||
return option.GetValue(false);
|
||||
return await _allowNsfw.GetValueAsync(chat.Id);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user