mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-29 22:23:12 -06:00
If user has no display_name set, let's show mastodon username instead
This commit is contained in:
parent
ca39db649b
commit
33647da6e8
@ -5,6 +5,8 @@ from . import utils
|
|||||||
def compose_toot(toot, db, relative_times, show_screen_names):
|
def compose_toot(toot, db, relative_times, show_screen_names):
|
||||||
if show_screen_names == False:
|
if show_screen_names == False:
|
||||||
user = toot.account.get("display_name")
|
user = toot.account.get("display_name")
|
||||||
|
if user == "":
|
||||||
|
user = toot.account.get("username")
|
||||||
else:
|
else:
|
||||||
user = toot.account.get("acct")
|
user = toot.account.get("acct")
|
||||||
original_date = arrow.get(toot.created_at)
|
original_date = arrow.get(toot.created_at)
|
||||||
@ -30,4 +32,7 @@ def compose_user(user, db, relative_times=True):
|
|||||||
ts = original_date.humanize(locale="es")
|
ts = original_date.humanize(locale="es")
|
||||||
else:
|
else:
|
||||||
ts = original_date.shift(hours=db["utc_offset"]).format(_("dddd, MMMM D, YYYY H:m:s"), locale="es")
|
ts = original_date.shift(hours=db["utc_offset"]).format(_("dddd, MMMM D, YYYY H:m:s"), locale="es")
|
||||||
return [_("%s (@%s). %s followers, %s following, %s toots. Joined %s") % (user.display_name, user.acct, user.followers_count, user.following_count, user.statuses_count, ts)]
|
name = user.display_name
|
||||||
|
if name == "":
|
||||||
|
name = user.get("username")
|
||||||
|
return [_("%s (@%s). %s followers, %s following, %s toots. Joined %s") % (name, user.acct, user.followers_count, user.following_count, user.statuses_count, ts)]
|
||||||
|
@ -49,7 +49,10 @@ def render_toot(toot, template, relative_times=False, offset_hours=0):
|
|||||||
created_at = process_date(toot.created_at, relative_times, offset_hours)
|
created_at = process_date(toot.created_at, relative_times, offset_hours)
|
||||||
available_data.update(date=created_at)
|
available_data.update(date=created_at)
|
||||||
# user.
|
# user.
|
||||||
available_data.update(display_name=toot.account.display_name, screen_name=toot.account.acct)
|
display_name = toot.account.display_name
|
||||||
|
if display_name == "":
|
||||||
|
display_name = toot.account.username
|
||||||
|
available_data.update(display_name=display_name, screen_name=toot.account.acct)
|
||||||
# Source client from where tweet was originated.
|
# Source client from where tweet was originated.
|
||||||
source = ""
|
source = ""
|
||||||
if hasattr(toot, "application") and toot.application != None:
|
if hasattr(toot, "application") and toot.application != None:
|
||||||
@ -87,7 +90,10 @@ def render_person(user, template, relative_times=True, offset_hours=0):
|
|||||||
$created_at: The date and time that the user account was created on Twitter.
|
$created_at: The date and time that the user account was created on Twitter.
|
||||||
"""
|
"""
|
||||||
global person_variables
|
global person_variables
|
||||||
available_data = dict(display_name=user.display_name, screen_name=user.acct, followers=user.followers_count, following=user.following_count, favorites=user.favourites_count, toots=user.statuses_count)
|
display_name = user.display_name
|
||||||
|
if display_name == "":
|
||||||
|
display_name = user.username
|
||||||
|
available_data = dict(display_name=display_name, screen_name=user.acct, followers=user.followers_count, following=user.following_count, favorites=user.favourites_count, toots=user.statuses_count)
|
||||||
# Nullable values.
|
# Nullable values.
|
||||||
nullables = ["description"]
|
nullables = ["description"]
|
||||||
for nullable in nullables:
|
for nullable in nullables:
|
||||||
|
Loading…
Reference in New Issue
Block a user