mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-07 02:10:23 +00:00
feat: 站内信 (#6183)
* 添加站内信 * s * s * 添加接口 * fix * fix * 重构了一些 * 完成 * 完善 * s * s * s * s * s * s * 测试ok * 替换业务中发送消息的方式 * 修改 * s * 去掉 update 兼容 create * 添加 unread total 接口 * 调整json字段 Co-authored-by: xinwen <coderWen@126.com>
This commit is contained in:
36
apps/notifications/backends/__init__.py
Normal file
36
apps/notifications/backends/__init__.py
Normal file
@@ -0,0 +1,36 @@
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.db import models
|
||||
|
||||
from .dingtalk import DingTalk
|
||||
from .email import Email
|
||||
from .site_msg import SiteMessage
|
||||
from .wecom import WeCom
|
||||
|
||||
|
||||
class BACKEND(models.TextChoices):
|
||||
EMAIL = 'email', _('Email')
|
||||
WECOM = 'wecom', _('WeCom')
|
||||
DINGTALK = 'dingtalk', _('DingTalk')
|
||||
SITE_MSG = 'site_msg', _('Site message')
|
||||
|
||||
@property
|
||||
def client(self):
|
||||
client = {
|
||||
self.EMAIL: Email,
|
||||
self.WECOM: WeCom,
|
||||
self.DINGTALK: DingTalk,
|
||||
self.SITE_MSG: SiteMessage
|
||||
}[self]
|
||||
return client
|
||||
|
||||
def get_account(self, user):
|
||||
return self.client.get_account(user)
|
||||
|
||||
@property
|
||||
def is_enable(self):
|
||||
return self.client.is_enable()
|
||||
|
||||
@classmethod
|
||||
def filter_enable_backends(cls, backends):
|
||||
enable_backends = [b for b in backends if cls(b).is_enable]
|
||||
return enable_backends
|
Reference in New Issue
Block a user