mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-13 05:49:07 +00:00
feat: 添加 飞书 (#6602)
* feat: 添加 飞书 Co-authored-by: xinwen <coderWen@126.com> Co-authored-by: wenyann <64353056+wenyann@users.noreply.github.com>
This commit is contained in:
@@ -5,6 +5,7 @@ from .dingtalk import DingTalk
|
||||
from .email import Email
|
||||
from .site_msg import SiteMessage
|
||||
from .wecom import WeCom
|
||||
from .feishu import FeiShu
|
||||
|
||||
|
||||
class BACKEND(models.TextChoices):
|
||||
@@ -12,6 +13,7 @@ class BACKEND(models.TextChoices):
|
||||
WECOM = 'wecom', _('WeCom')
|
||||
DINGTALK = 'dingtalk', _('DingTalk')
|
||||
SITE_MSG = 'site_msg', _('Site message')
|
||||
FEISHU = 'feishu', _('FeiShu')
|
||||
|
||||
@property
|
||||
def client(self):
|
||||
@@ -19,7 +21,8 @@ class BACKEND(models.TextChoices):
|
||||
self.EMAIL: Email,
|
||||
self.WECOM: WeCom,
|
||||
self.DINGTALK: DingTalk,
|
||||
self.SITE_MSG: SiteMessage
|
||||
self.SITE_MSG: SiteMessage,
|
||||
self.FEISHU: FeiShu,
|
||||
}[self]
|
||||
return client
|
||||
|
||||
|
@@ -1,5 +1,4 @@
|
||||
from django.conf import settings
|
||||
|
||||
from common.message.backends.dingtalk import DingTalk as Client
|
||||
from .base import BackendBase
|
||||
|
||||
|
19
apps/notifications/backends/feishu.py
Normal file
19
apps/notifications/backends/feishu.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from django.conf import settings
|
||||
|
||||
from common.message.backends.feishu import FeiShu as Client
|
||||
from .base import BackendBase
|
||||
|
||||
|
||||
class FeiShu(BackendBase):
|
||||
account_field = 'feishu_id'
|
||||
is_enable_field_in_settings = 'AUTH_FEISHU'
|
||||
|
||||
def __init__(self):
|
||||
self.client = Client(
|
||||
app_id=settings.FEISHU_APP_ID,
|
||||
app_secret=settings.FEISHU_APP_SECRET
|
||||
)
|
||||
|
||||
def send_msg(self, users, msg):
|
||||
accounts, __, __ = self.get_accounts(users)
|
||||
return self.client.send_text(accounts, msg)
|
Reference in New Issue
Block a user