kopia lustrzana https://github.com/halcy/Mastodon.py
add admin email domain blocks, missing Appeal entity
rodzic
c460d3c965
commit
adabd511fe
|
@ -31,7 +31,7 @@ attributes, `even if a type does not define them.`. Lists have been split into l
|
|||
that can be paginated (i.e. that have pagination attributes) and those that cannot.
|
||||
|
||||
All return values can be converted from and to JSON using the `to_json()` and `from_json()`
|
||||
methods defined on the ::class::`mastodon.types_base.Entity` class.
|
||||
methods defined on the `mastodon.types_base.Entity` class.
|
||||
|
||||
Base types
|
||||
==========
|
||||
|
@ -370,6 +370,9 @@ Return types
|
|||
.. autoclass:: mastodon.return_types.UnreadNotificationsCount
|
||||
:members:
|
||||
|
||||
.. autoclass:: mastodon.return_types.Appeal
|
||||
:members:
|
||||
|
||||
Deprecated types
|
||||
================
|
||||
.. autoclass:: mastodon.return_types.Filter
|
||||
|
@ -380,3 +383,4 @@ Deprecated types
|
|||
|
||||
.. autoclass:: mastodon.return_types.IdentityProof
|
||||
:members:
|
||||
|
||||
|
|
|
@ -66,3 +66,11 @@ Canonical email blocks
|
|||
.. automethod:: Mastodon.admin_create_canonical_email_block
|
||||
.. automethod:: Mastodon.admin_delete_canonical_email_block
|
||||
|
||||
Email domain blocks
|
||||
-------------------
|
||||
.. automethod:: Mastodon.admin_email_domain_blocks
|
||||
.. automethod:: Mastodon.admin_email_domain_block
|
||||
.. automethod:: Mastodon.admin_create_email_domain_block
|
||||
.. automethod:: Mastodon.admin_delete_email_domain_block
|
||||
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ from mastodon.utility import api_version
|
|||
from mastodon.internals import Mastodon as Internals
|
||||
from typing import Optional, List, Union
|
||||
from mastodon.return_types import IdType, PrimitiveIdType, Account, AdminAccount, AdminReport, PaginatableList, NonPaginatableList, Status, Tag,\
|
||||
PreviewCard, AdminDomainBlock, AdminMeasure, AdminDimension, AdminRetention, AdminCanonicalEmailBlock, AdminDomainAllow
|
||||
PreviewCard, AdminDomainBlock, AdminMeasure, AdminDimension, AdminRetention, AdminCanonicalEmailBlock, AdminDomainAllow, AdminEmailDomainBlock
|
||||
from datetime import datetime
|
||||
|
||||
class Mastodon(Internals):
|
||||
|
@ -658,3 +658,44 @@ class Mastodon(Internals):
|
|||
"""
|
||||
id = self.__unpack_id(id)
|
||||
self.__api_request('DELETE', f'/api/v1/admin/domain_allows/{id}')
|
||||
|
||||
@api_version("4.0.0", "4.0.0")
|
||||
def admin_email_domain_blocks(self, max_id: Optional[IdType] = None, min_id: Optional[IdType] = None,
|
||||
since_id: Optional[IdType] = None, limit: Optional[int] = None) -> PaginatableList[AdminEmailDomainBlock]:
|
||||
"""
|
||||
Fetches a list of blocked email domains. Requires scope `admin:read:email_domain_blocks`.
|
||||
|
||||
The returned list may be paginated using max_id, min_id, and since_id.
|
||||
"""
|
||||
params = self.__generate_params(locals())
|
||||
return self.__api_request('GET', '/api/v1/admin/email_domain_blocks', params)
|
||||
|
||||
@api_version("4.1.0", "4.1.0")
|
||||
def admin_email_domain_block(self, id: IdType) -> AdminEmailDomainBlock:
|
||||
"""
|
||||
Fetch a single blocked email domain by ID. Requires scope `admin:read:email_domain_blocks`.
|
||||
|
||||
Raises `MastodonAPIError` if the email domain block does not exist.
|
||||
"""
|
||||
id = self.__unpack_id(id)
|
||||
return self.__api_request('GET', f'/api/v1/admin/email_domain_blocks/{id}')
|
||||
|
||||
@api_version("4.0.0", "4.0.0")
|
||||
def admin_create_email_domain_block(self, domain: str) -> AdminEmailDomainBlock:
|
||||
"""
|
||||
Block an email domain from signups. Requires scope `admin:write:email_domain_blocks`.
|
||||
|
||||
If the domain contains invalid characters, a `MastodonAPIError` will be raised.
|
||||
"""
|
||||
params = {"domain": domain}
|
||||
return self.__api_request('POST', '/api/v1/admin/email_domain_blocks', params)
|
||||
|
||||
@api_version("4.0.0", "4.0.0")
|
||||
def admin_delete_email_domain_block(self, id: IdType):
|
||||
"""
|
||||
Remove an email domain block. Requires scope `admin:write:email_domain_blocks`.
|
||||
|
||||
Raises `MastodonAPIError` if the email domain block does not exist.
|
||||
"""
|
||||
id = self.__unpack_id(id)
|
||||
self.__api_request('DELETE', f'/api/v1/admin/email_domain_blocks/{id}')
|
||||
|
|
|
@ -5331,7 +5331,7 @@ class AdminCanonicalEmailBlock(AttribAccessDict):
|
|||
.. code-block:: python
|
||||
|
||||
# Returns a AdminCanonicalEmailBlock object
|
||||
api2.admin_create_canonical_email_block(email=<some email>)
|
||||
mastodon.admin_create_canonical_email_block(email=<some email>)
|
||||
|
||||
See also (Mastodon API documentation): https://docs.joinmastodon.org/entities/Admin_CanonicalEmailBlock
|
||||
"""
|
||||
|
@ -5363,7 +5363,7 @@ class AdminDomainAllow(AttribAccessDict):
|
|||
.. code-block:: python
|
||||
|
||||
# Returns a AdminDomainAllow object
|
||||
TODO_TO_BE_IMPLEMENTED
|
||||
mastodon.admin_domain_allows()[0]
|
||||
|
||||
See also (Mastodon API documentation): https://docs.joinmastodon.org/entities/Admin_DomainAllow
|
||||
"""
|
||||
|
@ -5403,7 +5403,7 @@ class AdminEmailDomainBlock(AttribAccessDict):
|
|||
.. code-block:: python
|
||||
|
||||
# Returns a AdminEmailDomainBlock object
|
||||
TODO_TO_BE_IMPLEMENTED
|
||||
mastodo.admin_email_domain_blocks()[0]
|
||||
|
||||
See also (Mastodon API documentation): https://docs.joinmastodon.org/entities/Admin_EmailDomainBlock
|
||||
"""
|
||||
|
@ -5451,7 +5451,7 @@ class AdminEmailDomainBlockHistory(AttribAccessDict):
|
|||
.. code-block:: python
|
||||
|
||||
# Returns a AdminEmailDomainBlockHistory object
|
||||
TODO_TO_BE_IMPLEMENTED
|
||||
mastodo.admin_email_domain_blocks()[0].history[0]
|
||||
|
||||
See also (Mastodon API documentation): https://docs.joinmastodon.org/entities/Admin_EmailDomainBlock
|
||||
"""
|
||||
|
@ -5807,7 +5807,7 @@ class Suggestion(AttribAccessDict):
|
|||
.. code-block:: python
|
||||
|
||||
# Returns a Suggestion object
|
||||
mastodon.suggestions()[0]
|
||||
mastodon.suggestions_v2()[0]
|
||||
|
||||
See also (Mastodon API documentation): https://docs.joinmastodon.org/entities/Suggestion
|
||||
"""
|
||||
|
@ -6115,7 +6115,7 @@ class RelationshipSeveranceEvent(AttribAccessDict):
|
|||
.. code-block:: python
|
||||
|
||||
# Returns a RelationshipSeveranceEvent object
|
||||
TODO_TO_BE_IMPLEMENTED
|
||||
# There isn't really a good way to get this manually - you get it if a moderation takes action.
|
||||
|
||||
See also (Mastodon API documentation): https://docs.joinmastodon.org/entities/RelationshipSeveranceEvent
|
||||
"""
|
||||
|
@ -6131,6 +6131,7 @@ class RelationshipSeveranceEvent(AttribAccessDict):
|
|||
type: "str"
|
||||
"""
|
||||
Type of event.
|
||||
Should contain (as text): RelationshipSeveranceEventType
|
||||
|
||||
Version history:
|
||||
* 4.3.0: added
|
||||
|
@ -6420,7 +6421,7 @@ class AccountWarning(AttribAccessDict):
|
|||
.. code-block:: python
|
||||
|
||||
# Returns a AccountWarning object
|
||||
TODO_TO_BE_IMPLEMENTED
|
||||
# There isn't really a good way to get this manually - you get it if a moderation takes action.
|
||||
|
||||
See also (Mastodon API documentation): https://docs.joinmastodon.org/entities/AccountWarning
|
||||
"""
|
||||
|
@ -6485,16 +6486,16 @@ class AccountWarning(AttribAccessDict):
|
|||
|
||||
class UnreadNotificationsCount(AttribAccessDict):
|
||||
"""
|
||||
Get the (capped) number of unread notifications for the current user.
|
||||
Rhe (capped) number of unread notifications for the current user.
|
||||
|
||||
Example:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
# Returns a UnreadNotificationsCount object
|
||||
TODO_TO_BE_IMPLEMENTED
|
||||
mastodon.notifications_unread_count()
|
||||
|
||||
See also (Mastodon API documentation): https://docs.joinmastodon.org/methods/notifications/#unread_count
|
||||
See also (Mastodon API documentation): https://docs.joinmastodon.org/methods/notifications/#unread-count
|
||||
"""
|
||||
|
||||
count: "int"
|
||||
|
@ -6507,6 +6508,39 @@ class UnreadNotificationsCount(AttribAccessDict):
|
|||
|
||||
_version = "4.3.0"
|
||||
|
||||
class Appeal(AttribAccessDict):
|
||||
"""
|
||||
Appeal against a moderation action.
|
||||
|
||||
Example:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
# Returns a Appeal object
|
||||
TODO_TO_BE_IMPLEMENTED
|
||||
|
||||
See also (Mastodon API documentation): https://docs.joinmastodon.org/entities/Appeal/
|
||||
"""
|
||||
|
||||
text: "str"
|
||||
"""
|
||||
Text of the appeal from the moderated account to the moderators..
|
||||
|
||||
Version history:
|
||||
* 4.3.0: added
|
||||
"""
|
||||
|
||||
state: "str"
|
||||
"""
|
||||
State of the appeal.
|
||||
Should contain (as text): AppealStateEnum
|
||||
|
||||
Version history:
|
||||
* 4.3.0: added
|
||||
"""
|
||||
|
||||
_version = "4.3.0"
|
||||
|
||||
ENTITY_NAME_MAP = {
|
||||
"Account": Account,
|
||||
"AccountField": AccountField,
|
||||
|
@ -6615,6 +6649,7 @@ ENTITY_NAME_MAP = {
|
|||
"NotificationGroup": NotificationGroup,
|
||||
"AccountWarning": AccountWarning,
|
||||
"UnreadNotificationsCount": UnreadNotificationsCount,
|
||||
"Appeal": Appeal,
|
||||
}
|
||||
__all__ = [
|
||||
"Account",
|
||||
|
@ -6724,5 +6759,6 @@ __all__ = [
|
|||
"NotificationGroup",
|
||||
"AccountWarning",
|
||||
"UnreadNotificationsCount",
|
||||
"Appeal",
|
||||
]
|
||||
|
||||
|
|
|
@ -163,7 +163,7 @@ if sys.version_info < (3, 9):
|
|||
DomainBlock, ExtendedDescription, FilterKeyword, FilterStatus, IdentityProof, StatusSource, \
|
||||
Suggestion, Translation, AccountCreationError, AccountCreationErrorDetails, AccountCreationErrorDetailsField, NotificationPolicy, \
|
||||
NotificationPolicySummary, RelationshipSeveranceEvent, GroupedNotificationsResults, PartialAccountWithAvatar, NotificationGroup, AccountWarning, \
|
||||
UnreadNotificationsCount
|
||||
UnreadNotificationsCount, Appeal
|
||||
if isinstance(t, ForwardRef):
|
||||
try:
|
||||
t = t._evaluate(globals(), locals(), frozenset())
|
||||
|
|
|
@ -8123,11 +8123,11 @@
|
|||
{
|
||||
"name": "Admin email domain block",
|
||||
"python_name": "AdminEmailDomainBlock",
|
||||
"func_call": "TODO_TO_BE_IMPLEMENTED",
|
||||
"func_call": "mastodo.admin_email_domain_blocks()[0]",
|
||||
"func_call_real": null,
|
||||
"func_call_additional": null,
|
||||
"func_alternate_acc": null,
|
||||
"manual_update": false,
|
||||
"manual_update": true,
|
||||
"masto_doc_link": "https://docs.joinmastodon.org/entities/Admin_EmailDomainBlock",
|
||||
"description": "A block that has been set up to prevent e-mails from certain domains to be used when signing up.",
|
||||
"fields": {
|
||||
|
@ -8196,11 +8196,11 @@
|
|||
{
|
||||
"name": "Admin email signup attempt history",
|
||||
"python_name": "AdminEmailDomainBlockHistory",
|
||||
"func_call": "TODO_TO_BE_IMPLEMENTED",
|
||||
"func_call": "mastodo.admin_email_domain_blocks()[0].history[0]",
|
||||
"func_call_real": null,
|
||||
"func_call_additional": null,
|
||||
"func_alternate_acc": null,
|
||||
"manual_update": false,
|
||||
"manual_update": true,
|
||||
"masto_doc_link": "https://docs.joinmastodon.org/entities/Admin_EmailDomainBlock",
|
||||
"description": "Historic data about attempted signups using e-mails from a given domain.",
|
||||
"fields": {
|
||||
|
@ -9644,7 +9644,7 @@
|
|||
"func_alternate_acc": null,
|
||||
"manual_update": false,
|
||||
"masto_doc_link": "https://docs.joinmastodon.org/methods/notifications/#unread-count",
|
||||
"description": "Get the (capped) number of unread notifications for the current user.",
|
||||
"description": "Rhe (capped) number of unread notifications for the current user.",
|
||||
"fields": {
|
||||
"count": {
|
||||
"description": "The capped number of unread notifications. The cap is not documented.",
|
||||
|
@ -9657,5 +9657,42 @@
|
|||
"is_nullable": false
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Appeal",
|
||||
"python_name": "Appeal",
|
||||
"func_call": "TODO_TO_BE_IMPLEMENTED",
|
||||
"func_call_real": null,
|
||||
"func_call_additional": null,
|
||||
"func_alternate_acc": null,
|
||||
"manual_update": false,
|
||||
"masto_doc_link": "https://docs.joinmastodon.org/entities/Appeal/",
|
||||
"description": "Appeal against a moderation action.",
|
||||
"fields": {
|
||||
"text": {
|
||||
"description": "Text of the appeal from the moderated account to the moderators..",
|
||||
"enum": null,
|
||||
"version_history": [["4.3.0", "added"]],
|
||||
"field_type": "str",
|
||||
"field_subtype": null,
|
||||
"field_structuretype": null,
|
||||
"is_optional": false,
|
||||
"is_nullable": false
|
||||
},
|
||||
"state": {
|
||||
"description": "State of the appeal.",
|
||||
"enum": {
|
||||
"approved": "The appeal has been approved by a moderator",
|
||||
"rejected": "The appeal has been rejected by a moderator",
|
||||
"pending": "The appeal has been submitted, but neither approved nor rejected yet"
|
||||
},
|
||||
"version_history": [["4.3.0", "added"]],
|
||||
"field_type": "str",
|
||||
"field_subtype": null,
|
||||
"field_structuretype": "AppealStateEnum",
|
||||
"is_optional": false,
|
||||
"is_nullable": false
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
@ -0,0 +1,305 @@
|
|||
interactions:
|
||||
- request:
|
||||
body: domain=blockedexample.com
|
||||
headers:
|
||||
Accept:
|
||||
- '*/*'
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '25'
|
||||
Content-Type:
|
||||
- application/x-www-form-urlencoded
|
||||
User-Agent:
|
||||
- tests/v311
|
||||
method: POST
|
||||
uri: http://localhost:3000/api/v1/admin/email_domain_blocks
|
||||
response:
|
||||
body:
|
||||
string: '{"id":"1","domain":"blockedexample.com","created_at":"2025-02-15T14:54:05.852Z","history":[{"day":"1739577600","accounts":"0","uses":"0"},{"day":"1739491200","accounts":"0","uses":"0"},{"day":"1739404800","accounts":"0","uses":"0"},{"day":"1739318400","accounts":"0","uses":"0"},{"day":"1739232000","accounts":"0","uses":"0"},{"day":"1739145600","accounts":"0","uses":"0"},{"day":"1739059200","accounts":"0","uses":"0"}],"allow_with_approval":false}'
|
||||
headers:
|
||||
Cache-Control:
|
||||
- private, no-store
|
||||
Content-Length:
|
||||
- '449'
|
||||
Content-Security-Policy:
|
||||
- default-src 'none'; frame-ancestors 'none'; form-action 'none'
|
||||
Content-Type:
|
||||
- application/json; charset=utf-8
|
||||
ETag:
|
||||
- W/"1808d2ab259a9df5de95d5c1b66b923a"
|
||||
Referrer-Policy:
|
||||
- strict-origin-when-cross-origin
|
||||
Server-Timing:
|
||||
- cache_read.active_support;dur=0.02, sql.active_record;dur=25.96, cache_generate.active_support;dur=14.16,
|
||||
cache_write.active_support;dur=0.14, instantiation.active_record;dur=0.57,
|
||||
start_processing.action_controller;dur=0.01, transaction.active_record;dur=9.82,
|
||||
render.active_model_serializers;dur=1.58, process_action.action_controller;dur=74.00
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Frame-Options:
|
||||
- SAMEORIGIN
|
||||
X-Permitted-Cross-Domain-Policies:
|
||||
- none
|
||||
X-RateLimit-Limit:
|
||||
- '300'
|
||||
X-RateLimit-Remaining:
|
||||
- '299'
|
||||
X-RateLimit-Reset:
|
||||
- '2025-02-15T14:55:00.814734Z'
|
||||
X-Request-Id:
|
||||
- 6a80dd2b-8ac4-484f-855d-0a452534c813
|
||||
X-Runtime:
|
||||
- '0.147481'
|
||||
X-XSS-Protection:
|
||||
- '0'
|
||||
vary:
|
||||
- Authorization, Origin
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body: null
|
||||
headers:
|
||||
Accept:
|
||||
- '*/*'
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2
|
||||
Connection:
|
||||
- keep-alive
|
||||
User-Agent:
|
||||
- tests/v311
|
||||
method: GET
|
||||
uri: http://localhost:3000/api/v1/admin/email_domain_blocks/1
|
||||
response:
|
||||
body:
|
||||
string: '{"id":"1","domain":"blockedexample.com","created_at":"2025-02-15T14:54:05.852Z","history":[{"day":"1739577600","accounts":"0","uses":"0"},{"day":"1739491200","accounts":"0","uses":"0"},{"day":"1739404800","accounts":"0","uses":"0"},{"day":"1739318400","accounts":"0","uses":"0"},{"day":"1739232000","accounts":"0","uses":"0"},{"day":"1739145600","accounts":"0","uses":"0"},{"day":"1739059200","accounts":"0","uses":"0"}],"allow_with_approval":false}'
|
||||
headers:
|
||||
Cache-Control:
|
||||
- private, no-store
|
||||
Content-Length:
|
||||
- '449'
|
||||
Content-Security-Policy:
|
||||
- default-src 'none'; frame-ancestors 'none'; form-action 'none'
|
||||
Content-Type:
|
||||
- application/json; charset=utf-8
|
||||
ETag:
|
||||
- W/"1808d2ab259a9df5de95d5c1b66b923a"
|
||||
Referrer-Policy:
|
||||
- strict-origin-when-cross-origin
|
||||
Server-Timing:
|
||||
- cache_read.active_support;dur=0.02, sql.active_record;dur=0.98, cache_generate.active_support;dur=1.00,
|
||||
cache_write.active_support;dur=0.07, instantiation.active_record;dur=0.29,
|
||||
start_processing.action_controller;dur=0.00, render.active_model_serializers;dur=1.45,
|
||||
process_action.action_controller;dur=21.91
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Frame-Options:
|
||||
- SAMEORIGIN
|
||||
X-Permitted-Cross-Domain-Policies:
|
||||
- none
|
||||
X-RateLimit-Limit:
|
||||
- '300'
|
||||
X-RateLimit-Remaining:
|
||||
- '299'
|
||||
X-RateLimit-Reset:
|
||||
- '2025-02-15T14:55:00.904524Z'
|
||||
X-Request-Id:
|
||||
- fa306560-9b65-48a2-82a0-d0a35aa847ab
|
||||
X-Runtime:
|
||||
- '0.037382'
|
||||
X-XSS-Protection:
|
||||
- '0'
|
||||
vary:
|
||||
- Authorization, Origin
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body: null
|
||||
headers:
|
||||
Accept:
|
||||
- '*/*'
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2
|
||||
Connection:
|
||||
- keep-alive
|
||||
User-Agent:
|
||||
- tests/v311
|
||||
method: GET
|
||||
uri: http://localhost:3000/api/v1/admin/email_domain_blocks
|
||||
response:
|
||||
body:
|
||||
string: '[{"id":"1","domain":"blockedexample.com","created_at":"2025-02-15T14:54:05.852Z","history":[{"day":"1739577600","accounts":"0","uses":"0"},{"day":"1739491200","accounts":"0","uses":"0"},{"day":"1739404800","accounts":"0","uses":"0"},{"day":"1739318400","accounts":"0","uses":"0"},{"day":"1739232000","accounts":"0","uses":"0"},{"day":"1739145600","accounts":"0","uses":"0"},{"day":"1739059200","accounts":"0","uses":"0"}],"allow_with_approval":false}]'
|
||||
headers:
|
||||
Cache-Control:
|
||||
- private, no-store
|
||||
Content-Length:
|
||||
- '451'
|
||||
Content-Security-Policy:
|
||||
- default-src 'none'; frame-ancestors 'none'; form-action 'none'
|
||||
Content-Type:
|
||||
- application/json; charset=utf-8
|
||||
ETag:
|
||||
- W/"9b0a3ccd05281d166d2b8e8e5eed8b2c"
|
||||
Link:
|
||||
- <http://localhost:3000/api/v1/admin/email_domain_blocks?min_id=1>; rel="prev"
|
||||
Referrer-Policy:
|
||||
- strict-origin-when-cross-origin
|
||||
Server-Timing:
|
||||
- cache_read.active_support;dur=0.02, sql.active_record;dur=0.95, cache_generate.active_support;dur=0.77,
|
||||
cache_write.active_support;dur=0.07, instantiation.active_record;dur=0.25,
|
||||
start_processing.action_controller;dur=0.00, render.active_model_serializers;dur=1.13,
|
||||
process_action.action_controller;dur=21.94
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Frame-Options:
|
||||
- SAMEORIGIN
|
||||
X-Permitted-Cross-Domain-Policies:
|
||||
- none
|
||||
X-RateLimit-Limit:
|
||||
- '300'
|
||||
X-RateLimit-Remaining:
|
||||
- '299'
|
||||
X-RateLimit-Reset:
|
||||
- '2025-02-15T14:55:00.946215Z'
|
||||
X-Request-Id:
|
||||
- 9d9d1aa5-8bfe-4729-a0d3-1921e48ec677
|
||||
X-Runtime:
|
||||
- '0.036179'
|
||||
X-XSS-Protection:
|
||||
- '0'
|
||||
vary:
|
||||
- Authorization, Origin
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body: null
|
||||
headers:
|
||||
Accept:
|
||||
- '*/*'
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '0'
|
||||
User-Agent:
|
||||
- tests/v311
|
||||
method: DELETE
|
||||
uri: http://localhost:3000/api/v1/admin/email_domain_blocks/1
|
||||
response:
|
||||
body:
|
||||
string: '{}'
|
||||
headers:
|
||||
Cache-Control:
|
||||
- private, no-store
|
||||
Content-Length:
|
||||
- '2'
|
||||
Content-Security-Policy:
|
||||
- default-src 'none'; frame-ancestors 'none'; form-action 'none'
|
||||
Content-Type:
|
||||
- application/json; charset=utf-8
|
||||
ETag:
|
||||
- W/"44136fa355b3678a1146ad16f7e8649e"
|
||||
Referrer-Policy:
|
||||
- strict-origin-when-cross-origin
|
||||
Server-Timing:
|
||||
- cache_read.active_support;dur=0.02, sql.active_record;dur=6.56, cache_generate.active_support;dur=0.93,
|
||||
cache_write.active_support;dur=0.26, instantiation.active_record;dur=0.35,
|
||||
start_processing.action_controller;dur=0.00, transaction.active_record;dur=6.76,
|
||||
render.active_model_serializers;dur=0.05, process_action.action_controller;dur=32.27
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Frame-Options:
|
||||
- SAMEORIGIN
|
||||
X-Permitted-Cross-Domain-Policies:
|
||||
- none
|
||||
X-RateLimit-Limit:
|
||||
- '300'
|
||||
X-RateLimit-Remaining:
|
||||
- '299'
|
||||
X-RateLimit-Reset:
|
||||
- '2025-02-15T14:55:00.988934Z'
|
||||
X-Request-Id:
|
||||
- 6e80b620-9464-4c22-a0d1-dd5e7ff6a1d4
|
||||
X-Runtime:
|
||||
- '0.047064'
|
||||
X-XSS-Protection:
|
||||
- '0'
|
||||
vary:
|
||||
- Authorization, Origin
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body: null
|
||||
headers:
|
||||
Accept:
|
||||
- '*/*'
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2
|
||||
Connection:
|
||||
- keep-alive
|
||||
User-Agent:
|
||||
- tests/v311
|
||||
method: GET
|
||||
uri: http://localhost:3000/api/v1/admin/email_domain_blocks
|
||||
response:
|
||||
body:
|
||||
string: '[]'
|
||||
headers:
|
||||
Cache-Control:
|
||||
- private, no-store
|
||||
Content-Length:
|
||||
- '2'
|
||||
Content-Security-Policy:
|
||||
- default-src 'none'; frame-ancestors 'none'; form-action 'none'
|
||||
Content-Type:
|
||||
- application/json; charset=utf-8
|
||||
ETag:
|
||||
- W/"4f53cda18c2baa0c0354bb5f9a3ecbe5"
|
||||
Referrer-Policy:
|
||||
- strict-origin-when-cross-origin
|
||||
Server-Timing:
|
||||
- cache_read.active_support;dur=0.02, sql.active_record;dur=1.14, cache_generate.active_support;dur=1.04,
|
||||
cache_write.active_support;dur=0.10, instantiation.active_record;dur=0.24,
|
||||
start_processing.action_controller;dur=0.00, render.active_model_serializers;dur=0.04,
|
||||
process_action.action_controller;dur=20.25
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Frame-Options:
|
||||
- SAMEORIGIN
|
||||
X-Permitted-Cross-Domain-Policies:
|
||||
- none
|
||||
X-RateLimit-Limit:
|
||||
- '300'
|
||||
X-RateLimit-Remaining:
|
||||
- '299'
|
||||
X-RateLimit-Reset:
|
||||
- '2025-02-15T14:55:00.039450Z'
|
||||
X-Request-Id:
|
||||
- a4d9dbce-c753-40e3-b738-92b3dd2a8269
|
||||
X-Runtime:
|
||||
- '0.035120'
|
||||
X-XSS-Protection:
|
||||
- '0'
|
||||
vary:
|
||||
- Authorization, Origin
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
version: 1
|
|
@ -274,3 +274,24 @@ def test_admin_canonical_email_block(api2):
|
|||
api2.admin_delete_canonical_email_block(block_id)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
@pytest.mark.vcr(match_on=['path'])
|
||||
def test_admin_email_domain_blocks(api2):
|
||||
test_domain = "blockedexample.com"
|
||||
|
||||
created_block = api2.admin_create_email_domain_block(test_domain)
|
||||
assert created_block is not None
|
||||
assert created_block.domain == test_domain
|
||||
|
||||
retrieved_block = api2.admin_email_domain_block(created_block.id)
|
||||
assert retrieved_block.id == created_block.id
|
||||
assert retrieved_block.domain == test_domain
|
||||
|
||||
all_blocks = api2.admin_email_domain_blocks()
|
||||
assert any(block.id == created_block.id for block in all_blocks)
|
||||
|
||||
api2.admin_delete_email_domain_block(created_block.id)
|
||||
|
||||
all_blocks_after_delete = api2.admin_email_domain_blocks()
|
||||
assert not any(block.id == created_block.id for block in all_blocks_after_delete)
|
||||
|
|
Ładowanie…
Reference in New Issue