From 8d6f9957c0f0357b89608ee88484385b73db69c0 Mon Sep 17 00:00:00 2001 From: Marnanel Thurman Date: Thu, 12 Sep 2019 17:50:37 +0100 Subject: [PATCH] if no actor is passed to kepi-post, fail --- django_kepi/management/commands/kepi-post.py | 25 +++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/django_kepi/management/commands/kepi-post.py b/django_kepi/management/commands/kepi-post.py index 556e122..ce7c4f6 100644 --- a/django_kepi/management/commands/kepi-post.py +++ b/django_kepi/management/commands/kepi-post.py @@ -24,9 +24,16 @@ class Command(KepiCommand): super().handle(*args, **options) + actor = self._actor + if actor is None: + self.stdout.write(self.style.ERROR( + 'You need to specify an actor, using --actor .', + )) + return + note = create(value={ 'type': 'Note', - 'attributedTo': self._actor, + 'attributedTo': actor, 'to': self._actor['followers'], 'cc': 'https://www.w3.org/ns/activitystreams#Public', 'content': options['text'], @@ -35,11 +42,17 @@ class Command(KepiCommand): ) logger.info('Note created: %s', note) + if note is None: + self.stdout.write(self.style.WARNING( + 'No note was created. (Try --debug-mode to discover why.)', + )) + return + creation = create(value={ 'type': 'Create', - 'actor': self._actor, + 'actor': actor, 'object': note, - 'to': self._actor['followers'], + 'to': actor['followers'], 'cc': 'https://www.w3.org/ns/activitystreams#Public', }, is_local_user=True, @@ -48,4 +61,10 @@ class Command(KepiCommand): ) logger.info('Create created: %s', creation) + if creation is None: + self.stdout.write(self.style.WARNING( + 'No creation activity was created. (Try --debug-mode to discover why.)', + )) + return + self.stdout.write('Created: %s' % (note,))