mirror of https://gitlab.com/bashrc2/epicyon
Handle brid.gy urls
parent
6b1d322663
commit
29d4f68fd5
16
tests.py
16
tests.py
|
@ -8971,6 +8971,21 @@ def _test_link_tracking() -> None:
|
|||
assert remove_link_trackers_from_content(content) == expected
|
||||
|
||||
|
||||
def _test_bridgy() -> None:
|
||||
print('bridgy')
|
||||
bridgy_url = \
|
||||
'https://brid.gy/convert/ap/at://' + \
|
||||
'did:plc:dcbhwedfgwuyfgwfnj/app.bsky.feed.post/fchbuiweefwui'
|
||||
nickname = get_nickname_from_actor(bridgy_url)
|
||||
if nickname != 'did:plc:dcbhwedfgwuyfgwfnj':
|
||||
print('nickname: ' + nickname)
|
||||
assert nickname == 'did:plc:dcbhwedfgwuyfgwfnj'
|
||||
domain, _ = get_domain_from_actor(bridgy_url)
|
||||
if domain != 'brid.gy':
|
||||
print('domain: ' + domain)
|
||||
assert domain == 'brid.gy'
|
||||
|
||||
|
||||
def run_all_tests():
|
||||
base_dir = os.getcwd()
|
||||
data_dir_testing(base_dir)
|
||||
|
@ -8989,6 +9004,7 @@ def run_all_tests():
|
|||
_test_checkbox_names()
|
||||
_test_thread_functions()
|
||||
_test_functions()
|
||||
_test_bridgy()
|
||||
_test_link_tracking()
|
||||
_test_remove_tags()
|
||||
_test_check_individual_post_content()
|
||||
|
|
8
utils.py
8
utils.py
|
@ -1508,7 +1508,7 @@ def _get_statuses_list() -> []:
|
|||
'/note/', '/notes/', '/comment/', '/post/', '/item/', '/videos/',
|
||||
'/button/', '/x/', '/o/', '/posts/', '/items/', '/object/', '/r/',
|
||||
'/content/', '/federation/', '/elsewhere/', '/article/',
|
||||
'/activity/', '/blog/')
|
||||
'/activity/', '/blog/', '/app.bsky.feed.post/')
|
||||
|
||||
|
||||
def contains_statuses(url: str) -> bool:
|
||||
|
@ -1701,6 +1701,10 @@ def get_nickname_from_actor(actor: str) -> str:
|
|||
"""
|
||||
if actor.startswith('@'):
|
||||
actor = actor[1:]
|
||||
|
||||
# handle brid.gy urls
|
||||
actor = actor.replace('at://did:', 'did:')
|
||||
|
||||
users_paths = get_user_paths()
|
||||
for possible_path in users_paths:
|
||||
if possible_path not in actor:
|
||||
|
@ -1741,7 +1745,7 @@ def get_user_paths() -> []:
|
|||
'/nieuws/author/', '/author/', '/federation/user/',
|
||||
'/activitypub/', '/actors/', '/snac/', '/@/', '/~/',
|
||||
'/fediverse/blog/', '/user/', '/@', '/api/collections/',
|
||||
'/feed/', '/actor/')
|
||||
'/feed/', '/actor/', '/ap/')
|
||||
|
||||
|
||||
def get_group_paths() -> []:
|
||||
|
|
Loading…
Reference in New Issue