remove USER_ALLOWLIST in favor of User.enabled_protocols

pull/965/head
Ryan Barrett 2024-04-17 16:49:06 -07:00
rodzic 259b7d72dd
commit 39a641e000
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
5 zmienionych plików z 4 dodań i 28 usunięć

Wyświetl plik

@ -34,7 +34,6 @@ from common import (
DOMAINS,
error,
USER_AGENT,
USER_ALLOWLIST,
)
import flask_app
from models import Object, PROTOCOLS, Target, User
@ -97,7 +96,7 @@ class ATProto(User, Protocol):
# need to update serviceEndpoint in all users' DID docs. :/
PDS_URL = f'https://atproto{common.SUPERDOMAIN}/'
CONTENT_TYPE = 'application/json'
DEFAULT_ENABLED_PROTOCOLS = ('web',)
DEFAULT_ENABLED_PROTOCOLS = ('web', 'activitypub')
def _pre_put_hook(self):
"""Validate id, require did:plc or non-blocklisted did:web."""
@ -580,8 +579,7 @@ def poll_notifications():
headers={'User-Agent': USER_AGENT})
for user in users:
# TODO: remove for launch
if not DEBUG and user.key.id() not in USER_ALLOWLIST:
if not user.is_enabled_to(ATProto, user=user):
logger.info(f'Skipping {user.key.id()}')
continue
@ -640,8 +638,7 @@ def poll_posts():
headers={'User-Agent': USER_AGENT})
for user in users:
# TODO: remove for launch
if not DEBUG and user.key.id() not in USER_ALLOWLIST:
if not user.is_enabled_to(ATProto, user=user):
logger.info(f'Skipping {user.key.id()}')
continue

Wyświetl plik

@ -83,16 +83,6 @@ util.set_user_agent(USER_AGENT)
TASKS_LOCATION = 'us-central1'
RUN_TASKS_INLINE = False # overridden by unit tests
# TODO: switch to User.enabled_protocols
USER_ALLOWLIST = (
'snarfed.org',
'did:plc:fdme4gb7mu7zrie7peay7tst',
'snarfed.bsky.social',
'did:plc:3ljmtyyjqcjee2kpewgsifvb',
'https://indieweb.social/users/snarfed',
'@snarfed@indieweb.social',
)
def base64_to_long(x):
"""Converts from URL safe base64 encoding to long integer.

Wyświetl plik

@ -171,9 +171,6 @@ class Protocol:
elif to_label in user.enabled_protocols:
return True
if user_id in common.USER_ALLOWLIST:
return True
return tuple(sorted((from_label, to_label))) in common.ENABLED_BRIDGES
@classmethod

Wyświetl plik

@ -441,7 +441,7 @@ class ActivityPubTest(TestCase):
self.store_object(id='did:plc:user', raw={'foo': 'baz'})
self.make_user('did:plc:user', cls=ATProto)
got = self.client.get('/ap/did:plc:user', base_url='https://bsky.brid.gy/')
self.assertEqual(400, got.status_code)
self.assertEqual(404, got.status_code)
@patch('common.ENABLED_BRIDGES', new=[('activitypub', 'atproto')])
def test_actor_atproto_no_handle(self, *_):

Wyświetl plik

@ -184,14 +184,6 @@ class ProtocolTest(TestCase):
self.assertFalse(ExplicitEnableFake.is_enabled_to(Fake))
self.assertFalse(ExplicitEnableFake.is_enabled_to(Web))
def test_is_enabled_to_user_allowlist(self):
self.assertFalse(ATProto.is_enabled_to(ActivityPub, user='unknown'))
self.assertTrue(ATProto.is_enabled_to(ActivityPub, user='snarfed.org'))
user = Fake(id='did:plc:fdme4gb7mu7zrie7peay7tst')
self.assertTrue(ATProto.is_enabled_to(ActivityPub, user=user))
self.assertTrue(ATProto.is_enabled_to(ActivityPub, user=user.key.id()))
def test_is_enabled_to_opt_out(self):
user = self.make_user('user.com', cls=Web)
self.assertTrue(Web.is_enabled_to(ActivityPub, user))