-
Notifications
You must be signed in to change notification settings - Fork 38
Fix private REST inbox teammate lastSeenAt context #157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2043,12 +2043,21 @@ conversationRouter.openapi( | |
| return privateContext; | ||
| } | ||
|
|
||
| const actor = await requirePrivateConversationActor({ | ||
| c, | ||
| db: extracted.db, | ||
| apiKey: privateContext.apiKey, | ||
| organizationId: privateContext.organization.id, | ||
| websiteTeamId: privateContext.website.teamId, | ||
| required: false, | ||
| }); | ||
|
|
||
| const [planInfo, result] = await Promise.all([ | ||
| getPlanForWebsite(privateContext.website), | ||
| listConversationsHeaders(extracted.db, { | ||
| organizationId: privateContext.organization.id, | ||
| websiteId: privateContext.website.id, | ||
| userId: null, | ||
| userId: actor?.userId ?? null, | ||
| limit: extracted.query.limit, | ||
| cursor: extracted.query.cursor ?? null, | ||
| }), | ||
|
Comment on lines
+2046
to
2063
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
required: falsedoesn't prevent 403 for linked keys on teamless websitesresolvePrivateApiKeyActorUseronly short-circuits tonullwhencandidateUserIdis falsy (unlinked key + no explicit actor header). When a key haslinkedUserIdset — or when anX-Actor-User-Idheader is present —candidateUserIdbecomes truthy, and the next checkif (!params.websiteTeamId)throws a 403 unconditionally, regardless ofrequired. So any linked private key used against a website withteamId: null | undefinedwill now get a 403 from the inbox, where previously it always returned 200 withuserId: null.This contradicts the PR's stated goal of keeping actorless / no-team-context integrations working. The relevant path in
resolvePrivateApiKeyActorUser(apps/api/src/lib/private-api-key-actor.tslines 54-58):A catch around the call in the inbox handler, or a separate guard, is needed to handle this gracefully.