mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-06-05 15:39:40 +08:00
refactor(module): simplify service instantiation with generics
This commit is contained in:
@@ -4,24 +4,18 @@ from typing import Union, Tuple
|
||||
from pywebpush import webpush, WebPushException
|
||||
|
||||
from app.core.config import global_vars, settings
|
||||
from app.helper.notification import NotificationHelper
|
||||
from app.log import logger
|
||||
from app.modules import _ModuleBase, _MessageBase
|
||||
from app.schemas import Notification
|
||||
|
||||
|
||||
class WebPushModule(_ModuleBase, _MessageBase):
|
||||
|
||||
def init_module(self) -> None:
|
||||
"""
|
||||
初始化模块
|
||||
"""
|
||||
clients = NotificationHelper().get_clients()
|
||||
if not clients:
|
||||
return
|
||||
self._configs = {}
|
||||
for client in clients:
|
||||
if client.type == "webpush" and client.enabled:
|
||||
self._configs[client.name] = client
|
||||
super().init_service(service_name=self.get_name().lower())
|
||||
|
||||
@staticmethod
|
||||
def get_name() -> str:
|
||||
|
||||
Reference in New Issue
Block a user