From fad290e91d1dc2ffbb1f7ca64883dd4dfaeb1eb4 Mon Sep 17 00:00:00 2001 From: Her Email Date: Sat, 18 Nov 2023 11:13:26 -0500 Subject: [PATCH] sync identity from takahe on first fetch --- neodb-takahe | 2 +- requirements-dev.txt | 4 ++-- takahe/ap_handlers.py | 31 ++++++++++--------------------- takahe/models.py | 2 +- 4 files changed, 14 insertions(+), 25 deletions(-) diff --git a/neodb-takahe b/neodb-takahe index aecd5006..4b434ff4 160000 --- a/neodb-takahe +++ b/neodb-takahe @@ -1 +1 @@ -Subproject commit aecd500619beff9c848ff041fff6cfa54fe8211b +Subproject commit 4b434ff4a53d162e4caca0880d9827289ccac0f3 diff --git a/requirements-dev.txt b/requirements-dev.txt index 599aa6fe..50a86089 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -2,8 +2,8 @@ black~=22.12.0 coverage django-debug-toolbar django-stubs -djlint~=1.32.1 +djlint~=1.34.0 isort~=5.12.0 lxml-stubs pre-commit -pyright==1.1.333 +pyright==1.1.336 diff --git a/takahe/ap_handlers.py b/takahe/ap_handlers.py index 45e5c659..212a1a1d 100644 --- a/takahe/ap_handlers.py +++ b/takahe/ap_handlers.py @@ -108,24 +108,13 @@ def post_deleted(pk, obj): Piece.objects.filter(posts__id=pk, local=False).delete() -def user_follow_updated(source_identity_pk, target_identity_pk): - u = Takahe.get_local_user_by_identity(source_identity_pk) - # Takahe.update_user_following(u) - logger.info(f"User {u} following updated") - - -def user_mute_updated(source_identity_pk, target_identity_pk): - u = Takahe.get_local_user_by_identity(source_identity_pk) - # Takahe.update_user_muting(u) - logger.info(f"User {u} muting updated") - - -def user_block_updated(source_identity_pk, target_identity_pk): - u = Takahe.get_local_user_by_identity(source_identity_pk) - if u: - # Takahe.update_user_rejecting(u) - logger.info(f"User {u} rejecting updated") - u = Takahe.get_local_user_by_identity(target_identity_pk) - if u: - # Takahe.update_user_rejecting(u) - logger.info(f"User {u} rejecting updated") +def identity_fetched(pk): + identity = Takahe.get_identity(pk) + if identity.username and identity.domain: + apid = Takahe.get_or_create_remote_apidentity(identity) + if apid: + logger.debug(f"Identity {identity} synced") + else: + logger.warning(f"Identity {identity} not synced") + else: + logger.warning(f"Identity {identity} has no username or domain") diff --git a/takahe/models.py b/takahe/models.py index ed0c08f8..4b82b59c 100644 --- a/takahe/models.py +++ b/takahe/models.py @@ -361,7 +361,7 @@ class Identity(models.Model): Represents both local and remote Fediverse identities (actors) """ - domain_id: int + domain_id: str class Restriction(models.IntegerChoices): none = 0