-
Notifications
You must be signed in to change notification settings - Fork 628
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Add a policy property to takedown events (#3271)
* ✨ Add a policy property to takedown events * ✨ Add policy list setting validation * ✨ Make multiple policies possible for takedown and event search * 📝 Add changeset * ✨ Use , as policies separator
- Loading branch information
Showing
19 changed files
with
204 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"@atproto/dev-env": patch | ||
"@atproto/ozone": patch | ||
"@atproto/api": patch | ||
--- | ||
|
||
Allow setting policy names with takedown actions and when querying events |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export const ProtectedTagSettingKey = 'tools.ozone.setting.protectedTags' | ||
export const PolicyListSettingKey = 'tools.ozone.setting.policyList' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { | ||
TestNetwork, | ||
TestOzone, | ||
SeedClient, | ||
basicSeed, | ||
ModeratorClient, | ||
} from '@atproto/dev-env' | ||
import { AtpAgent } from '@atproto/api' | ||
|
||
describe('moderation', () => { | ||
let network: TestNetwork | ||
let ozone: TestOzone | ||
let agent: AtpAgent | ||
let bskyAgent: AtpAgent | ||
let pdsAgent: AtpAgent | ||
let sc: SeedClient | ||
let modClient: ModeratorClient | ||
|
||
const repoSubject = (did: string) => ({ | ||
$type: 'com.atproto.admin.defs#repoRef', | ||
did, | ||
}) | ||
|
||
beforeAll(async () => { | ||
network = await TestNetwork.create({ | ||
dbPostgresSchema: 'ozone_takedown', | ||
}) | ||
ozone = network.ozone | ||
agent = network.ozone.getClient() | ||
bskyAgent = network.bsky.getClient() | ||
pdsAgent = network.pds.getClient() | ||
sc = network.getSeedClient() | ||
modClient = network.ozone.getModClient() | ||
await basicSeed(sc) | ||
await network.processAll() | ||
}) | ||
|
||
afterAll(async () => { | ||
await network.close() | ||
}) | ||
|
||
it('allows specifying policy for takedown actions.', async () => { | ||
await modClient.performTakedown({ | ||
subject: repoSubject(sc.dids.bob), | ||
policies: ['trolling'], | ||
}) | ||
|
||
// Verify that that the takedown even exposes the policy specified for it | ||
const { events } = await modClient.queryEvents({ | ||
subject: sc.dids.bob, | ||
types: ['tools.ozone.moderation.defs#modEventTakedown'], | ||
}) | ||
|
||
expect(events[0].event.policies?.[0]).toEqual('trolling') | ||
|
||
// Verify that event stream can be filtered by policy | ||
const { events: filteredEvents } = await modClient.queryEvents({ | ||
subject: sc.dids.bob, | ||
policies: ['trolling'], | ||
}) | ||
|
||
expect(filteredEvents[0].subject.did).toEqual(sc.dids.bob) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters