diff --git a/docker-compose-tests.yml b/docker-compose-tests.yml index 280f6c3..eae4264 100644 --- a/docker-compose-tests.yml +++ b/docker-compose-tests.yml @@ -26,6 +26,7 @@ services: environment: - MICROBLOGPUB_AMQP_BROKER=pyamqp://guest@rmq// - MICROBLOGPUB_MONGODB_HOST=mongo:27017 + - MICROBLOGPUB_DEBUG=1 mongo: image: "mongo:latest" rmq: diff --git a/tasks.py b/tasks.py index 6cad65b..6de6575 100644 --- a/tasks.py +++ b/tasks.py @@ -35,6 +35,17 @@ SigAuth = HTTPSigAuth(KEY) back = activitypub.MicroblogPubBackend() ap.use_backend(back) + +def save_cb(box: Box, iri: str) -> None: + if box == Box.INBOX: + process_new_activity.delay(iri) + else: + cache_actor.delay(iri) + + +back.set_save_cb(save_cb) + + MY_PERSON = ap.Person(**ME) @@ -327,7 +338,7 @@ def finish_post_to_outbox(self, iri: str) -> None: activity = ap.fetch_remote_activity(iri) log.info(f"activity={activity!r}") - if activity.has_type(ap.activitytype.delete): + if activity.has_type(ap.ActivityType.DELETE): back.outbox_delete(MY_PERSON, activity) elif activity.has_type(ap.ActivityType.UPDATE): back.outbox_update(MY_PERSON, activity) diff --git a/tests/federation_test.py b/tests/federation_test.py index 20569bb..5ab8e51 100644 --- a/tests/federation_test.py +++ b/tests/federation_test.py @@ -19,7 +19,7 @@ class Instance(object): def __init__(self, name, host_url, docker_url=None): self.host_url = host_url self.docker_url = docker_url or host_url - self._create_delay = 12 + self._create_delay = 20 with open( os.path.join( os.path.dirname(os.path.abspath(__file__)),