1
0
forked from erp-dev/erp
Files
erpnew/notifier/registry.py
2026-07-11 00:05:05 +08:00

18 lines
591 B
Python

from notifier.backends import JPushNotifierBackend, MessageAPINotifierBackend, WeComWebhookNotifierBackend
from notifier.models import NotifierChannelEnum
BACKEND_REGISTRY = {
NotifierChannelEnum.WECOM_WEBHOOK: WeComWebhookNotifierBackend,
NotifierChannelEnum.MESSAGE_API: MessageAPINotifierBackend,
NotifierChannelEnum.JPUSH: JPushNotifierBackend,
}
def get_notifier_backend(channel: str):
try:
backend_cls = BACKEND_REGISTRY[channel]
except KeyError as exc:
raise ValueError(f"不支持的通知渠道: {channel}") from exc
return backend_cls()