From 04f50284c6b6ea7e38e1d29d4d0dd65f4970e41f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=AF=E5=A4=A7=E4=BE=A0?= Date: Wed, 27 Mar 2024 00:54:40 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E5=88=A0=E9=99=A4=E7=AB=99=E7=82=B9?= =?UTF-8?q?=E4=BC=9A=E5=AF=BC=E8=87=B4=E5=85=B6=E8=AE=A2=E9=98=85=E7=9A=84?= =?UTF-8?q?=E7=AB=99=E7=82=B9=E5=88=97=E8=A1=A8=E5=87=BA=E7=8E=B0=E6=95=B0?= =?UTF-8?q?=E5=AD=97ID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/chain/subscribe.py | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/app/chain/subscribe.py b/app/chain/subscribe.py index 5aa86c08..2d671816 100644 --- a/app/chain/subscribe.py +++ b/app/chain/subscribe.py @@ -12,6 +12,7 @@ from app.chain.search import SearchChain from app.chain.torrents import TorrentsChain from app.core.config import settings from app.core.context import TorrentInfo, Context, MediaInfo +from app.core.event import eventmanager, Event from app.core.meta import MetaBase from app.core.metainfo import MetaInfo from app.db.models.subscribe import Subscribe @@ -21,7 +22,7 @@ from app.helper.message import MessageHelper from app.helper.torrent import TorrentHelper from app.log import logger from app.schemas import NotExistMediaInfo, Notification -from app.schemas.types import MediaType, SystemConfigKey, MessageChannel, NotificationType +from app.schemas.types import MediaType, SystemConfigKey, MessageChannel, NotificationType, EventType from app.utils.string import StringUtils @@ -956,3 +957,33 @@ class SubscribeChain(ChainBase): start_episode=start_episode ) return no_exists + + @eventmanager.register(EventType.SiteDeleted) + def remove_site(self, event: Event): + """ + 从订阅中移除与站点相关的设置 + """ + if not event: + return + event_data = event.event_data or {} + site_id = event_data.get("site_id") + if not site_id: + return + # 从选中的rss站点中移除 + selected_sites = SystemConfigOper().get(SystemConfigKey.RssSites) or [] + if site_id in selected_sites: + selected_sites.remove(site_id) + SystemConfigOper().set(SystemConfigKey.RssSites, selected_sites) + # 查询所有订阅 + subscribes = self.subscribeoper.list() + for subscribe in subscribes: + if not subscribe.sites: + continue + sites = json.loads(subscribe.sites) or [] + if site_id not in sites: + continue + sites.remove(site_id) + sites = json.dumps(sites) + self.subscribeoper.update(subscribe.id, { + "sites": sites + })