Run codemod for replacing BskyAgent with AtpAgent (#10862)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
type $Typed,
|
||||
type AppBskyEmbedRecord,
|
||||
type BskyAgent,
|
||||
type AtpAgent,
|
||||
type ChatBskyActorDefs,
|
||||
type ChatBskyConvoDefs,
|
||||
type ChatBskyConvoSendMessage,
|
||||
@@ -13,7 +13,7 @@ import {type ConvoWithDetails} from '#/components/dms/util'
|
||||
|
||||
export type ConvoParams = {
|
||||
convoId: string
|
||||
agent: BskyAgent
|
||||
agent: AtpAgent
|
||||
events: MessagesEventBus
|
||||
placeholderData?: {
|
||||
convo: ChatBskyConvoDefs.ConvoView
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {type BskyAgent, type ChatBskyConvoGetLog} from '@atproto/api'
|
||||
import {type AtpAgent, type ChatBskyConvoGetLog} from '@atproto/api'
|
||||
import {EventEmitter} from 'eventemitter3'
|
||||
import {nanoid} from 'nanoid/non-secure'
|
||||
|
||||
@@ -27,7 +27,7 @@ const logger = Logger.create(Logger.Context.DMsAgent)
|
||||
export class MessagesEventBus {
|
||||
private id: string
|
||||
|
||||
private agent: BskyAgent
|
||||
private agent: AtpAgent
|
||||
private emitter = new EventEmitter<{event: [MessagesEventBusEvent]}>()
|
||||
|
||||
private status: MessagesEventBusStatus = MessagesEventBusStatus.Initializing
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {type BskyAgent, type ChatBskyConvoGetLog} from '@atproto/api'
|
||||
import {type AtpAgent, type ChatBskyConvoGetLog} from '@atproto/api'
|
||||
|
||||
export type MessagesEventBusParams = {
|
||||
agent: BskyAgent
|
||||
agent: AtpAgent
|
||||
}
|
||||
|
||||
export enum MessagesEventBusStatus {
|
||||
|
||||
@@ -2,7 +2,7 @@ import {
|
||||
type AppBskyActorDefs,
|
||||
type AppBskyGraphDefs,
|
||||
type AppBskyGraphGetList,
|
||||
type BskyAgent,
|
||||
type AtpAgent,
|
||||
} from '@atproto/api'
|
||||
import {
|
||||
type InfiniteData,
|
||||
@@ -60,7 +60,7 @@ export function useAllListMembersQuery(uri?: string) {
|
||||
})
|
||||
}
|
||||
|
||||
export async function getAllListMembers(agent: BskyAgent, uri: string) {
|
||||
export async function getAllListMembers(agent: AtpAgent, uri: string) {
|
||||
let hasMore = true
|
||||
let cursor: string | undefined
|
||||
const listItems: AppBskyGraphDefs.ListItemView[] = []
|
||||
|
||||
@@ -3,8 +3,8 @@ import {
|
||||
type AppBskyGraphDefs,
|
||||
type AppBskyGraphGetList,
|
||||
type AppBskyGraphList,
|
||||
type AtpAgent,
|
||||
AtUri,
|
||||
type BskyAgent,
|
||||
type ComAtprotoRepoApplyWrites,
|
||||
type Facet,
|
||||
type Un$Typed,
|
||||
@@ -305,7 +305,7 @@ export function useListBlockMutation() {
|
||||
}
|
||||
|
||||
async function whenAppViewReady(
|
||||
agent: BskyAgent,
|
||||
agent: AtpAgent,
|
||||
uri: string,
|
||||
fn: (res: AppBskyGraphGetList.Response) => boolean,
|
||||
) {
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
type AppBskyGraphDefs,
|
||||
AppBskyGraphStarterpack,
|
||||
type AppBskyNotificationListNotifications,
|
||||
type BskyAgent,
|
||||
type AtpAgent,
|
||||
hasMutedWord,
|
||||
moderateNotification,
|
||||
type ModerationOpts,
|
||||
@@ -46,7 +46,7 @@ export async function fetchPage({
|
||||
fetchAdditionalData,
|
||||
reasons,
|
||||
}: {
|
||||
agent: BskyAgent
|
||||
agent: AtpAgent
|
||||
cursor: string | undefined
|
||||
limit: number
|
||||
queryClient: QueryClient
|
||||
@@ -204,7 +204,7 @@ export function groupNotifications(
|
||||
}
|
||||
|
||||
async function fetchSubjects(
|
||||
agent: BskyAgent,
|
||||
agent: AtpAgent,
|
||||
groupedNotifs: FeedNotification[],
|
||||
): Promise<{
|
||||
posts: Map<string, AppBskyFeedDefs.PostView>
|
||||
|
||||
@@ -4,8 +4,8 @@ import {
|
||||
type AppBskyActorDefs,
|
||||
AppBskyFeedDefs,
|
||||
type AppBskyFeedPost,
|
||||
type AtpAgent,
|
||||
AtUri,
|
||||
type BskyAgent,
|
||||
moderatePost,
|
||||
type ModerationDecision,
|
||||
type ModerationPrefs,
|
||||
@@ -450,7 +450,7 @@ function createApi({
|
||||
feedParams: FeedParams
|
||||
feedTuners: FeedTunerFn[]
|
||||
userInterests?: string
|
||||
agent: BskyAgent
|
||||
agent: AtpAgent
|
||||
enableFollowingToDiscoverFallback: boolean
|
||||
}) {
|
||||
if (feedDesc === 'following') {
|
||||
|
||||
@@ -4,8 +4,8 @@ import {
|
||||
AppBskyEmbedRecordWithMedia,
|
||||
type AppBskyFeedDefs,
|
||||
AppBskyFeedPostgate,
|
||||
type AtpAgent,
|
||||
AtUri,
|
||||
type BskyAgent,
|
||||
} from '@atproto/api'
|
||||
import {useMutation, useQuery, useQueryClient} from '@tanstack/react-query'
|
||||
|
||||
@@ -27,7 +27,7 @@ export async function getPostgateRecord({
|
||||
agent,
|
||||
postUri,
|
||||
}: {
|
||||
agent: BskyAgent
|
||||
agent: AtpAgent
|
||||
postUri: string
|
||||
}): Promise<AppBskyFeedPostgate.Record | undefined> {
|
||||
const urip = new AtUri(postUri)
|
||||
@@ -89,7 +89,7 @@ export async function writePostgateRecord({
|
||||
postUri,
|
||||
postgate,
|
||||
}: {
|
||||
agent: BskyAgent
|
||||
agent: AtpAgent
|
||||
postUri: string
|
||||
postgate: AppBskyFeedPostgate.Record
|
||||
}) {
|
||||
@@ -110,7 +110,7 @@ export async function upsertPostgate(
|
||||
agent,
|
||||
postUri,
|
||||
}: {
|
||||
agent: BskyAgent
|
||||
agent: AtpAgent
|
||||
postUri: string
|
||||
},
|
||||
callback: (
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {useMemo} from 'react'
|
||||
import {BskyAgent, interpretLabelValueDefinitions} from '@atproto/api'
|
||||
import {AtpAgent, interpretLabelValueDefinitions} from '@atproto/api'
|
||||
|
||||
import {isNonConfigurableModerationAuthority} from '#/state/session/additional-moderation-authorities'
|
||||
import {useLabelersDetailedInfoQuery} from '../labeler'
|
||||
@@ -13,7 +13,7 @@ export function useMyLabelersQuery({
|
||||
const prefs = usePreferencesQuery()
|
||||
let dids = Array.from(
|
||||
new Set(
|
||||
BskyAgent.appLabelers.concat(
|
||||
AtpAgent.appLabelers.concat(
|
||||
prefs.data?.moderationPrefs.labelers.map(l => l.did) || [],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {AtUri, type BskyAgent} from '@atproto/api'
|
||||
import {type AtpAgent, AtUri} from '@atproto/api'
|
||||
import {type QueryClient, queryOptions, useQuery} from '@tanstack/react-query'
|
||||
|
||||
import {STALE} from '#/state/queries'
|
||||
@@ -9,7 +9,7 @@ const RQKEY_ROOT = 'resolved-did'
|
||||
export const RQKEY = (didOrHandle: string) => [RQKEY_ROOT, didOrHandle]
|
||||
|
||||
const resolvedDidQueryOptions = (
|
||||
agent: BskyAgent,
|
||||
agent: AtpAgent,
|
||||
getUnstableProfile: (did: string) => {did: string} | undefined,
|
||||
didOrHandle: string | undefined,
|
||||
) =>
|
||||
|
||||
@@ -4,8 +4,8 @@ import {
|
||||
type AppBskyGraphGetStarterPack,
|
||||
AppBskyGraphStarterpack,
|
||||
type AppBskyRichtextFacet,
|
||||
type AtpAgent,
|
||||
AtUri,
|
||||
type BskyAgent,
|
||||
RichText,
|
||||
} from '@atproto/api'
|
||||
import {
|
||||
@@ -340,7 +340,7 @@ export function useDeleteStarterPackMutation({
|
||||
}
|
||||
|
||||
async function whenAppViewReady(
|
||||
agent: BskyAgent,
|
||||
agent: AtpAgent,
|
||||
uri: string,
|
||||
fn: (res?: AppBskyGraphGetStarterPack.Response) => boolean,
|
||||
) {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import {
|
||||
type AppBskyFeedDefs,
|
||||
AppBskyFeedThreadgate,
|
||||
type AtpAgent,
|
||||
AtUri,
|
||||
type BskyAgent,
|
||||
} from '@atproto/api'
|
||||
import {useMutation, useQuery, useQueryClient} from '@tanstack/react-query'
|
||||
|
||||
@@ -88,7 +88,7 @@ export async function getThreadgateRecord({
|
||||
agent,
|
||||
postUri,
|
||||
}: {
|
||||
agent: BskyAgent
|
||||
agent: AtpAgent
|
||||
postUri: string
|
||||
}): Promise<AppBskyFeedThreadgate.Record | null> {
|
||||
const urip = new AtUri(postUri)
|
||||
@@ -150,7 +150,7 @@ export async function writeThreadgateRecord({
|
||||
postUri,
|
||||
threadgate,
|
||||
}: {
|
||||
agent: BskyAgent
|
||||
agent: AtpAgent
|
||||
postUri: string
|
||||
threadgate: AppBskyFeedThreadgate.Record
|
||||
}) {
|
||||
@@ -176,7 +176,7 @@ export async function upsertThreadgate(
|
||||
agent,
|
||||
postUri,
|
||||
}: {
|
||||
agent: BskyAgent
|
||||
agent: AtpAgent
|
||||
postUri: string
|
||||
},
|
||||
callback: (
|
||||
@@ -205,7 +205,7 @@ export async function updateThreadgateAllow({
|
||||
postUri,
|
||||
allow,
|
||||
}: {
|
||||
agent: BskyAgent
|
||||
agent: AtpAgent
|
||||
postUri: string
|
||||
allow: ThreadgateAllowUISetting[]
|
||||
}) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {BskyAgent} from '@atproto/api'
|
||||
import {AtpAgent} from '@atproto/api'
|
||||
import {describe, expect, it, jest} from '@jest/globals'
|
||||
|
||||
import {agentToSessionAccountOrThrow} from '../agent'
|
||||
@@ -16,7 +16,7 @@ jest.mock('../../../ageAssurance/state', () => ({
|
||||
unsafeGetAndComputeAgeAssurance: () => ({state: {}}),
|
||||
}))
|
||||
jest.mock('#/lib/notifications/notifications', () => ({
|
||||
unregisterPushToken(_agents: BskyAgent[]) {
|
||||
unregisterPushToken(_agents: AtpAgent[]) {
|
||||
return Promise.resolve()
|
||||
},
|
||||
}))
|
||||
@@ -37,7 +37,7 @@ describe('session', () => {
|
||||
}
|
||||
`)
|
||||
|
||||
const agent = new BskyAgent({service: 'https://alice.com'})
|
||||
const agent = new AtpAgent({service: 'https://alice.com'})
|
||||
agent.sessionManager.session = {
|
||||
active: true,
|
||||
did: 'alice-did',
|
||||
@@ -130,7 +130,7 @@ describe('session', () => {
|
||||
it('switches to the latest account, stores all of them', () => {
|
||||
let state = getInitialState([])
|
||||
|
||||
const agent1 = new BskyAgent({service: 'https://alice.com'})
|
||||
const agent1 = new AtpAgent({service: 'https://alice.com'})
|
||||
agent1.sessionManager.session = {
|
||||
active: true,
|
||||
did: 'alice-did',
|
||||
@@ -179,7 +179,7 @@ describe('session', () => {
|
||||
}
|
||||
`)
|
||||
|
||||
const agent2 = new BskyAgent({service: 'https://bob.com'})
|
||||
const agent2 = new AtpAgent({service: 'https://bob.com'})
|
||||
agent2.sessionManager.session = {
|
||||
active: true,
|
||||
did: 'bob-did',
|
||||
@@ -245,7 +245,7 @@ describe('session', () => {
|
||||
}
|
||||
`)
|
||||
|
||||
const agent3 = new BskyAgent({service: 'https://alice.com'})
|
||||
const agent3 = new AtpAgent({service: 'https://alice.com'})
|
||||
agent3.sessionManager.session = {
|
||||
active: true,
|
||||
did: 'alice-did',
|
||||
@@ -311,7 +311,7 @@ describe('session', () => {
|
||||
}
|
||||
`)
|
||||
|
||||
const agent4 = new BskyAgent({service: 'https://jay.com'})
|
||||
const agent4 = new AtpAgent({service: 'https://jay.com'})
|
||||
agent4.sessionManager.session = {
|
||||
active: true,
|
||||
did: 'jay-did',
|
||||
@@ -468,7 +468,7 @@ describe('session', () => {
|
||||
it('can log back in after logging out', () => {
|
||||
let state = getInitialState([])
|
||||
|
||||
const agent1 = new BskyAgent({service: 'https://alice.com'})
|
||||
const agent1 = new AtpAgent({service: 'https://alice.com'})
|
||||
agent1.sessionManager.session = {
|
||||
active: true,
|
||||
did: 'alice-did',
|
||||
@@ -526,7 +526,7 @@ describe('session', () => {
|
||||
}
|
||||
`)
|
||||
|
||||
const agent2 = new BskyAgent({service: 'https://alice.com'})
|
||||
const agent2 = new AtpAgent({service: 'https://alice.com'})
|
||||
agent2.sessionManager.session = {
|
||||
active: true,
|
||||
did: 'alice-did',
|
||||
@@ -578,7 +578,7 @@ describe('session', () => {
|
||||
it('can remove active account', () => {
|
||||
let state = getInitialState([])
|
||||
|
||||
const agent1 = new BskyAgent({service: 'https://alice.com'})
|
||||
const agent1 = new AtpAgent({service: 'https://alice.com'})
|
||||
agent1.sessionManager.session = {
|
||||
active: true,
|
||||
did: 'alice-did',
|
||||
@@ -623,7 +623,7 @@ describe('session', () => {
|
||||
it('can remove inactive account', () => {
|
||||
let state = getInitialState([])
|
||||
|
||||
const agent1 = new BskyAgent({service: 'https://alice.com'})
|
||||
const agent1 = new AtpAgent({service: 'https://alice.com'})
|
||||
agent1.sessionManager.session = {
|
||||
active: true,
|
||||
did: 'alice-did',
|
||||
@@ -631,7 +631,7 @@ describe('session', () => {
|
||||
accessJwt: 'alice-access-jwt-1',
|
||||
refreshJwt: 'alice-refresh-jwt-1',
|
||||
}
|
||||
const agent2 = new BskyAgent({service: 'https://bob.com'})
|
||||
const agent2 = new AtpAgent({service: 'https://bob.com'})
|
||||
agent2.sessionManager.session = {
|
||||
active: true,
|
||||
did: 'bob-did',
|
||||
@@ -704,7 +704,7 @@ describe('session', () => {
|
||||
it('can log out of the current account', () => {
|
||||
let state = getInitialState([])
|
||||
|
||||
const agent1 = new BskyAgent({service: 'https://alice.com'})
|
||||
const agent1 = new AtpAgent({service: 'https://alice.com'})
|
||||
agent1.sessionManager.session = {
|
||||
active: true,
|
||||
did: 'alice-did',
|
||||
@@ -724,7 +724,7 @@ describe('session', () => {
|
||||
expect(state.accounts[0].refreshJwt).toBe('alice-refresh-jwt-1')
|
||||
expect(state.currentAgentState.did).toBe('alice-did')
|
||||
|
||||
const agent2 = new BskyAgent({service: 'https://bob.com'})
|
||||
const agent2 = new AtpAgent({service: 'https://bob.com'})
|
||||
agent2.sessionManager.session = {
|
||||
active: true,
|
||||
did: 'bob-did',
|
||||
@@ -803,7 +803,7 @@ describe('session', () => {
|
||||
it('updates stored account with refreshed tokens', () => {
|
||||
let state = getInitialState([])
|
||||
|
||||
const agent1 = new BskyAgent({service: 'https://alice.com'})
|
||||
const agent1 = new AtpAgent({service: 'https://alice.com'})
|
||||
agent1.sessionManager.session = {
|
||||
active: true,
|
||||
did: 'alice-did',
|
||||
@@ -987,7 +987,7 @@ describe('session', () => {
|
||||
it('bails out of update on identical objects', () => {
|
||||
let state = getInitialState([])
|
||||
|
||||
const agent1 = new BskyAgent({service: 'https://alice.com'})
|
||||
const agent1 = new AtpAgent({service: 'https://alice.com'})
|
||||
agent1.sessionManager.session = {
|
||||
active: true,
|
||||
did: 'alice-did',
|
||||
@@ -1059,7 +1059,7 @@ describe('session', () => {
|
||||
it('accepts updates from a stale agent', () => {
|
||||
let state = getInitialState([])
|
||||
|
||||
const agent1 = new BskyAgent({service: 'https://alice.com'})
|
||||
const agent1 = new AtpAgent({service: 'https://alice.com'})
|
||||
agent1.sessionManager.session = {
|
||||
active: true,
|
||||
did: 'alice-did',
|
||||
@@ -1068,7 +1068,7 @@ describe('session', () => {
|
||||
refreshJwt: 'alice-refresh-jwt-1',
|
||||
}
|
||||
|
||||
const agent2 = new BskyAgent({service: 'https://bob.com'})
|
||||
const agent2 = new AtpAgent({service: 'https://bob.com'})
|
||||
agent2.sessionManager.session = {
|
||||
active: true,
|
||||
did: 'bob-did',
|
||||
@@ -1258,7 +1258,7 @@ describe('session', () => {
|
||||
it('ignores updates from a removed agent', () => {
|
||||
let state = getInitialState([])
|
||||
|
||||
const agent1 = new BskyAgent({service: 'https://alice.com'})
|
||||
const agent1 = new AtpAgent({service: 'https://alice.com'})
|
||||
agent1.sessionManager.session = {
|
||||
active: true,
|
||||
did: 'alice-did',
|
||||
@@ -1267,7 +1267,7 @@ describe('session', () => {
|
||||
refreshJwt: 'alice-refresh-jwt-1',
|
||||
}
|
||||
|
||||
const agent2 = new BskyAgent({service: 'https://bob.com'})
|
||||
const agent2 = new AtpAgent({service: 'https://bob.com'})
|
||||
agent2.sessionManager.session = {
|
||||
active: true,
|
||||
did: 'bob-did',
|
||||
@@ -1320,7 +1320,7 @@ describe('session', () => {
|
||||
it('ignores network errors', () => {
|
||||
let state = getInitialState([])
|
||||
|
||||
const agent1 = new BskyAgent({service: 'https://alice.com'})
|
||||
const agent1 = new AtpAgent({service: 'https://alice.com'})
|
||||
agent1.sessionManager.session = {
|
||||
active: true,
|
||||
did: 'alice-did',
|
||||
@@ -1386,7 +1386,7 @@ describe('session', () => {
|
||||
it('resets tokens on expired event', () => {
|
||||
let state = getInitialState([])
|
||||
|
||||
const agent1 = new BskyAgent({service: 'https://alice.com'})
|
||||
const agent1 = new AtpAgent({service: 'https://alice.com'})
|
||||
agent1.sessionManager.session = {
|
||||
active: true,
|
||||
did: 'alice-did',
|
||||
@@ -1452,7 +1452,7 @@ describe('session', () => {
|
||||
it('resets tokens on created-failed event', () => {
|
||||
let state = getInitialState([])
|
||||
|
||||
const agent1 = new BskyAgent({service: 'https://alice.com'})
|
||||
const agent1 = new AtpAgent({service: 'https://alice.com'})
|
||||
agent1.sessionManager.session = {
|
||||
active: true,
|
||||
did: 'alice-did',
|
||||
@@ -1518,7 +1518,7 @@ describe('session', () => {
|
||||
it('replaces local accounts with synced accounts', () => {
|
||||
let state = getInitialState([])
|
||||
|
||||
const agent1 = new BskyAgent({service: 'https://alice.com'})
|
||||
const agent1 = new AtpAgent({service: 'https://alice.com'})
|
||||
agent1.sessionManager.session = {
|
||||
active: true,
|
||||
did: 'alice-did',
|
||||
@@ -1526,7 +1526,7 @@ describe('session', () => {
|
||||
accessJwt: 'alice-access-jwt-1',
|
||||
refreshJwt: 'alice-refresh-jwt-1',
|
||||
}
|
||||
const agent2 = new BskyAgent({service: 'https://bob.com'})
|
||||
const agent2 = new AtpAgent({service: 'https://bob.com'})
|
||||
agent2.sessionManager.session = {
|
||||
active: true,
|
||||
did: 'bob-did',
|
||||
@@ -1549,7 +1549,7 @@ describe('session', () => {
|
||||
expect(state.accounts.length).toBe(2)
|
||||
expect(state.currentAgentState.did).toBe('bob-did')
|
||||
|
||||
const anotherTabAgent1 = new BskyAgent({service: 'https://jay.com'})
|
||||
const anotherTabAgent1 = new AtpAgent({service: 'https://jay.com'})
|
||||
anotherTabAgent1.sessionManager.session = {
|
||||
active: true,
|
||||
did: 'jay-did',
|
||||
@@ -1557,7 +1557,7 @@ describe('session', () => {
|
||||
accessJwt: 'jay-access-jwt-1',
|
||||
refreshJwt: 'jay-refresh-jwt-1',
|
||||
}
|
||||
const anotherTabAgent2 = new BskyAgent({service: 'https://alice.com'})
|
||||
const anotherTabAgent2 = new AtpAgent({service: 'https://alice.com'})
|
||||
anotherTabAgent2.sessionManager.session = {
|
||||
active: true,
|
||||
did: 'bob-did',
|
||||
@@ -1627,7 +1627,7 @@ describe('session', () => {
|
||||
}
|
||||
`)
|
||||
|
||||
const anotherTabAgent3 = new BskyAgent({service: 'https://clarence.com'})
|
||||
const anotherTabAgent3 = new AtpAgent({service: 'https://clarence.com'})
|
||||
anotherTabAgent3.sessionManager.session = {
|
||||
active: true,
|
||||
did: 'clarence-did',
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {BskyAgent} from '@atproto/api'
|
||||
import {AtpAgent} from '@atproto/api'
|
||||
|
||||
import {device} from '#/storage'
|
||||
|
||||
@@ -83,8 +83,8 @@ export function configureAdditionalModerationAuthorities() {
|
||||
}
|
||||
|
||||
const appLabelers = Array.from(
|
||||
new Set([...BskyAgent.appLabelers, ...additionalLabelers]),
|
||||
new Set([...AtpAgent.appLabelers, ...additionalLabelers]),
|
||||
)
|
||||
|
||||
BskyAgent.configure({appLabelers})
|
||||
AtpAgent.configure({appLabelers})
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import {
|
||||
Agent as BaseAgent,
|
||||
type AppBskyActorProfile,
|
||||
AtpAgent,
|
||||
type AtprotoServiceType,
|
||||
type AtpSessionData,
|
||||
type AtpSessionEvent,
|
||||
BskyAgent,
|
||||
type Did,
|
||||
type Un$Typed,
|
||||
} from '@atproto/api'
|
||||
@@ -52,7 +52,7 @@ export function createPublicAgent() {
|
||||
export async function createAgentAndResume(
|
||||
storedAccount: SessionAccount,
|
||||
onSessionChange: (
|
||||
agent: BskyAgent,
|
||||
agent: AtpAgent,
|
||||
did: string,
|
||||
event: AtpSessionEvent,
|
||||
) => void,
|
||||
@@ -96,7 +96,7 @@ export async function createAgentAndLogin(
|
||||
authFactorToken?: string
|
||||
},
|
||||
onSessionChange: (
|
||||
agent: BskyAgent,
|
||||
agent: AtpAgent,
|
||||
did: string,
|
||||
event: AtpSessionEvent,
|
||||
) => void,
|
||||
@@ -143,7 +143,7 @@ export async function createAgentAndCreateAccount(
|
||||
verificationCode?: string
|
||||
},
|
||||
onSessionChange: (
|
||||
agent: BskyAgent,
|
||||
agent: AtpAgent,
|
||||
did: string,
|
||||
event: AtpSessionEvent,
|
||||
) => void,
|
||||
@@ -282,7 +282,7 @@ export async function createAgentAndCreateAccount(
|
||||
})
|
||||
}
|
||||
|
||||
export function agentToSessionAccountOrThrow(agent: BskyAgent): SessionAccount {
|
||||
export function agentToSessionAccountOrThrow(agent: AtpAgent): SessionAccount {
|
||||
const account = agentToSessionAccount(agent)
|
||||
if (!account) {
|
||||
throw Error('Expected an active session')
|
||||
@@ -291,7 +291,7 @@ export function agentToSessionAccountOrThrow(agent: BskyAgent): SessionAccount {
|
||||
}
|
||||
|
||||
export function agentToSessionAccount(
|
||||
agent: BskyAgent,
|
||||
agent: AtpAgent,
|
||||
): SessionAccount | undefined {
|
||||
if (!agent.session) {
|
||||
return undefined
|
||||
@@ -350,7 +350,7 @@ export class Agent extends BaseAgent {
|
||||
// Ideally, we wouldn't be doing this. However, since there is so much logic that requires making calls to the PDS right now, it
|
||||
// feels safer to just let those run as-is and set the header afterward.
|
||||
let realFetch = globalThis.fetch
|
||||
class BskyAppAgent extends BskyAgent {
|
||||
class BskyAppAgent extends AtpAgent {
|
||||
persistSessionHandler: ((event: AtpSessionEvent) => void) | undefined =
|
||||
undefined
|
||||
|
||||
@@ -389,7 +389,7 @@ class BskyAppAgent extends BskyAgent {
|
||||
// Not awaited in the calling code so we can delay blocking on them.
|
||||
resolvers: Promise<unknown>[]
|
||||
onSessionChange: (
|
||||
agent: BskyAgent,
|
||||
agent: AtpAgent,
|
||||
did: string,
|
||||
event: AtpSessionEvent,
|
||||
) => void
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {BSKY_LABELER_DID, BskyAgent} from '@atproto/api'
|
||||
import {AtpAgent, BSKY_LABELER_DID} from '@atproto/api'
|
||||
|
||||
import {IS_TEST_USER} from '#/lib/constants'
|
||||
import {configureAdditionalModerationAuthorities} from './additional-moderation-authorities'
|
||||
@@ -13,7 +13,7 @@ export function configureModerationForGuest() {
|
||||
}
|
||||
|
||||
export async function configureModerationForAccount(
|
||||
agent: BskyAgent,
|
||||
agent: AtpAgent,
|
||||
account: SessionAccount,
|
||||
) {
|
||||
// This global mutation is *only* OK because this code is only relevant for testing.
|
||||
@@ -38,10 +38,10 @@ export async function configureModerationForAccount(
|
||||
}
|
||||
|
||||
function switchToBskyAppLabeler() {
|
||||
BskyAgent.configure({appLabelers: [BSKY_LABELER_DID]})
|
||||
AtpAgent.configure({appLabelers: [BSKY_LABELER_DID]})
|
||||
}
|
||||
|
||||
async function trySwitchToTestAppLabeler(agent: BskyAgent) {
|
||||
async function trySwitchToTestAppLabeler(agent: AtpAgent) {
|
||||
const did = (
|
||||
await agent
|
||||
.resolveHandle({handle: 'mod-authority.test'})
|
||||
@@ -49,6 +49,6 @@ async function trySwitchToTestAppLabeler(agent: BskyAgent) {
|
||||
)?.data.did
|
||||
if (did) {
|
||||
console.warn('USING TEST ENV MODERATION')
|
||||
BskyAgent.configure({appLabelers: [did]})
|
||||
AtpAgent.configure({appLabelers: [did]})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user