2021-05-31 09:20:38 +00:00
|
|
|
from django.conf import settings
|
2021-10-21 08:50:11 +00:00
|
|
|
from common.sdk.im.dingtalk import DingTalk as Client
|
2021-05-31 09:20:38 +00:00
|
|
|
from .base import BackendBase
|
|
|
|
|
|
|
|
|
|
|
|
class DingTalk(BackendBase):
|
|
|
|
account_field = 'dingtalk_id'
|
|
|
|
is_enable_field_in_settings = 'AUTH_DINGTALK'
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
self.dingtalk = Client(
|
|
|
|
appid=settings.DINGTALK_APPKEY,
|
|
|
|
appsecret=settings.DINGTALK_APPSECRET,
|
|
|
|
agentid=settings.DINGTALK_AGENTID
|
|
|
|
)
|
|
|
|
|
2021-08-24 06:20:54 +00:00
|
|
|
def send_msg(self, users, message, subject=None):
|
2021-05-31 09:20:38 +00:00
|
|
|
accounts, __, __ = self.get_accounts(users)
|
2021-12-15 07:01:46 +00:00
|
|
|
return self.dingtalk.send_markdown(accounts, subject, message)
|
2021-08-24 06:20:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
backend = DingTalk
|