Skip to content

Commit

Permalink
Add isSelfHosted to SessionAccount (bluesky-social#7028)
Browse files Browse the repository at this point in the history
* Add isSelfHosted to SessionAccount

* Update snaps
  • Loading branch information
estrattonbailey authored Dec 9, 2024
1 parent 63c0c7e commit bc4b4a3
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/state/persisted/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const accountSchema = z.object({
*/
status: z.string().optional(),
pdsUrl: z.string().optional(),
isSelfHosted: z.boolean().optional(),
})
export type PersistedAccount = z.infer<typeof accountSchema>

Expand Down
31 changes: 31 additions & 0 deletions src/state/session/__tests__/session-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ describe('session', () => {
"emailAuthFactor": false,
"emailConfirmed": false,
"handle": "alice.test",
"isSelfHosted": true,
"pdsUrl": undefined,
"refreshJwt": "alice-refresh-jwt-1",
"service": "https://alice.com/",
Expand Down Expand Up @@ -100,6 +101,7 @@ describe('session', () => {
"emailAuthFactor": false,
"emailConfirmed": false,
"handle": "alice.test",
"isSelfHosted": true,
"pdsUrl": undefined,
"refreshJwt": undefined,
"service": "https://alice.com/",
Expand Down Expand Up @@ -152,6 +154,7 @@ describe('session', () => {
"emailAuthFactor": false,
"emailConfirmed": false,
"handle": "alice.test",
"isSelfHosted": true,
"pdsUrl": undefined,
"refreshJwt": "alice-refresh-jwt-1",
"service": "https://alice.com/",
Expand Down Expand Up @@ -202,6 +205,7 @@ describe('session', () => {
"emailAuthFactor": false,
"emailConfirmed": false,
"handle": "bob.test",
"isSelfHosted": true,
"pdsUrl": undefined,
"refreshJwt": "bob-refresh-jwt-1",
"service": "https://bob.com/",
Expand All @@ -216,6 +220,7 @@ describe('session', () => {
"emailAuthFactor": false,
"emailConfirmed": false,
"handle": "alice.test",
"isSelfHosted": true,
"pdsUrl": undefined,
"refreshJwt": "alice-refresh-jwt-1",
"service": "https://alice.com/",
Expand Down Expand Up @@ -266,6 +271,7 @@ describe('session', () => {
"emailAuthFactor": false,
"emailConfirmed": false,
"handle": "alice-updated.test",
"isSelfHosted": true,
"pdsUrl": undefined,
"refreshJwt": "alice-refresh-jwt-2",
"service": "https://alice.com/",
Expand All @@ -280,6 +286,7 @@ describe('session', () => {
"emailAuthFactor": false,
"emailConfirmed": false,
"handle": "bob.test",
"isSelfHosted": true,
"pdsUrl": undefined,
"refreshJwt": "bob-refresh-jwt-1",
"service": "https://bob.com/",
Expand Down Expand Up @@ -328,6 +335,7 @@ describe('session', () => {
"emailAuthFactor": false,
"emailConfirmed": false,
"handle": "jay.test",
"isSelfHosted": true,
"pdsUrl": undefined,
"refreshJwt": "jay-refresh-jwt-1",
"service": "https://jay.com/",
Expand All @@ -342,6 +350,7 @@ describe('session', () => {
"emailAuthFactor": false,
"emailConfirmed": false,
"handle": "alice-updated.test",
"isSelfHosted": true,
"pdsUrl": undefined,
"refreshJwt": "alice-refresh-jwt-2",
"service": "https://alice.com/",
Expand All @@ -356,6 +365,7 @@ describe('session', () => {
"emailAuthFactor": false,
"emailConfirmed": false,
"handle": "bob.test",
"isSelfHosted": true,
"pdsUrl": undefined,
"refreshJwt": "bob-refresh-jwt-1",
"service": "https://bob.com/",
Expand Down Expand Up @@ -399,6 +409,7 @@ describe('session', () => {
"emailAuthFactor": false,
"emailConfirmed": false,
"handle": "jay.test",
"isSelfHosted": true,
"pdsUrl": undefined,
"refreshJwt": undefined,
"service": "https://jay.com/",
Expand All @@ -413,6 +424,7 @@ describe('session', () => {
"emailAuthFactor": false,
"emailConfirmed": false,
"handle": "alice-updated.test",
"isSelfHosted": true,
"pdsUrl": undefined,
"refreshJwt": undefined,
"service": "https://alice.com/",
Expand All @@ -427,6 +439,7 @@ describe('session', () => {
"emailAuthFactor": false,
"emailConfirmed": false,
"handle": "bob.test",
"isSelfHosted": true,
"pdsUrl": undefined,
"refreshJwt": undefined,
"service": "https://bob.com/",
Expand Down Expand Up @@ -488,6 +501,7 @@ describe('session', () => {
"emailAuthFactor": false,
"emailConfirmed": false,
"handle": "alice.test",
"isSelfHosted": true,
"pdsUrl": undefined,
"refreshJwt": undefined,
"service": "https://alice.com/",
Expand Down Expand Up @@ -535,6 +549,7 @@ describe('session', () => {
"emailAuthFactor": false,
"emailConfirmed": false,
"handle": "alice.test",
"isSelfHosted": true,
"pdsUrl": undefined,
"refreshJwt": "alice-refresh-jwt-2",
"service": "https://alice.com/",
Expand Down Expand Up @@ -651,6 +666,7 @@ describe('session', () => {
"emailAuthFactor": false,
"emailConfirmed": false,
"handle": "bob.test",
"isSelfHosted": true,
"pdsUrl": undefined,
"refreshJwt": "bob-refresh-jwt-1",
"service": "https://bob.com/",
Expand Down Expand Up @@ -743,6 +759,7 @@ describe('session', () => {
"emailAuthFactor": false,
"emailConfirmed": false,
"handle": "bob.test",
"isSelfHosted": true,
"pdsUrl": undefined,
"refreshJwt": undefined,
"service": "https://bob.com/",
Expand All @@ -757,6 +774,7 @@ describe('session', () => {
"emailAuthFactor": false,
"emailConfirmed": false,
"handle": "alice.test",
"isSelfHosted": true,
"pdsUrl": undefined,
"refreshJwt": "alice-refresh-jwt-1",
"service": "https://alice.com/",
Expand Down Expand Up @@ -832,6 +850,7 @@ describe('session', () => {
"emailAuthFactor": false,
"emailConfirmed": false,
"handle": "alice-updated.test",
"isSelfHosted": true,
"pdsUrl": undefined,
"refreshJwt": "alice-refresh-jwt-2",
"service": "https://alice.com/",
Expand Down Expand Up @@ -885,6 +904,7 @@ describe('session', () => {
"emailAuthFactor": true,
"emailConfirmed": true,
"handle": "alice-updated.test",
"isSelfHosted": true,
"pdsUrl": undefined,
"refreshJwt": "alice-refresh-jwt-3",
"service": "https://alice.com/",
Expand Down Expand Up @@ -938,6 +958,7 @@ describe('session', () => {
"emailAuthFactor": false,
"emailConfirmed": false,
"handle": "alice-updated.test",
"isSelfHosted": true,
"pdsUrl": undefined,
"refreshJwt": "alice-refresh-jwt-4",
"service": "https://alice.com/",
Expand Down Expand Up @@ -1102,6 +1123,7 @@ describe('session', () => {
"emailAuthFactor": false,
"emailConfirmed": false,
"handle": "bob.test",
"isSelfHosted": true,
"pdsUrl": undefined,
"refreshJwt": "bob-refresh-jwt-1",
"service": "https://bob.com/",
Expand All @@ -1116,6 +1138,7 @@ describe('session', () => {
"emailAuthFactor": false,
"emailConfirmed": false,
"handle": "alice-updated.test",
"isSelfHosted": true,
"pdsUrl": undefined,
"refreshJwt": "alice-refresh-jwt-2",
"service": "https://alice.com/",
Expand Down Expand Up @@ -1167,6 +1190,7 @@ describe('session', () => {
"emailAuthFactor": false,
"emailConfirmed": false,
"handle": "bob-updated.test",
"isSelfHosted": true,
"pdsUrl": undefined,
"refreshJwt": "bob-refresh-jwt-2",
"service": "https://bob.com/",
Expand All @@ -1181,6 +1205,7 @@ describe('session', () => {
"emailAuthFactor": false,
"emailConfirmed": false,
"handle": "alice-updated.test",
"isSelfHosted": true,
"pdsUrl": undefined,
"refreshJwt": "alice-refresh-jwt-2",
"service": "https://alice.com/",
Expand Down Expand Up @@ -1332,6 +1357,7 @@ describe('session', () => {
"emailAuthFactor": false,
"emailConfirmed": false,
"handle": "alice.test",
"isSelfHosted": true,
"pdsUrl": undefined,
"refreshJwt": "alice-refresh-jwt-1",
"service": "https://alice.com/",
Expand Down Expand Up @@ -1397,6 +1423,7 @@ describe('session', () => {
"emailAuthFactor": false,
"emailConfirmed": false,
"handle": "alice.test",
"isSelfHosted": true,
"pdsUrl": undefined,
"refreshJwt": undefined,
"service": "https://alice.com/",
Expand Down Expand Up @@ -1462,6 +1489,7 @@ describe('session', () => {
"emailAuthFactor": false,
"emailConfirmed": false,
"handle": "alice.test",
"isSelfHosted": true,
"pdsUrl": undefined,
"refreshJwt": undefined,
"service": "https://alice.com/",
Expand Down Expand Up @@ -1559,6 +1587,7 @@ describe('session', () => {
"emailAuthFactor": false,
"emailConfirmed": false,
"handle": "jay.test",
"isSelfHosted": true,
"pdsUrl": undefined,
"refreshJwt": "jay-refresh-jwt-1",
"service": "https://jay.com/",
Expand All @@ -1573,6 +1602,7 @@ describe('session', () => {
"emailAuthFactor": false,
"emailConfirmed": false,
"handle": "bob.test",
"isSelfHosted": true,
"pdsUrl": undefined,
"refreshJwt": "bob-refresh-jwt-2",
"service": "https://alice.com/",
Expand Down Expand Up @@ -1622,6 +1652,7 @@ describe('session', () => {
"emailAuthFactor": false,
"emailConfirmed": false,
"handle": "clarence.test",
"isSelfHosted": true,
"pdsUrl": undefined,
"refreshJwt": "clarence-refresh-jwt-2",
"service": "https://clarence.com/",
Expand Down
2 changes: 2 additions & 0 deletions src/state/session/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {TID} from '@atproto/common-web'

import {networkRetry} from '#/lib/async/retry'
import {
BSKY_SERVICE,
DISCOVER_SAVED_FEED,
IS_PROD_SERVICE,
PUBLIC_BSKY_SERVICE,
Expand Down Expand Up @@ -204,6 +205,7 @@ export function agentToSessionAccount(
active: agent.session.active,
status: agent.session.status as SessionAccount['status'],
pdsUrl: agent.pdsUrl?.toString(),
isSelfHosted: !agent.serviceUrl.toString().startsWith(BSKY_SERVICE),
}
}

Expand Down

0 comments on commit bc4b4a3

Please sign in to comment.