From c893992f5b3a9cd6dcef359f33fa2d44ea4f899f Mon Sep 17 00:00:00 2001 From: Andriy <30056636+West14@users.noreply.github.com> Date: Mon, 14 Nov 2022 00:49:56 +0200 Subject: [PATCH] [store] add nsfw guard for boobs --- modules/ContentStore/Service/AnimBoobsService.cs | 16 ++++++++++++++-- modules/ContentStore/Service/OBoobsService.cs | 16 ++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/modules/ContentStore/Service/AnimBoobsService.cs b/modules/ContentStore/Service/AnimBoobsService.cs index ff300b9..4b5ef00 100644 --- a/modules/ContentStore/Service/AnimBoobsService.cs +++ b/modules/ContentStore/Service/AnimBoobsService.cs @@ -1,15 +1,20 @@ -using Telegram.Bot.Types.Enums; +using Kruzya.TelegramBot.Core.Data; +using Kruzya.TelegramBot.Core.Extensions; +using Telegram.Bot.Types; +using Telegram.Bot.Types.Enums; using West.TelegramBot.ContentStore.Model; namespace West.TelegramBot.ContentStore.Service; public class AnimBoobsService : IRandomMediaService { + private readonly CoreContext _db; private readonly HttpClient _httpClient; public StoreItem StoreItem { get; } = new("anim_boobs", "Сиськи движущиеся", 120, 40); - public AnimBoobsService() + public AnimBoobsService(CoreContext db) { + _db = db; _httpClient = new HttpClient() { BaseAddress = new Uri("https://westdev.me/_boobs/") @@ -24,4 +29,11 @@ public class AnimBoobsService : IRandomMediaService Type = InputMediaType.Video }; } + + public async Task CanView(Chat chat, User user) + { + var option = await _db.UserValues.FindOrCreateOption(chat.Id, "AllowNSFW"); + + return option.GetValue(false); + } } \ No newline at end of file diff --git a/modules/ContentStore/Service/OBoobsService.cs b/modules/ContentStore/Service/OBoobsService.cs index f13cf62..450b25c 100644 --- a/modules/ContentStore/Service/OBoobsService.cs +++ b/modules/ContentStore/Service/OBoobsService.cs @@ -1,15 +1,20 @@ -using Newtonsoft.Json; +using Kruzya.TelegramBot.Core.Data; +using Kruzya.TelegramBot.Core.Extensions; +using Newtonsoft.Json; +using Telegram.Bot.Types; using West.TelegramBot.ContentStore.Model; namespace West.TelegramBot.ContentStore.Service; public class OBoobsService : IRandomMediaService { + private readonly CoreContext _db; private readonly HttpClient _httpClient; public StoreItem StoreItem { get; } = new("boobs", "Сиськи", 60, 30); - public OBoobsService() + public OBoobsService(CoreContext db) { + _db = db; _httpClient = new HttpClient { BaseAddress = new Uri("http://api.oboobs.ru") @@ -26,4 +31,11 @@ public class OBoobsService : IRandomMediaService return new RandomMedia($"https://media.oboobs.ru/boobs/{boobsId}.jpg", boobsItem.Model); } + + public async Task CanView(Chat chat, User user) + { + var option = await _db.UserValues.FindOrCreateOption(chat.Id, "AllowNSFW"); + + return option.GetValue(false); + } } \ No newline at end of file