feat(weibo): 增加外部 CK 单行复制

This commit is contained in:
yml2213
2026-11-08 14:13:01 +08:00
parent 5b42577b0b
commit 66b4f72994
8 changed files with 126 additions and 1 deletions
+2
View File
@@ -45,6 +45,7 @@ PERMISSIONS = {
"weibo:view": "查看微博账号",
"weibo:import": "导入/刷新微博 CK",
"weibo:manage": "编辑、停用和启用微博账号",
"weibo:account:ck_export": "复制微博外部 CK 账号的 CK(写剪贴板)",
"weibo:bind": "生成微博绑定二维码",
"weibo:recharge": "创建微博助威充值订单",
"weibo:exchange": "执行微博微豆兑换",
@@ -115,6 +116,7 @@ ROLE_PERMISSIONS = {
"weibo:view",
"weibo:import",
"weibo:manage",
"weibo:account:ck_export",
"weibo:bind",
"weibo:recharge",
"weibo:exchange",
+28
View File
@@ -16,6 +16,7 @@ from ..deps import get_current_user
from ..models import User, WeiboAccount
from ..permissions import user_has_permission
from ..schemas import (
WeiboAccountCkOut,
WeiboAccountDisableRequest,
WeiboAccountOut,
WeiboAccountUpdate,
@@ -347,6 +348,33 @@ def refresh_account(
return _account_out(account)
@router.post("/accounts/{account_id}/ck/copy", response_model=WeiboAccountCkOut)
def copy_account_ck(
account_id: int,
db: Session = Depends(get_db),
current: User = Depends(get_current_user),
):
"""复制已导入的微博 CK 明文;只走单独权限并保留审计。"""
_require_weibo_perm(current, "weibo:account:ck_export")
account = _get_account(db, account_id)
ck_text = (account.cookie or "").strip()
if not ck_text:
raise HTTPException(status_code=409, detail="该账号没有保存 CK")
_record_audit_safely(
db,
current,
action="weibo:account:ck_export",
target=f"weibo_account:{account.id}",
detail={"account_id": account.id, "uid": account.uid},
)
return WeiboAccountCkOut(
account_id=account.id,
uid=account.uid,
ck_text=ck_text,
)
@router.post("/accounts/{account_id}/bind-qrcodes", response_model=WeiboBindQrOut)
def create_bind_qrcodes(
account_id: int,
+6
View File
@@ -509,6 +509,12 @@ class WeiboAccountDisableRequest(BaseModel):
reason: str = Field("", max_length=256)
class WeiboAccountCkOut(BaseModel):
account_id: int
uid: str
ck_text: str
class WeiboImportResult(BaseModel):
success: bool
message: str