Skip to content

Commit

Permalink
tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
devinivy committed Dec 21, 2023
1 parent f2edcfd commit a93ae30
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 23 deletions.
50 changes: 28 additions & 22 deletions packages/dev-env/src/mock/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { AtUri } from '@atproto/syntax'
import AtpAgent from '@atproto/api'
import { PrimaryDatabase } from '@atproto/bsky'
import {
REASONSPAM,
REASONOTHER,
Expand Down Expand Up @@ -186,28 +187,16 @@ export async function generateMockSetup(env: TestNetwork) {
},
)

const ctx = env.bsky.ctx
if (ctx) {
const labelSrvc = ctx.services.label(ctx.db.getPrimary())
await labelSrvc.createLabels([
{
src: ctx.cfg.labelerDid,
uri: labeledPost.uri,
cid: labeledPost.cid,
val: 'nudity',
neg: false,
cts: new Date().toISOString(),
},
{
src: ctx.cfg.labelerDid,
uri: filteredPost.uri,
cid: filteredPost.cid,
val: 'dmca-violation',
neg: false,
cts: new Date().toISOString(),
},
])
}
await createLabel(env.bsky.db.getPrimary(), {
uri: labeledPost.uri,
cid: labeledPost.cid,
val: 'nudity',
})
await createLabel(env.bsky.db.getPrimary(), {
uri: filteredPost.uri,
cid: filteredPost.cid,
val: 'dmca-violation',
})

// a set of replies
for (let i = 0; i < 100; i++) {
Expand Down Expand Up @@ -341,3 +330,20 @@ export async function generateMockSetup(env: TestNetwork) {
function ucfirst(str: string): string {
return str.at(0)?.toUpperCase() + str.slice(1)
}

const createLabel = async (
db: PrimaryDatabase,
opts: { uri: string; cid: string; val: string },
) => {
await db.db
.insertInto('label')
.values({
uri: opts.uri,
cid: opts.cid,
val: opts.val,
cts: new Date().toISOString(),
neg: false,
src: 'did:example:labeler',
})
.execute()
}
2 changes: 1 addition & 1 deletion services/bsky/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This is the service entrypoint for the bsky appview. The entrypoint command shou
- `NODE_ENV` - (recommended) for production usage, should be set to `production`. Otherwise all responses are validated on their way out. There may be other effects of not setting this to `production`, as dependencies may also implement debug modes based on its value.
- `BSKY_VERSION` - (recommended) version of the bsky service. This is advertised by the health endpoint.
- `BSKY_PORT` - (recommended) the port that the service will run on.
- `BSKY_IMG_URI_ENDPOINT` - (recommended) the base url for resized images, e.g. `https://https://cdn.bsky.app/img`. When not set, sets-up an image resizing service directly on the appview.
- `BSKY_IMG_URI_ENDPOINT` - (recommended) the base url for resized images, e.g. `https://cdn.bsky.app/img`. When not set, sets-up an image resizing service directly on the appview.
- `BSKY_SERVER_DID` - (recommended) the did of the appview service. When this is a `did:web` that matches the appview's public url, a `did:web` document is served.
- `BSKY_FEED_PUBLISHER_DID` - indicates the publisher did of any feedgen records which the appview supports.
- `BSKY_FEED_GEN_DID` - the did of the appview's feed generator service. When present the appview implements `app.bsky.feed.describeFeedGenerator`.
Expand Down

0 comments on commit a93ae30

Please sign in to comment.