mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-11-27 17:00:37 +00:00
fix(scheduler): use current account status for conversation schedules (#8522)
Co-authored-by: Totoro-qaq <279883115+Totoro-qaq@users.noreply.github.com>
This commit is contained in:
parent
b7d1c577e3
commit
7076409781
@ -212,7 +212,7 @@ async def _owner(owner_id: str, token_version: int, *, auth_disabled_owner: bool
|
||||
user = get_auth_disabled_user() if is_auth_disabled() and owner_id == AUTH_DISABLED_USER_ID else None
|
||||
else:
|
||||
user = await get_local_provider().get_user(owner_id)
|
||||
if user is None or str(user.id) != owner_id or getattr(user, "token_version", 0) != token_version or getattr(user, "needs_setup", False) or getattr(user, "system_role", None) == INTERNAL_SYSTEM_ROLE:
|
||||
if user is None or str(user.id) != owner_id or getattr(user, "disabled", False) or getattr(user, "token_version", 0) != token_version or getattr(user, "needs_setup", False) or getattr(user, "system_role", None) == INTERNAL_SYSTEM_ROLE:
|
||||
return None
|
||||
return user
|
||||
|
||||
|
||||
@ -18,8 +18,8 @@ from deerflow.persistence.scheduled_tasks import ActiveScheduledTaskMutationConf
|
||||
_PERMISSIONS = ("threads:read", "threads:write", "runs:create")
|
||||
|
||||
|
||||
def _user(*, user_id="alice", token_version=0, role="user"):
|
||||
return SimpleNamespace(id=user_id, token_version=token_version, system_role=role, needs_setup=False)
|
||||
def _user(*, user_id="alice", token_version=0, role="user", disabled=False):
|
||||
return SimpleNamespace(id=user_id, token_version=token_version, system_role=role, needs_setup=False, disabled=disabled)
|
||||
|
||||
|
||||
_FUTURE = (datetime.now(UTC) + timedelta(days=1)).replace(microsecond=0).isoformat()
|
||||
@ -157,6 +157,21 @@ async def test_deleted_changed_or_revoked_owner_cannot_use_an_existing_grant(mon
|
||||
repo.list_manageable_from_thread.assert_not_awaited()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_suspended_owner_loses_existing_schedule_write_authority(monkeypatch):
|
||||
prepare, repo, _, _, _, provider, resolve, _ = _setup(monkeypatch)
|
||||
capability = await prepare()
|
||||
provider.get_user.return_value = _user(disabled=True)
|
||||
resolve.reset_mock()
|
||||
|
||||
result = await capability.manage(action="create", request={})
|
||||
|
||||
assert result["status_code"] == 401
|
||||
repo.create.assert_not_awaited()
|
||||
resolve.assert_not_awaited()
|
||||
assert await prepare() is None
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_live_permission_revocation_is_honored_each_action(monkeypatch):
|
||||
prepare, repo, _, _, _, _, resolve, _ = _setup(monkeypatch)
|
||||
|
||||
@ -121,6 +121,9 @@ live card with the schedule, the stop condition and buttons, and the agent
|
||||
replies in one or two sentences; IM and other non-web turns describe the
|
||||
schedule, the next run and the stop condition in plain text.
|
||||
|
||||
Conversation scheduling actions require an active owner account. The Gateway
|
||||
returns `authority_expired` when the account is no longer active.
|
||||
|
||||
- **Which tasks a conversation manages.** The tasks created in it, and, in a run
|
||||
conversation (the chat a scheduled run posted into), the task that run belongs
|
||||
to: “pause this” or “move it to 10:00” work there too. This applies only to
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user