26 lines
968 B
Python
Raw Normal View History

# -*- coding: utf-8 -*-
import arrow
from . import utils
def compose_toot(toot, db, relative_times, show_screen_names):
if show_screen_names == False:
user = toot.account.get("display_name")
else:
user = toot.account.get("acct")
original_date = arrow.get(toot.created_at)
if relative_times:
ts = original_date.humanize(locale="es")
else:
ts = original_date.shift(hours=db["utc_offset"]).format(_("dddd, MMMM D, YYYY H:m:s"), locale="es")
if toot.reblog != None:
2022-11-08 08:59:09 -06:00
text = _("Boosted from @{}: {}").format(toot.reblog.account.acct, utils.html_filter(toot.reblog.content))
else:
text = utils.html_filter(toot.content)
source = toot.get("application", "")
2022-11-08 08:59:09 -06:00
# "" means remote user, None for legacy apps so we should cover both sides.
if source != None and source != "":
source = source.get("name", "")
2022-11-08 08:59:09 -06:00
else:
source = ""
return [user+", ", text, ts+", ", source]