Skip to content
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

Admin account state endpoints #1725

Closed
wants to merge 12 commits into from
Closed

Admin account state endpoints #1725

wants to merge 12 commits into from

Conversation

dholms
Copy link
Collaborator

@dholms dholms commented Oct 9, 2023

Some simple routes for toggling various subject status attributes.

This only includes the takedown attribute, but the basic idea is that other types of state (such as ability to login, mutate, download repo, etc) can included in a similar manner.

I also made only one route for every type of subject (repo, record, blob) and unbundled record & blob takedowns.

There's also a bit of a weird implementation detail where we translate between the lexicon represenation of state (boolean & optional ref) and our current database schema (arbitrary string where presence means the takedown is applied). We can clean this up in pds v2

Precursor to #1723 & we'll probably merge/deploy both together. Just kept as a separate PR for ease of review

Comment on lines 11 to 13
"did": { "type": "string", "format": "did" },
"uri": { "type": "string", "format": "at-uri" },
"blob": { "type": "string", "format": "cid" }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want the status for a blob do you end-up passing (did, blob)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah that's what i was thinking

Comment on lines 13 to 18
// if less than admin access then cannot perform a takedown
if (!access.moderator) {
throw new AuthRequiredError(
'Must be a full moderator to update subject state',
)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no update happening here, so I think we can safely skip this check.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yup good call 👍

@@ -0,0 +1,39 @@
{
"lexicon": 1,
"id": "com.atproto.admin.getSubjectState",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you envision having a separate endpoint for getting the subject state specific to a particular service? Or beyond that, fetching the subject state for multiple services at once?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah - i view this as just being "what is this particular service's state for this subject?" then the moderation service could have some higher-level end points for collating state from across services

auth: ctx.roleVerifier,
handler: async ({ input, auth }) => {
const access = auth.credentials
// if less than admin access then cannot perform a takedown
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment might be out-of-date since this check below permits non-admin moderators. Or maybe we need a more stringent check within the if (takedown) {} block below.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah good call 👍

i updated the error text but not the comment

@@ -0,0 +1,39 @@
{
"lexicon": 1,
"id": "com.atproto.admin.getSubjectState",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you mean about naming being hard here—"subject state" is a little loaded. Some other ideas to replace: "state": flags, statuses, notices, advisories.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as we discussed, i think "status" might work well & syncs up nicely with foysals work

@@ -7,7 +7,7 @@ export interface Record {
rkey: string
repoRev: string | null
indexedAt: string
takedownId: number | null
takedownId: string | null
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a feeling you're already on it, but just a note to ensure we don't forget the db migration path for these.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup yup 👍

@@ -2,6 +2,14 @@
"lexicon": 1,
"id": "com.atproto.admin.defs",
"defs": {
"statusAttr": {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Swapped out "state" for "status" (inspired by Foysal's PR #1617)

As well, differentiated between the names of these two:
"status attribute": an individual attribute of a subject's status. For instance, it's current takedown status
"status": all attributes of a subject's status

@dholms dholms marked this pull request as ready for review October 12, 2023 17:07
@dholms dholms mentioned this pull request Oct 12, 2023
@dholms
Copy link
Collaborator Author

dholms commented Oct 27, 2023

Closing because this is all contained in in #1723

@dholms dholms closed this Oct 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants