show username when a toot is CWed

This commit is contained in:
jesopo 2019-11-27 15:16:46 +00:00
parent 038d6841f1
commit f62fc8c2a1
2 changed files with 11 additions and 11 deletions

View file

@ -97,20 +97,19 @@ class Module(ModuleManager.BaseModule):
type = note["type"] type = note["type"]
note = note["object"] note = note["object"]
cw, out, url = ap_utils.format_note(actor, note, type) cw, author, content, url = ap_utils.parse_note(actor, note, type)
shorturl = self.exports.get_one("shorturl")(event["server"], url, shorturl = self.exports.get_one("shorturl")(event["server"], url,
context=event["target"]) context=event["target"])
if cw: if cw:
if strict_cw: if strict_cw:
out = "CW: %s - %s" % (cw, shorturl) out = "%s: CW %s - %s" % (author, cw, shorturl)
else: else:
out = "(CW %s) %s - %s" % (cw, out, shorturl) out = "(CW %s) %s: %s - %s" % (cw, author, content, shorturl)
else: else:
out = "%s - %s" % (out, shorturl) out = "%s: %s - %s" % (author, content, shorturl)
event["stdout"].write(out) event["stdout"].write(out)
def _get_from_outbox(self, username, instance): def _get_from_outbox(self, username, instance):
try: try:
actor_url = ap_utils.find_actor(username, instance) actor_url = ap_utils.find_actor(username, instance)

View file

@ -123,7 +123,7 @@ def _content(note):
return "<%s>" % filename return "<%s>" % filename
def format_note(actor, note, type="Create"): def parse_note(actor, note, type="Create"):
if type == "Announce": if type == "Announce":
retoot_url = note retoot_url = note
retoot_instance = urllib.parse.urlparse(retoot_url).hostname retoot_instance = urllib.parse.urlparse(retoot_url).hostname
@ -135,14 +135,15 @@ def format_note(actor, note, type="Create"):
retooted_user = "@%s@%s" % (original_tooter.username, retoot_instance) retooted_user = "@%s@%s" % (original_tooter.username, retoot_instance)
retoot_content = _content(retoot) retoot_content = _content(retoot)
return (retoot.get("summary", None), "%s (boost %s): %s" % ( author = "%s (boost %s)" % (actor.username, retooted_user)
actor.username, retooted_user, retoot_content), retoot_url)
return (retoot.get("summary", None), author, retoot_content, retoot_url)
elif type == "Create": elif type == "Create":
content = _content(note) content = _content(note)
url = note.get("url", note["id"]) url = note.get("url", note["id"])
return (note.get("summary", None), return note.get("summary", None), actor.username, content, url
"%s: %s" % (actor.username, content), url)
return None, None, None return None