feat(fulfillment): 支持共享账号操作并完善时间线
This commit is contained in:
@@ -19,7 +19,7 @@ from ..models import (
|
||||
LoginTask,
|
||||
User,
|
||||
)
|
||||
from ..permissions import user_has_permission
|
||||
from ..permissions import ROLE_LABELS, user_has_permission
|
||||
from ..schemas import (
|
||||
AccountAssign,
|
||||
AccountAutomationUpdate,
|
||||
@@ -1856,8 +1856,34 @@ def account_events(
|
||||
.all()
|
||||
)
|
||||
|
||||
items = [dict(row) for row in rows]
|
||||
actor_ids = {
|
||||
int(item["actor_id"])
|
||||
for item in items
|
||||
if item.get("actor_type") == "user"
|
||||
and item.get("actor_id") is not None
|
||||
}
|
||||
actors = {
|
||||
int(user.id): user
|
||||
for user in db.query(User).filter(User.id.in_(actor_ids)).all()
|
||||
} if actor_ids else {}
|
||||
for item in items:
|
||||
actor = (
|
||||
actors.get(int(item["actor_id"]))
|
||||
if item.get("actor_type") == "user"
|
||||
and item.get("actor_id") is not None
|
||||
else None
|
||||
)
|
||||
item["actor_name"] = (
|
||||
actor.deleted_username or actor.username
|
||||
) if actor is not None else ""
|
||||
item["actor_role"] = actor.role if actor is not None else ""
|
||||
item["actor_role_label"] = (
|
||||
ROLE_LABELS.get(actor.role, actor.role) if actor is not None else ""
|
||||
)
|
||||
|
||||
return {
|
||||
"items": [dict(row) for row in rows],
|
||||
"items": items,
|
||||
"total": int(total),
|
||||
"page": page,
|
||||
"page_size": page_size,
|
||||
|
||||
Reference in New Issue
Block a user