Skip to content

Commit

Permalink
Appview v2 config tidy (#2117)
Browse files Browse the repository at this point in the history
* remove mod and triage roles from appview

* rename cdn and search config

* remove custom feed harness from appview v2
  • Loading branch information
devinivy authored Feb 2, 2024
1 parent 1970529 commit be4dc5a
Show file tree
Hide file tree
Showing 20 changed files with 315 additions and 358 deletions.
21 changes: 0 additions & 21 deletions packages/bsky/src/api/app/bsky/feed/describeFeedGenerator.ts

This file was deleted.

25 changes: 20 additions & 5 deletions packages/bsky/src/api/app/bsky/feed/getFeed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { QueryParams as GetFeedParams } from '../../../../lexicon/types/app/bsky
import { OutputSchema as SkeletonOutput } from '../../../../lexicon/types/app/bsky/feed/getFeedSkeleton'
import { Server } from '../../../../lexicon'
import AppContext from '../../../../context'
import { AlgoResponse, toFeedItem } from '../../../feed-gen/types'
import {
HydrationFnInput,
PresentationFnInput,
Expand Down Expand Up @@ -68,15 +67,12 @@ const skeleton = async (
): Promise<Skeleton> => {
const { ctx, params } = inputs
const timerSkele = new ServerTimer('skele').start()
const localAlgo = ctx.algos[params.feed]
const {
feedItems: algoItems,
cursor,
resHeaders,
...passthrough
} = localAlgo !== undefined
? await localAlgo(ctx, params, params.viewer)
: await skeletonFromFeedGen(ctx, params)
} = await skeletonFromFeedGen(ctx, params)

return {
cursor,
Expand Down Expand Up @@ -229,3 +225,22 @@ const skeletonFromFeedGen = async (

return { ...skele, resHeaders, feedItems }
}

export type AlgoResponse = {
feedItems: AlgoResponseItem[]
resHeaders?: Record<string, string>
cursor?: string
}

export type AlgoResponseItem = {
itemUri: string
postUri: string
}

export const toFeedItem = (feedItem: AlgoResponseItem): FeedItem => ({
post: { uri: feedItem.postUri },
repost:
feedItem.itemUri === feedItem.postUri
? undefined
: { uri: feedItem.itemUri },
})
30 changes: 0 additions & 30 deletions packages/bsky/src/api/app/bsky/feed/getFeedSkeleton.ts

This file was deleted.

29 changes: 0 additions & 29 deletions packages/bsky/src/api/app/bsky/unspecced/getTimelineSkeleton.ts

This file was deleted.

6 changes: 0 additions & 6 deletions packages/bsky/src/api/feed-gen/index.ts

This file was deleted.

45 changes: 0 additions & 45 deletions packages/bsky/src/api/feed-gen/types.ts

This file was deleted.

6 changes: 0 additions & 6 deletions packages/bsky/src/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { Server } from '../lexicon'
import AppContext from '../context'
import describeFeedGenerator from './app/bsky/feed/describeFeedGenerator'
import getTimeline from './app/bsky/feed/getTimeline'
import getActorFeeds from './app/bsky/feed/getActorFeeds'
import getSuggestedFeeds from './app/bsky/feed/getSuggestedFeeds'
import getAuthorFeed from './app/bsky/feed/getAuthorFeed'
import getFeed from './app/bsky/feed/getFeed'
import getFeedGenerator from './app/bsky/feed/getFeedGenerator'
import getFeedGenerators from './app/bsky/feed/getFeedGenerators'
import getFeedSkeleton from './app/bsky/feed/getFeedSkeleton'
import getLikes from './app/bsky/feed/getLikes'
import getListFeed from './app/bsky/feed/getListFeed'
import getPostThread from './app/bsky/feed/getPostThread'
Expand Down Expand Up @@ -40,7 +38,6 @@ import listNotifications from './app/bsky/notification/listNotifications'
import updateSeen from './app/bsky/notification/updateSeen'
import registerPush from './app/bsky/notification/registerPush'
import getPopularFeedGenerators from './app/bsky/unspecced/getPopularFeedGenerators'
import getTimelineSkeleton from './app/bsky/unspecced/getTimelineSkeleton'
import getTaggedSuggestions from './app/bsky/unspecced/getTaggedSuggestions'
import getSubjectStatus from './com/atproto/admin/getSubjectStatus'
import updateSubjectStatus from './com/atproto/admin/updateSubjectStatus'
Expand All @@ -57,15 +54,13 @@ export * as blobResolver from './blob-resolver'

export default function (server: Server, ctx: AppContext) {
// app.bsky
describeFeedGenerator(server, ctx)
getTimeline(server, ctx)
getActorFeeds(server, ctx)
getSuggestedFeeds(server, ctx)
getAuthorFeed(server, ctx)
getFeed(server, ctx)
getFeedGenerator(server, ctx)
getFeedGenerators(server, ctx)
getFeedSkeleton(server, ctx)
getLikes(server, ctx)
getListFeed(server, ctx)
getPostThread(server, ctx)
Expand Down Expand Up @@ -97,7 +92,6 @@ export default function (server: Server, ctx: AppContext) {
updateSeen(server, ctx)
registerPush(server, ctx)
getPopularFeedGenerators(server, ctx)
getTimelineSkeleton(server, ctx)
getTaggedSuggestions(server, ctx)
// com.atproto
getSubjectStatus(server, ctx)
Expand Down
30 changes: 8 additions & 22 deletions packages/bsky/src/auth-verifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ type RoleOutput = {
credentials: {
type: 'role'
admin: boolean
moderator: boolean
triage: boolean
}
}

Expand All @@ -58,24 +56,18 @@ type AdminServiceOutput = {
export type AuthVerifierOpts = {
ownDid: string
adminDid: string
adminPass: string
moderatorPass: string
triagePass: string
adminPasses: string[]
}

export class AuthVerifier {
private _adminPass: string
private _moderatorPass: string
private _triagePass: string
public ownDid: string
public adminDid: string
private adminPasses: Set<string>

constructor(public dataplane: DataPlaneClient, opts: AuthVerifierOpts) {
this._adminPass = opts.adminPass
this._moderatorPass = opts.moderatorPass
this._triagePass = opts.triagePass
this.ownDid = opts.ownDid
this.adminDid = opts.adminDid
this.adminPasses = new Set(opts.adminPasses)
}

// verifiers (arrow fns to preserve scope)
Expand Down Expand Up @@ -180,16 +172,10 @@ export class AuthVerifier {
return { status: Missing, admin: false, moderator: false, triage: false }
}
const { username, password } = parsed
if (username === 'admin' && password === this._adminPass) {
return { status: Valid, admin: true, moderator: true, triage: true }
if (username === 'admin' && this.adminPasses.has(password)) {
return { status: Valid, admin: true }
}
if (username === 'admin' && password === this._moderatorPass) {
return { status: Valid, admin: false, moderator: true, triage: true }
}
if (username === 'admin' && password === this._triagePass) {
return { status: Valid, admin: false, moderator: false, triage: true }
}
return { status: Invalid, admin: false, moderator: false, triage: false }
return { status: Invalid, admin: false }
}

async verifyServiceJwt(
Expand Down Expand Up @@ -243,10 +229,10 @@ export class AuthVerifier {
const viewer =
creds.credentials.type === 'standard' ? creds.credentials.iss : null
const canViewTakedowns =
(creds.credentials.type === 'role' && creds.credentials.triage) ||
(creds.credentials.type === 'role' && creds.credentials.admin) ||
creds.credentials.type === 'admin_service'
const canPerformTakedown =
(creds.credentials.type === 'role' && creds.credentials.moderator) ||
(creds.credentials.type === 'role' && creds.credentials.admin) ||
creds.credentials.type === 'admin_service'
return {
viewer,
Expand Down
Loading

0 comments on commit be4dc5a

Please sign in to comment.