This commit is contained in:
Thomas Sileo 2018-07-29 16:40:33 +02:00
parent 55ff15ff86
commit 5da27d9820
3 changed files with 14 additions and 2 deletions

View file

@ -26,6 +26,7 @@ services:
environment: environment:
- MICROBLOGPUB_AMQP_BROKER=pyamqp://guest@rmq// - MICROBLOGPUB_AMQP_BROKER=pyamqp://guest@rmq//
- MICROBLOGPUB_MONGODB_HOST=mongo:27017 - MICROBLOGPUB_MONGODB_HOST=mongo:27017
- MICROBLOGPUB_DEBUG=1
mongo: mongo:
image: "mongo:latest" image: "mongo:latest"
rmq: rmq:

View file

@ -35,6 +35,17 @@ SigAuth = HTTPSigAuth(KEY)
back = activitypub.MicroblogPubBackend() back = activitypub.MicroblogPubBackend()
ap.use_backend(back) 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) MY_PERSON = ap.Person(**ME)
@ -327,7 +338,7 @@ def finish_post_to_outbox(self, iri: str) -> None:
activity = ap.fetch_remote_activity(iri) activity = ap.fetch_remote_activity(iri)
log.info(f"activity={activity!r}") 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) back.outbox_delete(MY_PERSON, activity)
elif activity.has_type(ap.ActivityType.UPDATE): elif activity.has_type(ap.ActivityType.UPDATE):
back.outbox_update(MY_PERSON, activity) back.outbox_update(MY_PERSON, activity)

View file

@ -19,7 +19,7 @@ class Instance(object):
def __init__(self, name, host_url, docker_url=None): def __init__(self, name, host_url, docker_url=None):
self.host_url = host_url self.host_url = host_url
self.docker_url = docker_url or host_url self.docker_url = docker_url or host_url
self._create_delay = 12 self._create_delay = 20
with open( with open(
os.path.join( os.path.join(
os.path.dirname(os.path.abspath(__file__)), os.path.dirname(os.path.abspath(__file__)),