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:
Totoro 2026-11-23 20:29:39 +08:00 committed by GitHub
parent b7d1c577e3
commit 7076409781
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 21 additions and 3 deletions

View File

@ -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

View File

@ -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)

View File

@ -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