Repository navigation
Conversation
Add a queries parameter to GET /v1/account/sessions and
GET /v1/users/{userId}/sessions, validated by a Sessions query
validator over the sessions collection.
Sessions are now read from the sessions collection filtered by
userInternalId, with count-based totals and cursor validation scoped
to the target user. Expired sessions are excluded unless the caller
filters on expire, and the 1000-row default limit matches the old
subquery behavior when no limit is supplied.
🟢 Tier S · Ready to merge
Adds the standard Latest changes: The latest commits add an
Note @heyrapto does not have write access to this repository, so Hansi does not approve automatically. A maintainer can review and approve. 📂 Walkthrough · 8
✅ Fixed since the last review · 1
Reviewed the commits since |
What does this PR do?
Adds the standard Query API (
queries) to both session list endpoints:GET /v1/account/sessionsGET /v1/users/{userId}/sessionsBoth endpoints now use a new
Appwrite\Utopia\Database\Validator\Queries\Sessionsvalidator (mirroring the existingIdentitiesandPasskeysvalidators). They read from thesessionscollection, filtered byuserInternalId(index_key_user), instead of the embeddedsubQuerySessionsattribute.Callers can now filter, order, limit, offset, and cursor-paginate sessions on:
$id,$createdAt,$updatedAt,ip,countryCode,continentCode,provider,userAgent,osName,osCode,osVersion,clientType,clientName,clientCode,deviceName,deviceBrand,deviceModel,deviceId,expire,factorsBehavior notes
totalnow comes fromcount()over the same filters instead ofcount($sessions), so it reflects the whole result set rather than the current page.expire >= now). A caller that filters onexpireowns the time window and can read expired sessions.limitis supplied,APP_LIMIT_SUBQUERY(1000) is applied, preserving the previous subquery cap for callers that do not paginate.sessionscollection and must belong to the target user; otherwisegeneral_cursor_not_foundis returned.current,countryName,userName, and the existing sensitive/credential handling.queriesis declared aftertotalso released positional SDK calls keep working.app/config/sdks/parameters.lock.jsonis updated forclient,console, andserver.Test Plan
Added
tests/unit/Utopia/Database/Validator/Queries/SessionsTest.php: allowed and disallowed attributes for the new validator.testListAccountSessionsQueriesintests/e2e/Services/Account/AccountCustomClientTest.php.testListUserSessionsQueriesintests/e2e/Services/Users/UsersBase.php.Both e2e tests cover:
expirewindows,total=falseRun
Related PRs and Issues
GET /v1/account/mfa/factorsis out of scope and will be handled in a separate PR.Checklist
app/config/sdks/parameters.lock.jsonis updated; generated SDK specs and docs are produced by the release process.