fix
This commit is contained in:
parent
cdeb601528
commit
df30b71077
@ -13,7 +13,7 @@ from app.db import get_db
|
|||||||
from app.db.systemconfig_oper import SystemConfigOper
|
from app.db.systemconfig_oper import SystemConfigOper
|
||||||
from app.log import logger
|
from app.log import logger
|
||||||
from app.modules.wechat.WXBizMsgCrypt3 import WXBizMsgCrypt
|
from app.modules.wechat.WXBizMsgCrypt3 import WXBizMsgCrypt
|
||||||
from app.schemas import Notification
|
from app.schemas import NotificationSwitch
|
||||||
from app.schemas.types import SystemConfigKey, NotificationType
|
from app.schemas.types import SystemConfigKey, NotificationType
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
@ -62,7 +62,7 @@ def wechat_verify(echostr: str, msg_signature: str,
|
|||||||
return PlainTextResponse(sEchoStr)
|
return PlainTextResponse(sEchoStr)
|
||||||
|
|
||||||
|
|
||||||
@router.get("/switchs", summary="查询通知消息渠道开关", response_model=List[Notification])
|
@router.get("/switchs", summary="查询通知消息渠道开关", response_model=List[NotificationSwitch])
|
||||||
def read_switchs(db: Session = Depends(get_db),
|
def read_switchs(db: Session = Depends(get_db),
|
||||||
_: schemas.TokenPayload = Depends(verify_token)) -> Any:
|
_: schemas.TokenPayload = Depends(verify_token)) -> Any:
|
||||||
"""
|
"""
|
||||||
@ -73,13 +73,13 @@ def read_switchs(db: Session = Depends(get_db),
|
|||||||
switchs = SystemConfigOper(db).get(SystemConfigKey.NotificationChannels)
|
switchs = SystemConfigOper(db).get(SystemConfigKey.NotificationChannels)
|
||||||
if not switchs:
|
if not switchs:
|
||||||
for noti in NotificationType:
|
for noti in NotificationType:
|
||||||
return_list.append(Notification(mtype=noti.value, switch=True))
|
return_list.append(NotificationSwitch(mtype=noti.value, wechat=True, telegram=True, slack=True))
|
||||||
|
|
||||||
return return_list
|
return return_list
|
||||||
|
|
||||||
|
|
||||||
@router.put("/switchs", summary="设置通知消息渠道开关", response_model=schemas.Response)
|
@router.put("/switchs", summary="设置通知消息渠道开关", response_model=schemas.Response)
|
||||||
def set_switchs(switchs: List[Notification],
|
def set_switchs(switchs: List[NotificationSwitch],
|
||||||
db: Session = Depends(get_db),
|
db: Session = Depends(get_db),
|
||||||
_: schemas.TokenPayload = Depends(verify_token)) -> Any:
|
_: schemas.TokenPayload = Depends(verify_token)) -> Any:
|
||||||
"""
|
"""
|
||||||
|
@ -3,7 +3,7 @@ from typing import Optional, Dict, List, Union
|
|||||||
|
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
from app.schemas.types import MediaType
|
from app.schemas.types import MediaType, NotificationType
|
||||||
|
|
||||||
|
|
||||||
class MetaInfo(BaseModel):
|
class MetaInfo(BaseModel):
|
||||||
@ -314,7 +314,7 @@ class Notification(BaseModel):
|
|||||||
消息
|
消息
|
||||||
"""
|
"""
|
||||||
# 消息类型
|
# 消息类型
|
||||||
mtype: Optional[str] = None
|
mtype: Optional[NotificationType] = None
|
||||||
# 标题
|
# 标题
|
||||||
title: Optional[str] = None
|
title: Optional[str] = None
|
||||||
# 内容
|
# 内容
|
||||||
@ -325,5 +325,17 @@ class Notification(BaseModel):
|
|||||||
link: Optional[str] = None
|
link: Optional[str] = None
|
||||||
# 用户ID
|
# 用户ID
|
||||||
user_id: Optional[str] = None
|
user_id: Optional[str] = None
|
||||||
# 开关
|
|
||||||
switch: Optional[bool] = True
|
|
||||||
|
class NotificationSwitch(BaseModel):
|
||||||
|
"""
|
||||||
|
消息开关
|
||||||
|
"""
|
||||||
|
# 消息类型
|
||||||
|
mtype: Optional[str] = None
|
||||||
|
# 微信开关
|
||||||
|
wechat: Optional[bool] = False
|
||||||
|
# TG开关
|
||||||
|
telegram: Optional[bool] = False
|
||||||
|
# Slack开关
|
||||||
|
slack: Optional[bool] = False
|
||||||
|
Loading…
x
Reference in New Issue
Block a user