From 2f34a0debacce89fd38b229fd94408100c62bef3 Mon Sep 17 00:00:00 2001 From: James Ravenscroft Date: Sun, 20 Nov 2022 09:56:03 +0000 Subject: [PATCH] implement copying tags + hypothesis metadata --- hypopub.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hypopub.py b/hypopub.py index 48e520b..222d6e7 100644 --- a/hypopub.py +++ b/hypopub.py @@ -37,17 +37,22 @@ def send_micropub(entry: atoma.atom.AtomEntry): endpoint = os.getenv("MICROPUB_ENDPOINT") - session.post(f"{endpoint}", json={ + r = session.post(f"{endpoint}", json={ "type": ["h-entry"], "properties":{ "published": [entry.published.strftime("%Y-%m-%dT%H:%M:%S")], "content":[{ "html": entry.content.value }], - "in-reply-to": [annotation['target'][0]['source']] + "category": annotation['tags'] + ['hypothes.is'], + "in-reply-to": [annotation['target'][0]['source']], + "hypothesis-link": [json_link] } }) + if r.status_code > 300: + raise Exception(f"Request failed: {r.status_code}: {r.text}") + def main():