aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorGravatar jesopo2019-09-16 11:10:26 +0100
committerGravatar jesopo2019-09-16 11:10:49 +0100
commitcefbbe7c5fe3f33ed5248b96f2990d226b107942 (patch)
treed91d160d70873eea6a04a4c7467cc1e956acd45a /modules
parentuse `json_body=True` for ActivityPub requests (diff)
signature
return content warning from ap_utils.format_note and show it
closes #118
Diffstat (limited to 'modules')
-rw-r--r--modules/fediverse/__init__.py8
-rw-r--r--modules/fediverse/ap_utils.py9
2 files changed, 11 insertions, 6 deletions
diff --git a/modules/fediverse/__init__.py b/modules/fediverse/__init__.py
index ea16c5e9..25f87900 100644
--- a/modules/fediverse/__init__.py
+++ b/modules/fediverse/__init__.py
@@ -74,8 +74,12 @@ class Module(ModuleManager.BaseModule):
if not items:
raise utils.EventError("No toots found")
- out, url = ap_utils.format_note(actor, items[0])
+ cw, out, url = ap_utils.format_note(actor, items[0])
shorturl = self.exports.get_one("shorturl")(event["server"], url,
context=event["target"])
- out = "%s - %s" % (out, shorturl)
+
+ if not cw == None:
+ out = "CW: %s - %s" % (cw, shorturl)
+ else:
+ out = "%s - %s" % (out, shorturl)
event["stdout"].write(out)
diff --git a/modules/fediverse/ap_utils.py b/modules/fediverse/ap_utils.py
index a71692ed..d15ff243 100644
--- a/modules/fediverse/ap_utils.py
+++ b/modules/fediverse/ap_utils.py
@@ -67,13 +67,14 @@ def format_note(actor, note):
retooted_user = "@%s@%s" % (original_tooter.username, retoot_instance)
retoot_content = utils.http.strip_html(retoot.data["content"])
- return "%s (boost %s): %s - %s" % (
- actor.username, retooted_user, retoot_content), retoot_url
+ return (retoot.data.get("summary", None), "%s (boost %s): %s - %s" % (
+ actor.username, retooted_user, retoot_content), retoot_url)
elif note["type"] == "Create":
content = utils.http.strip_html(note["object"]["content"])
url = note["object"]["id"]
- return "%s: %s" % (actor.username, content), url
+ return (note["object"].get("summary", None),
+ "%s: %s" % (actor.username, content), url)
- return None, None
+ return None, None, None