diff --git a/django_kepi/models/activity.py b/django_kepi/models/activity.py index c7b2440..af13ccf 100644 --- a/django_kepi/models/activity.py +++ b/django_kepi/models/activity.py @@ -17,7 +17,7 @@ class Activity(thing.Object): if not self.is_local: return - actor = self['actor__obj'] + actor = self['actor__find'] logger.info('%s: going into %s\'s outbox', self.number, @@ -59,7 +59,7 @@ class Delete(Activity): pass class Follow(Activity): - _explicit_object_field = True + pass class Add(Activity): pass diff --git a/django_kepi/models/thing.py b/django_kepi/models/thing.py index 20434e5..4a80f0e 100644 --- a/django_kepi/models/thing.py +++ b/django_kepi/models/thing.py @@ -200,9 +200,11 @@ class Object(PolymorphicModel): except ThingField.DoesNotExist: result = None - if 'obj' in name_parts and result is not None: + if 'find' in name_parts and result is not None: result = find(result, do_not_fetch=True) + elif 'obj' in name_parts and result is not None: + result = Object.get_by_url(url=result) return result @@ -323,6 +325,32 @@ class Object(PolymorphicModel): self.number = _new_number() return self.save(*args, **kwargs) + @classmethod + def get_by_url(cls, url): + """ + Retrieves an Object whose URL is "url". + + This differs from find() in that it can + find objects which were submitted to us over HTTP + (as opposed to generated locally or fetched by us). + find() would ignore these. + """ + + from django_kepi.find import find + + result = find(url, + local_only = True) + + if result is None: + try: + result = cls.objects.get( + remote_url = url, + ) + except cls.DoesNotExist: + result = None + + return result + ###################################### def _normalise_type_for_thing(v):