mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-25 14:50:24 +00:00
@@ -6,7 +6,7 @@ from .base import BackendBase
|
||||
|
||||
class SMS(BackendBase):
|
||||
account_field = 'phone'
|
||||
is_enable_field_in_settings = 'AUTH_SMS'
|
||||
is_enable_field_in_settings = 'SMS_ENABLED'
|
||||
|
||||
def __init__(self):
|
||||
"""
|
||||
|
@@ -44,7 +44,7 @@ class Migration(migrations.Migration):
|
||||
('id', models.UUIDField(default=uuid.uuid4, primary_key=True, serialize=False)),
|
||||
('message_type', models.CharField(max_length=128)),
|
||||
('receive_backends', models.JSONField(default=list)),
|
||||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='user_msg_subscriptions', to=settings.AUTH_USER_MODEL)),
|
||||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='user_msg_subscription', to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
options={
|
||||
'abstract': False,
|
||||
|
@@ -1,4 +1,4 @@
|
||||
# Generated by Django 3.1.12 on 2021-08-23 08:19
|
||||
# Generated by Django 3.1.12 on 2021-09-09 11:46
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
@@ -20,6 +20,6 @@ class Migration(migrations.Migration):
|
||||
migrations.AlterField(
|
||||
model_name='usermsgsubscription',
|
||||
name='user',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='user_msg_subscriptions', to=settings.AUTH_USER_MODEL, unique=True),
|
||||
field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='user_msg_subscription', to=settings.AUTH_USER_MODEL),
|
||||
),
|
||||
]
|
@@ -35,7 +35,7 @@ class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('users', '0036_user_feishu_id'),
|
||||
('notifications', '0002_auto_20210823_1619'),
|
||||
('notifications', '0002_auto_20210909_1946'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
|
@@ -6,7 +6,7 @@ __all__ = ('SystemMsgSubscription', 'UserMsgSubscription')
|
||||
|
||||
|
||||
class UserMsgSubscription(JMSModel):
|
||||
user = models.OneToOneField('users.User', related_name='user_msg_subscriptions', on_delete=models.CASCADE)
|
||||
user = models.OneToOneField('users.User', related_name='user_msg_subscription', on_delete=models.CASCADE)
|
||||
receive_backends = models.JSONField(default=list)
|
||||
|
||||
def __str__(self):
|
||||
|
@@ -68,6 +68,9 @@ class Message(metaclass=MessageType):
|
||||
raise NotImplementedError
|
||||
|
||||
def send_msg(self, users: Iterable, backends: Iterable = BACKEND):
|
||||
backends = set(backends)
|
||||
backends.add(BACKEND.SITE_MSG) # 站内信必须发
|
||||
|
||||
for backend in backends:
|
||||
try:
|
||||
backend = BACKEND(backend)
|
||||
|
Reference in New Issue
Block a user