mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-04-27 20:22:47 +08:00
fix bug
This commit is contained in:
@@ -74,7 +74,7 @@ class _MessageBase:
|
||||
return None
|
||||
return self._configs.get(name)
|
||||
|
||||
def checkMessage(self, message: Notification, source: str) -> bool:
|
||||
def checkMessage(self, message: Notification, source: str = None) -> bool:
|
||||
"""
|
||||
检查消息渠道及消息类型,如不符合则不处理
|
||||
"""
|
||||
|
||||
@@ -2,14 +2,12 @@ from pathlib import Path
|
||||
from typing import Optional
|
||||
from xml.dom import minidom
|
||||
|
||||
from app.core.config import settings
|
||||
from app.core.context import MediaInfo
|
||||
from app.schemas.types import MediaType
|
||||
from app.utils.dom import DomUtils
|
||||
|
||||
|
||||
class DoubanScraper:
|
||||
_transfer_type = settings.TRANSFER_TYPE
|
||||
_force_nfo = False
|
||||
_force_img = False
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ from app.utils.dom import DomUtils
|
||||
|
||||
class TmdbScraper:
|
||||
tmdb = None
|
||||
_transfer_type = settings.TRANSFER_TYPE
|
||||
_force_nfo = False
|
||||
_force_img = False
|
||||
|
||||
|
||||
@@ -5,11 +5,11 @@ from pywebpush import webpush, WebPushException
|
||||
|
||||
from app.core.config import global_vars, settings
|
||||
from app.log import logger
|
||||
from app.modules import _ModuleBase
|
||||
from app.schemas import MessageChannel, Notification
|
||||
from app.modules import _ModuleBase, _MessageBase
|
||||
from app.schemas import Notification
|
||||
|
||||
|
||||
class WebPushModule(_ModuleBase):
|
||||
class WebPushModule(_ModuleBase, _MessageBase):
|
||||
def init_module(self) -> None:
|
||||
pass
|
||||
|
||||
@@ -27,9 +27,8 @@ class WebPushModule(_ModuleBase):
|
||||
return True, ""
|
||||
|
||||
def init_setting(self) -> Tuple[str, Union[str, bool]]:
|
||||
return "MESSAGER", "webpush"
|
||||
pass
|
||||
|
||||
@checkMessage(MessageChannel.WebPush)
|
||||
def post_message(self, message: Notification) -> None:
|
||||
"""
|
||||
发送消息
|
||||
@@ -39,6 +38,9 @@ class WebPushModule(_ModuleBase):
|
||||
if not message.title and not message.text:
|
||||
logger.warn("标题和内容不能同时为空")
|
||||
return
|
||||
if not self.checkMessage(message):
|
||||
logger.warn("WebPush 通道未启用")
|
||||
return
|
||||
try:
|
||||
if message.title:
|
||||
caption = message.title
|
||||
|
||||
Reference in New Issue
Block a user