mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-09 19:29:48 +00:00
perf: 支持slack通知和认证 (#12193)
* perf: 支持slack通知和认证 * perf: 生成迁移文件 * perf: 优化获取access_token逻辑 --------- Co-authored-by: jiangweidong <weidong.jiang@fit2cloud.com>
This commit is contained in:
21
apps/notifications/backends/slack.py
Normal file
21
apps/notifications/backends/slack.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from django.conf import settings
|
||||
|
||||
from common.sdk.im.slack import Slack as Client
|
||||
from .base import BackendBase
|
||||
|
||||
|
||||
class Slack(BackendBase):
|
||||
account_field = 'slack_id'
|
||||
is_enable_field_in_settings = 'AUTH_SLACK'
|
||||
|
||||
def __init__(self):
|
||||
self.client = Client(
|
||||
bot_token=settings.SLACK_BOT_TOKEN,
|
||||
)
|
||||
|
||||
def send_msg(self, users, message, subject=None):
|
||||
accounts, __, __ = self.get_accounts(users)
|
||||
return self.client.send_text(accounts, message)
|
||||
|
||||
|
||||
backend = Slack
|
Reference in New Issue
Block a user