From 20656259e9fbc6105e9c93b409623f49f4e9e74a Mon Sep 17 00:00:00 2001 From: Thomas Sileo Date: Sat, 19 May 2018 09:10:27 +0200 Subject: [PATCH] Bugfix in the custom API --- app.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/app.py b/app.py index 70d0060..e7bd4c1 100644 --- a/app.py +++ b/app.py @@ -503,14 +503,24 @@ def new(): if tag['type'] == 'Mention': cc.append(tag['href']) - note = activitypub.Note( - cc=cc, - to=[to if to else config.AS_PUBLIC], - content=content, # TODO(tsileo): handle markdown - tag=tags, - source={'mediaType': 'text/markdown', 'content': source}, - inReplyTo=reply.id, - ) + if reply: + note = activitypub.Note( + cc=cc, + to=[to if to else config.AS_PUBLIC], + content=content, # TODO(tsileo): handle markdown + tag=tags, + source={'mediaType': 'text/markdown', 'content': source}, + inReplyTo=reply.id, # FIXME(tsieo): support None for inReplyTo? + ) + else: + note = activitypub.Note( + cc=cc, + to=[to if to else config.AS_PUBLIC], + content=content, # TODO(tsileo): handle markdown + tag=tags, + source={'mediaType': 'text/markdown', 'content': source}, + ) + create = note.build_create() print(create.to_dict()) create.post_to_outbox()