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

Update admin/domain_blocks to include conflict response #1417

Merged
merged 2 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion content/en/entities/Admin_DomainBlock.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ aliases: [
{
"id": "1",
"domain": "example.com",
"digest": "a379a6f6eeafb9a55e378c118034e2751e682fab9f2d30ab13d2125586ce1947",
"created_at": "2022-11-16T08:15:34.238Z",
"severity": "noop",
"reject_media": false,
Expand All @@ -48,6 +49,13 @@ aliases: [
**Version history:**\
4.0.0 - added

### `digest` {#digest}

**Description:** The sha256 hex digest of the domain that is not allowed to federated.\
**Type:** String\
**Version history:**\
4.3.0 - added
ThisIsMissEm marked this conversation as resolved.
Show resolved Hide resolved

### `created_at` {#created_at}

**Description:** When the domain was blocked from federating.\
Expand Down Expand Up @@ -104,4 +112,4 @@ aliases: [

{{< page-relref page="methods/admin/domain_blocks" caption="admin/domain_blocks API methods" >}}

{{< caption-link url="https://github.com/mastodon/mastodon/blob/main/app/serializers/rest/admin/domain_block_serializer.rb" caption="app/serializers/rest/admin/domain_block_serializer.rb" >}}
{{< caption-link url="https://github.com/mastodon/mastodon/blob/main/app/serializers/rest/admin/domain_block_serializer.rb" caption="app/serializers/rest/admin/domain_block_serializer.rb" >}}
36 changes: 31 additions & 5 deletions content/en/methods/admin/domain_blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ limit
{
"id": "1",
"domain": "example.com",
"digest": "a379a6f6eeafb9a55e378c118034e2751e682fab9f2d30ab13d2125586ce1947",
"created_at": "2022-11-16T08:15:34.238Z",
"severity": "noop",
"reject_media": false,
Expand Down Expand Up @@ -120,6 +121,7 @@ Authorization
{
"id": "1",
"domain": "example.com",
"digest": "a379a6f6eeafb9a55e378c118034e2751e682fab9f2d30ab13d2125586ce1947",
"created_at": "2022-11-16T08:15:34.238Z",
"severity": "noop",
"reject_media": false,
Expand All @@ -146,7 +148,7 @@ DomainBlock with the given ID does not exist

```json
{
"error": "Record not found"
"error": "Record not found"
}
```

Expand Down Expand Up @@ -205,6 +207,7 @@ Domain has been blocked from federating.
{
"id": "1",
"domain": "example.com",
"digest": "a379a6f6eeafb9a55e378c118034e2751e682fab9f2d30ab13d2125586ce1947",
"created_at": "2022-11-16T08:15:34.238Z",
"severity": "noop",
"reject_media": false,
Expand All @@ -225,13 +228,35 @@ Authorized user is not allowed to perform this action, or invalid or missing Aut
}
```

##### 422: Unprocessable entity
##### 422: Unprocessable entity - Missing Parameter

The domain parameter was not provided

```json
{
"error": "Validation failed: Domain can't be blank"
"error": "Validation failed: Domain can't be blank"
}
```

##### 422: Unprocessable entity - Existing Domain Block
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Arguably this shouldn't be a 422 but instead a 409 conflict, I'm not sure how easy that would be to change though, since the 422 is existing behaviour.


The domain parameter already is covered by an existing domain block.

```json
{
"error": "You have already imposed stricter limits on example.com."
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is also misleading kind of: The check is just "do we have a domain block for any of the variants of example.com", it doesn't actually check that the block that is found is "stricter" than the requested block to create.

i.e., if you have a block for foo.example.com where you want to suspend, but you already have a block for example.com which is a silence, then you cannot create foo.example.com's block with suspend, because the rule for example.com prevents you.

Copy link
Contributor

Choose a reason for hiding this comment

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

That does sound like a bug, we may want to let people block subdomains of domains they have merely limited, and that is something the admin interface allows afaict

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

@ThisIsMissEm ThisIsMissEm Mar 14, 2024

Choose a reason for hiding this comment

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

In IFTAS FediCheck we basically had to reimplement the domain block redundancy code, and comparing severity.

i've also an issue to add webhooks to federation management (would certainly be also good to know when a new domain is noticed, but this is much harder to implement )

"existing_domain_block": {
"id": "1",
"domain": "example.com",
"digest": "a379a6f6eeafb9a55e378c118034e2751e682fab9f2d30ab13d2125586ce1947",
"created_at": "2022-11-16T08:15:34.238Z",
"severity": "noop",
"reject_media": false,
"reject_reports": false,
"private_comment": null,
"public_comment": null,
"obfuscate": false
}
}
```

Expand Down Expand Up @@ -292,6 +317,7 @@ Domain block has been updated
{
"id": "1",
"domain": "example.com",
"digest": "a379a6f6eeafb9a55e378c118034e2751e682fab9f2d30ab13d2125586ce1947",
"created_at": "2022-11-16T08:15:34.238Z",
"severity": "noop",
"reject_media": false,
Expand Down Expand Up @@ -368,12 +394,12 @@ DomainBlock with the given ID does not exist

```json
{
"error": "Record not found"
"error": "Record not found"
}
```

---

## See also

{{< caption-link url="https://github.com/mastodon/mastodon/blob/main/app/controllers/api/v1/admin/domain_blocks_controller.rb" caption="app/controllers/api/v1/admin/domain_blocks_controller.rb" >}}
{{< caption-link url="https://github.com/mastodon/mastodon/blob/main/app/controllers/api/v1/admin/domain_blocks_controller.rb" caption="app/controllers/api/v1/admin/domain_blocks_controller.rb" >}}