feat(weibo): 增加工作台独占与快捷操作
This commit is contained in:
@@ -18,7 +18,7 @@ from core.weibo import (
|
||||
normalize_weibo_cookie,
|
||||
)
|
||||
|
||||
from ..models import WeiboAccount
|
||||
from ..models import WeiboAccount, WeiboWorkbenchAccount
|
||||
|
||||
|
||||
@dataclass(frozen=True, slots=True)
|
||||
@@ -61,6 +61,8 @@ def import_weibo_cookies(
|
||||
text: str,
|
||||
tag: str = "",
|
||||
activity: str = "",
|
||||
update_existing: bool = False,
|
||||
current_user_id: int | None = None,
|
||||
) -> tuple[list[WeiboAccount], list[WeiboImportIssue], int]:
|
||||
"""逐行验证并导入微博 CK。
|
||||
|
||||
@@ -95,6 +97,23 @@ def import_weibo_cookies(
|
||||
account = (
|
||||
db.query(WeiboAccount).filter(WeiboAccount.uid == snapshot.uid).first()
|
||||
)
|
||||
if account is not None and update_existing and current_user_id is not None:
|
||||
owner_id = (
|
||||
db.query(WeiboWorkbenchAccount.user_id)
|
||||
.filter(WeiboWorkbenchAccount.account_id == account.id)
|
||||
.scalar()
|
||||
)
|
||||
if owner_id is not None and owner_id != current_user_id:
|
||||
errors.append(
|
||||
WeiboImportIssue(
|
||||
line=line_no,
|
||||
message="该账号已被其他人的工作台占用,不能更新 CK",
|
||||
)
|
||||
)
|
||||
continue
|
||||
if account is not None and not update_existing:
|
||||
skipped += 1
|
||||
continue
|
||||
if account is None:
|
||||
account = WeiboAccount(uid=snapshot.uid, cookie=cookie)
|
||||
db.add(account)
|
||||
|
||||
Reference in New Issue
Block a user