diff --git a/fedireads/incoming.py b/fedireads/incoming.py index 3167031d..4daaf709 100644 --- a/fedireads/incoming.py +++ b/fedireads/incoming.py @@ -86,9 +86,9 @@ def shared_inbox(request): def get_public_key(key_actor): try: - user = models.User.objects.get(actor=key_actor) + user = models.User.objects.get(remote_id=key_actor) public_key = user.public_key - actor = user.actor + actor = user.remote_id except models.User.DoesNotExist: response = requests.get( key_actor, @@ -149,7 +149,7 @@ def handle_follow(activity): # figure out who they want to follow -- not using get_or_create because # we only allow you to follow local users try: - to_follow = models.User.objects.get(actor=activity['object']) + to_follow = models.User.objects.get(remote_id=activity['object']) except models.User.DoesNotExist: return False # figure out who the actor is @@ -189,7 +189,7 @@ def handle_unfollow(activity): obj = activity['object'] try: requester = get_or_create_remote_user(obj['actor']) - to_unfollow = models.User.objects.get(actor=obj['object']) + to_unfollow = models.User.objects.get(remote_id=obj['object']) except models.User.DoesNotExist: return False @@ -200,7 +200,7 @@ def handle_unfollow(activity): def handle_follow_accept(activity): ''' hurray, someone remote accepted a follow request ''' # figure out who they want to follow - requester = models.User.objects.get(actor=activity['object']['actor']) + requester = models.User.objects.get(remote_id=activity['object']['actor']) # figure out who they are accepter = get_or_create_remote_user(activity['actor']) @@ -218,7 +218,7 @@ def handle_follow_accept(activity): @app.task def handle_follow_reject(activity): ''' someone is rejecting a follow request ''' - requester = models.User.objects.get(actor=activity['object']['actor']) + requester = models.User.objects.get(remote_id=activity['object']['actor']) rejecter = get_or_create_remote_user(activity['actor']) try: diff --git a/fedireads/models/base_model.py b/fedireads/models/base_model.py index a90312f4..14273407 100644 --- a/fedireads/models/base_model.py +++ b/fedireads/models/base_model.py @@ -22,10 +22,10 @@ class FedireadsModel(models.Model): abstract = True -@receiver(models.signals.post_save, sender=FedireadsModel) +@receiver(models.signals.post_save) def execute_after_save(sender, instance, created, *args, **kwargs): ''' set the remote_id after save (when the id is available) ''' - if not created: + if not created or not hasattr(instance, 'get_remote_id'): return instance.remote_id = instance.get_remote_id() instance.save() diff --git a/fedireads/tests/test_signing.py b/fedireads/tests/test_signing.py index 6cb69f16..6bf9b7e6 100644 --- a/fedireads/tests/test_signing.py +++ b/fedireads/tests/test_signing.py @@ -14,7 +14,7 @@ from fedireads.broadcast import make_signature from fedireads.activitypub import get_follow_request from fedireads.settings import DOMAIN -Sender = namedtuple('Sender', ('actor', 'private_key', 'public_key')) +Sender = namedtuple('Sender', ('remote_id', 'private_key', 'public_key')) class Signature(TestCase): def setUp(self): @@ -67,7 +67,7 @@ class Signature(TestCase): def test_remote_signer(self): responses.add( responses.GET, - self.fake_remote.actor, + self.fake_remote.remote_id, json={'publicKey': { 'publicKeyPem': self.fake_remote.public_key }}, @@ -82,7 +82,7 @@ class Signature(TestCase): def test_nonexistent_signer(self): responses.add( responses.GET, - self.fake_remote.actor, + self.fake_remote.remote_id, json={'error': 'not found'}, status=404)