Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into msi/drop-axios
Browse files Browse the repository at this point in the history
  • Loading branch information
matthieusieben committed Jan 6, 2025
2 parents 2ddfc5c + 3365bf8 commit bb64dff
Show file tree
Hide file tree
Showing 42 changed files with 285 additions and 36 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
**/dist
.DS_Store
Dockerfile
6 changes: 3 additions & 3 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
pull-requests: write
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v3
- run: corepack enable && corepack prepare --activate
- uses: actions/setup-node@v4
with:
node-version: 18
node-version-file: package.json
cache: 'pnpm'
- run: pnpm i --frozen-lockfile
- run: pnpm build
Expand Down
21 changes: 6 additions & 15 deletions .github/workflows/repo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
run_install: false
- run: corepack enable && corepack prepare --activate
- uses: actions/setup-node@v4
with:
node-version: 18
node-version-file: package.json
cache: 'pnpm'
- name: Get current month
run: echo "CURRENT_MONTH=$(date +'%Y-%m')" >> $GITHUB_ENV
Expand All @@ -48,13 +45,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
run_install: false
- run: corepack enable && corepack prepare --activate
- uses: actions/setup-node@v4
with:
node-version: 18
node-version-file: package.json
cache: 'pnpm'
- name: Get current month
run: echo "CURRENT_MONTH=$(date +'%Y-%m')" >> $GITHUB_ENV
Expand All @@ -75,13 +69,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
run_install: false
- run: corepack enable && corepack prepare --activate
- uses: actions/setup-node@v4
with:
node-version: 18
node-version-file: package.json
cache: 'pnpm'
- name: Get current month
run: echo "CURRENT_MONTH=$(date +'%Y-%m')" >> $GITHUB_ENV
Expand Down
6 changes: 6 additions & 0 deletions lexicons/tools/ozone/moderation/defs.json
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,12 @@
"acknowledgeAccountSubjects": {
"type": "boolean",
"description": "If true, all other reports on content authored by this account will be resolved (acknowledged)."
},
"policies": {
"type": "array",
"maxLength": 5,
"items": { "type": "string" },
"description": "Names/Keywords of the policies that drove the decision."
}
}
},
Expand Down
7 changes: 7 additions & 0 deletions lexicons/tools/ozone/moderation/queryEvents.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@
"type": "string"
}
},
"policies": {
"type": "array",
"items": {
"type": "string",
"description": "If specified, only events where the action policies match any of the given policies are returned"
}
},
"cursor": {
"type": "string"
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"license": "MIT",
"private": true,
"engines": {
"node": ">=18"
"node": "18"
},
"packageManager": "[email protected]",
"scripts": {
Expand Down
6 changes: 6 additions & 0 deletions packages/api/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @atproto/api

## 0.13.25

### Patch Changes

- [#3271](https://github.com/bluesky-social/atproto/pull/3271) [`53621f8e1`](https://github.com/bluesky-social/atproto/commit/53621f8e100a3aa3c1caff10a08d3f4ea919875a) Thanks [@foysalit](https://github.com/foysalit)! - Allow setting policy names with takedown actions and when querying events

## 0.13.24

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@atproto/api",
"version": "0.13.24",
"version": "0.13.25",
"license": "MIT",
"description": "Client library for atproto and Bluesky",
"keywords": [
Expand Down
17 changes: 17 additions & 0 deletions packages/api/src/client/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11309,6 +11309,15 @@ export const schemaDict = {
description:
'If true, all other reports on content authored by this account will be resolved (acknowledged).',
},
policies: {
type: 'array',
maxLength: 5,
items: {
type: 'string',
},
description:
'Names/Keywords of the policies that drove the decision.',
},
},
},
modEventReverseTakedown: {
Expand Down Expand Up @@ -12345,6 +12354,14 @@ export const schemaDict = {
type: 'string',
},
},
policies: {
type: 'array',
items: {
type: 'string',
description:
'If specified, only events where the policy matches the given policy are returned',
},
},
cursor: {
type: 'string',
},
Expand Down
2 changes: 2 additions & 0 deletions packages/api/src/client/types/tools/ozone/moderation/defs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ export interface ModEventTakedown {
durationInHours?: number
/** If true, all other reports on content authored by this account will be resolved (acknowledged). */
acknowledgeAccountSubjects?: boolean
/** Names/Keywords of the policies that drove the decision. */
policies?: string[]
[k: string]: unknown
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export interface QueryParams {
/** If specified, only events where all of these tags were removed are returned */
removedTags?: string[]
reportTypes?: string[]
policies?: string[]
cursor?: string
}

Expand Down
7 changes: 7 additions & 0 deletions packages/bsky/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @atproto/bsky

## 0.0.103

### Patch Changes

- Updated dependencies [[`53621f8e1`](https://github.com/bluesky-social/atproto/commit/53621f8e100a3aa3c1caff10a08d3f4ea919875a)]:
- @atproto/api@0.13.25

## 0.0.102

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/bsky/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@atproto/bsky",
"version": "0.0.102",
"version": "0.0.103",
"license": "MIT",
"description": "Reference implementation of app.bsky App View (Bluesky API)",
"keywords": [
Expand Down
12 changes: 12 additions & 0 deletions packages/dev-env/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# @atproto/dev-env

## 0.3.73

### Patch Changes

- [#3271](https://github.com/bluesky-social/atproto/pull/3271) [`53621f8e1`](https://github.com/bluesky-social/atproto/commit/53621f8e100a3aa3c1caff10a08d3f4ea919875a) Thanks [@foysalit](https://github.com/foysalit)! - Allow setting policy names with takedown actions and when querying events

- Updated dependencies [[`53621f8e1`](https://github.com/bluesky-social/atproto/commit/53621f8e100a3aa3c1caff10a08d3f4ea919875a)]:
- @atproto/ozone@0.1.64
- @atproto/api@0.13.25
- @atproto/bsky@0.0.103
- @atproto/pds@0.4.81

## 0.3.72

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/dev-env/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@atproto/dev-env",
"version": "0.3.72",
"version": "0.3.73",
"license": "MIT",
"description": "Local development environment helper for atproto development",
"keywords": [
Expand Down
5 changes: 4 additions & 1 deletion packages/dev-env/src/moderator-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,19 @@ export class ModeratorClient {
durationInHours?: number
acknowledgeAccountSubjects?: boolean
reason?: string
policies?: string[]
},
role?: ModLevel,
) {
const { durationInHours, acknowledgeAccountSubjects, ...rest } = opts
const { durationInHours, acknowledgeAccountSubjects, policies, ...rest } =
opts
return this.emitEvent(
{
event: {
$type: 'tools.ozone.moderation.defs#modEventTakedown',
acknowledgeAccountSubjects,
durationInHours,
policies,
},
...rest,
},
Expand Down
1 change: 0 additions & 1 deletion packages/internal/pipe/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"default": "./dist/index.js"
}
},
"dependencies": {},
"devDependencies": {
"typescript": "^5.6.3"
},
Expand Down
1 change: 0 additions & 1 deletion packages/internal/simple-store/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"default": "./dist/index.js"
}
},
"dependencies": {},
"devDependencies": {
"typescript": "^5.6.3"
},
Expand Down
9 changes: 9 additions & 0 deletions packages/ozone/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# @atproto/ozone

## 0.1.64

### Patch Changes

- [#3271](https://github.com/bluesky-social/atproto/pull/3271) [`53621f8e1`](https://github.com/bluesky-social/atproto/commit/53621f8e100a3aa3c1caff10a08d3f4ea919875a) Thanks [@foysalit](https://github.com/foysalit)! - Allow setting policy names with takedown actions and when querying events

- Updated dependencies [[`53621f8e1`](https://github.com/bluesky-social/atproto/commit/53621f8e100a3aa3c1caff10a08d3f4ea919875a)]:
- @atproto/api@0.13.25

## 0.1.63

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/ozone/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@atproto/ozone",
"version": "0.1.63",
"version": "0.1.64",
"license": "MIT",
"description": "Backend service for moderating the Bluesky network.",
"keywords": [
Expand Down
2 changes: 2 additions & 0 deletions packages/ozone/src/api/moderation/queryEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default function (server: Server, ctx: AppContext) {
reportTypes,
collections = [],
subjectType,
policies,
} = params
const db = ctx.db
const modService = ctx.modService(db)
Expand All @@ -47,6 +48,7 @@ export default function (server: Server, ctx: AppContext) {
reportTypes,
collections,
subjectType,
policies,
})
return {
encoding: 'application/json',
Expand Down
17 changes: 17 additions & 0 deletions packages/ozone/src/lexicon/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11309,6 +11309,15 @@ export const schemaDict = {
description:
'If true, all other reports on content authored by this account will be resolved (acknowledged).',
},
policies: {
type: 'array',
maxLength: 5,
items: {
type: 'string',
},
description:
'Names/Keywords of the policies that drove the decision.',
},
},
},
modEventReverseTakedown: {
Expand Down Expand Up @@ -12345,6 +12354,14 @@ export const schemaDict = {
type: 'string',
},
},
policies: {
type: 'array',
items: {
type: 'string',
description:
'If specified, only events where the policy matches the given policy are returned',
},
},
cursor: {
type: 'string',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ export interface ModEventTakedown {
durationInHours?: number
/** If true, all other reports on content authored by this account will be resolved (acknowledged). */
acknowledgeAccountSubjects?: boolean
/** Names/Keywords of the policies that drove the decision. */
policies?: string[]
[k: string]: unknown
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export interface QueryParams {
/** If specified, only events where all of these tags were removed are returned */
removedTags?: string[]
reportTypes?: string[]
policies?: string[]
cursor?: string
}

Expand Down
14 changes: 14 additions & 0 deletions packages/ozone/src/mod-service/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ export class ModerationService {
reportTypes?: string[]
collections: string[]
subjectType?: string
policies?: string[]
}): Promise<{ cursor?: string; events: ModerationEventRow[] }> {
const {
subject,
Expand All @@ -172,6 +173,7 @@ export class ModerationService {
reportTypes,
collections,
subjectType,
policies,
} = opts
const { ref } = this.db.db.dynamic
let builder = this.db.db.selectFrom('moderation_event').selectAll()
Expand Down Expand Up @@ -264,6 +266,14 @@ export class ModerationService {
if (reportTypes?.length) {
builder = builder.where(sql`meta->>'reportType'`, 'in', reportTypes)
}
if (policies?.length) {
builder = builder.where((qb) => {
policies.forEach((policy) => {
qb = qb.orWhere(sql`meta->>'policies'`, 'ilike', `%${policy}%`)
})
return qb
})
}

const keyset = new TimeIdKeyset(
ref(`moderation_event.createdAt`),
Expand Down Expand Up @@ -435,6 +445,10 @@ export class ModerationService {
meta.acknowledgeAccountSubjects = true
}

if (isModEventTakedown(event) && event.policies?.length) {
meta.policies = event.policies.join(',')
}

// Keep trace of reports that came in while the reporter was in muted stated
if (isModEventReport(event)) {
const isReportingMuted = await this.isReportingMutedForSubject(createdBy)
Expand Down
Loading

0 comments on commit bb64dff

Please sign in to comment.