refactor: 移除邮件功能

发信能力整体下线,唯一的调用方(忘记密码)前端也从来没接过。

- utils/shortcuts.py 删 send_email,连带四个 django.core.mail 相关 import
- account/tasks.py 整个删除,里面只有 send_email_async 一个 actor
- 删 ApplyResetPasswordAPI / ResetPasswordAPI 及其路由、serializer,
  User.reset_password_token 和 reset_password_token_expire_time 两个
  字段(account/0010)
- 删 SMTPAPI / SMTPTestAPI 及其路由、三个 SMTP serializer、
  SysOptions.smtp_config
- account/templates/reset_password_email.html

options/0003 数据迁移删掉库里的 smtp_config 行:_init_option 会为每个
OptionKey 建行,key 从代码里去掉后它会变成孤儿,而且配过 SMTP 的话
value 里存着明文密码。

保留 ResetUserPasswordAPI(管理端直接重置密码,不发信,前端在用)和
User.email(注册要填)。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-05 23:17:48 -06:00
parent 8d35d5c2de
commit 927f235537
13 changed files with 46 additions and 245 deletions

View File

@@ -0,0 +1,24 @@
# 邮件功能已整体移除smtp_config 不再有读写方。_init_option 建过的那一行会留在
# 库里成为孤儿,且里面存着明文 SMTP 密码,这里一并删掉。
from django.db import migrations
def remove_smtp_config(apps, schema_editor):
SysOptions = apps.get_model("options", "SysOptions")
SysOptions.objects.filter(key="smtp_config").delete()
def restore_smtp_config(apps, schema_editor):
SysOptions = apps.get_model("options", "SysOptions")
SysOptions.objects.get_or_create(key="smtp_config", defaults={"value": {}})
class Migration(migrations.Migration):
dependencies = [
("options", "0002_add_sql_language"),
]
operations = [
migrations.RunPython(remove_smtp_config, restore_smtp_config),
]

View File

@@ -102,7 +102,6 @@ class OptionKeys:
allow_register = "allow_register"
submission_list_show_all = "submission_list_show_all"
class_list = "class_list"
smtp_config = "smtp_config"
judge_server_token = "judge_server_token"
throttling = "throttling"
languages = "languages"
@@ -117,7 +116,6 @@ class OptionDefaultValue:
allow_register = True
submission_list_show_all = True
class_list = []
smtp_config = {}
judge_server_token = default_token
throttling = {"ip": {"capacity": 100, "fill_rate": 0.1, "default_capacity": 50}, "user": {"capacity": 20, "fill_rate": 0.03, "default_capacity": 10}}
languages = languages
@@ -242,14 +240,6 @@ class _SysOptionsMeta(type):
def class_list(cls, value):
cls._set_option(OptionKeys.class_list, value)
@my_property
def smtp_config(cls):
return cls._get_option(OptionKeys.smtp_config)
@smtp_config.setter
def smtp_config(cls, value):
cls._set_option(OptionKeys.smtp_config, value)
@my_property(ttl=DEFAULT_SHORT_TTL)
def judge_server_token(cls):
return cls._get_option(OptionKeys.judge_server_token)