Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/appview-v2-proto-sync1' into app…
Browse files Browse the repository at this point in the history
…view-v2-testing
  • Loading branch information
devinivy committed Jan 23, 2024
2 parents 159e0a9 + d4440e8 commit 8c02e21
Show file tree
Hide file tree
Showing 33 changed files with 1,633 additions and 1,243 deletions.
263 changes: 152 additions & 111 deletions packages/bsky/proto/bsky.proto

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/bsky/src/api/app/bsky/feed/getAuthorFeed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const skeleton = async (inputs: {
}
const actors = await ctx.hydrator.actor.getActors([did])
const actor = actors.get(did)
if (!actor || actor.takendown) {
if (!actor) {
throw new InvalidRequestError('Profile not found')
}
const res = await ctx.dataplane.getAuthorFeed({
Expand Down
3 changes: 2 additions & 1 deletion packages/bsky/src/api/app/bsky/graph/muteActor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export default function (server: Server, ctx: AppContext) {
const viewer = auth.credentials.iss
const [did] = await ctx.hydrator.actor.getDids([actor])
if (!did) throw new InvalidRequestError('Actor not found')
await ctx.dataplane.muteActor({ actorDid: viewer, subjectDid: did })
// @TODO switch to bsync
await ctx.dataplane.createActorMute({ actorDid: viewer, subjectDid: did })
},
})
}
6 changes: 5 additions & 1 deletion packages/bsky/src/api/app/bsky/graph/muteActorList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ export default function (server: Server, ctx: AppContext) {
handler: async ({ auth, input }) => {
const { list } = input.body
const viewer = auth.credentials.iss
await ctx.dataplane.muteActorList({ actorDid: viewer, listUri: list })
// @TODO switch to bsync
await ctx.dataplane.createActorMutelistSubscription({
actorDid: viewer,
subjectUri: list,
})
},
})
}
6 changes: 5 additions & 1 deletion packages/bsky/src/api/app/bsky/graph/unmuteActor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ export default function (server: Server, ctx: AppContext) {
const viewer = auth.credentials.iss
const [did] = await ctx.hydrator.actor.getDids([actor])
if (!did) throw new InvalidRequestError('Actor not found')
await ctx.dataplane.unmuteActor({ actorDid: viewer, subjectDid: actor })
// @TODO switch to bsync
await ctx.dataplane.deleteActorMute({
actorDid: viewer,
subjectDid: actor,
})
},
})
}
5 changes: 4 additions & 1 deletion packages/bsky/src/api/app/bsky/graph/unmuteActorList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ export default function (server: Server, ctx: AppContext) {
handler: async ({ auth, input }) => {
const { list } = input.body
const viewer = auth.credentials.iss
await ctx.dataplane.unmuteActorList({ actorDid: viewer, listUri: list })
await ctx.dataplane.deleteActorMutelistSubscription({
actorDid: viewer,
subjectUri: list,
})
},
})
}
2 changes: 1 addition & 1 deletion packages/bsky/src/api/blob-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export async function resolveBlob(ctx: AppContext, did: string, cid: CID) {

const [{ pds }, { takenDown }] = await Promise.all([
ctx.idResolver.did.resolveAtprotoData(did),
ctx.dataplane.getBlobTakedown({ actorDid: did, cid: cid.toString() }),
ctx.dataplane.getBlobTakedown({ did, cid: cid.toString() }),
])
if (takenDown) {
throw createError(404, 'Blob not found')
Expand Down
12 changes: 6 additions & 6 deletions packages/bsky/src/api/com/atproto/admin/getSubjectStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function (server: Server, ctx: AppContext) {
)
}
const res = await ctx.dataplane.getBlobTakedown({
actorDid: did,
did,
cid: blob,
})
body = {
Expand All @@ -28,7 +28,7 @@ export default function (server: Server, ctx: AppContext) {
},
takedown: {
applied: res.takenDown,
ref: res.takenDown ? 'TAKEDOWN' : undefined,
ref: res.takedownRef ? 'TAKEDOWN' : undefined,
},
}
} else if (uri) {
Expand All @@ -41,8 +41,8 @@ export default function (server: Server, ctx: AppContext) {
cid: res.cid,
},
takedown: {
applied: res.takenDown,
ref: res.takenDown ? 'TAKEDOWN' : undefined,
applied: !!res.takedownRef,
ref: res.takedownRef || undefined,
},
}
}
Expand All @@ -55,8 +55,8 @@ export default function (server: Server, ctx: AppContext) {
did: did,
},
takedown: {
applied: res.takendown,
ref: res.takendown ? 'TAKEDOWN' : undefined,
applied: !!res.takedownRef,
ref: res.takedownRef || undefined,
},
}
}
Expand Down
55 changes: 41 additions & 14 deletions packages/bsky/src/api/com/atproto/admin/updateSubjectStatus.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Timestamp } from '@bufbuild/protobuf'
import { AuthRequiredError, InvalidRequestError } from '@atproto/xrpc-server'
import { Server } from '../../../../lexicon'
import AppContext from '../../../../context'
import {
isRepoRef,
isRepoBlobRef,
} from '../../../../lexicon/types/com/atproto/admin/defs'
import { isMain as isStrongRef } from '../../../../lexicon/types/com/atproto/repo/strongRef'
import { AuthRequiredError, InvalidRequestError } from '@atproto/xrpc-server'

export default function (server: Server, ctx: AppContext) {
server.com.atproto.admin.updateSubjectStatus({
Expand All @@ -17,27 +18,53 @@ export default function (server: Server, ctx: AppContext) {
'Must be a full moderator to update subject state',
)
}
const now = new Date()
const { subject, takedown } = input.body
if (takedown) {
let actorDid: string | undefined = undefined
let recordUri: string | undefined = undefined
let blobCid: string | undefined = undefined
if (isRepoRef(subject)) {
actorDid = subject.did
if (takedown.applied) {
await ctx.dataplane.takedownActor({
did: subject.did,
ref: takedown.ref,
seen: Timestamp.fromDate(now),
})
} else {
await ctx.dataplane.untakedownActor({
did: subject.did,
seen: Timestamp.fromDate(now),
})
}
} else if (isStrongRef(subject)) {
recordUri = subject.uri
if (takedown.applied) {
await ctx.dataplane.takedownRecord({
recordUri: subject.uri,
ref: takedown.ref,
seen: Timestamp.fromDate(now),
})
} else {
await ctx.dataplane.untakedownRecord({
recordUri: subject.uri,
seen: Timestamp.fromDate(now),
})
}
} else if (isRepoBlobRef(subject)) {
actorDid = subject.did
blobCid = subject.cid
if (takedown.applied) {
await ctx.dataplane.takedownBlob({
did: subject.did,
cid: subject.cid,
ref: takedown.ref,
seen: Timestamp.fromDate(now),
})
} else {
await ctx.dataplane.untakedownBlob({
did: subject.did,
cid: subject.cid,
seen: Timestamp.fromDate(now),
})
}
} else {
throw new InvalidRequestError('Invalid subject')
}
await ctx.dataplane.updateTakedown({
actorDid,
recordUri,
blobCid,
takenDown: takedown?.applied,
})
}

return {
Expand Down
Loading

0 comments on commit 8c02e21

Please sign in to comment.