-
Notifications
You must be signed in to change notification settings - Fork 636
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨ Add a policy property to takedown events #3271
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ae948a7
:sparkles: Add a policy property to takedown events
foysalit a781841
:sparkles: Add policy list setting validation
foysalit 55c3771
:sparkles: Make multiple policies possible for takedown and event search
foysalit a77b231
:memo: Add changeset
foysalit 54f9076
:sparkles: Use , as policies separator
foysalit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look out for the empty string, which likes to split into
['']
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In other words:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep yep! nice catch. realized the separator is an issue to start with and ended up finding this too.