mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-23 03:38:08 -06:00
Mastodon: Added compose function for notifications
This commit is contained in:
parent
e63479a261
commit
4bf155b421
@ -48,6 +48,7 @@ speech_reporting = boolean(default=True)
|
|||||||
post = string(default="$display_name, $safe_text $image_descriptions $date. $visibility. $source")
|
post = string(default="$display_name, $safe_text $image_descriptions $date. $visibility. $source")
|
||||||
person = string(default="$display_name (@$screen_name). $followers followers, $following following, $posts posts. Joined $created_at.")
|
person = string(default="$display_name (@$screen_name). $followers followers, $following following, $posts posts. Joined $created_at.")
|
||||||
conversation = string(default="Conversation with $users. Last message: $last_post")
|
conversation = string(default="Conversation with $users. Last message: $last_post")
|
||||||
|
notification = string(default="$display_name $text, $date")
|
||||||
|
|
||||||
[filters]
|
[filters]
|
||||||
|
|
||||||
|
@ -49,3 +49,30 @@ def compose_conversation(conversation, db, relative_times, show_screen_names):
|
|||||||
last_post = compose_post(conversation.last_status, db, relative_times, show_screen_names)
|
last_post = compose_post(conversation.last_status, db, relative_times, show_screen_names)
|
||||||
text = _("Last message from {}: {}").format(last_post[0], last_post[1])
|
text = _("Last message from {}: {}").format(last_post[0], last_post[1])
|
||||||
return [users, text, last_post[-2], last_post[-1]]
|
return [users, text, last_post[-2], last_post[-1]]
|
||||||
|
|
||||||
|
def compose_notification(notification, db, relative_times, show_screen_names):
|
||||||
|
if show_screen_names == False:
|
||||||
|
user = notification.account.get("display_name")
|
||||||
|
if user == "":
|
||||||
|
user = notification.account.get("username")
|
||||||
|
else:
|
||||||
|
user = notification.account.get("acct")
|
||||||
|
original_date = arrow.get(notification.created_at)
|
||||||
|
if relative_times:
|
||||||
|
ts = original_date.humanize(locale=languageHandler.curLang[:2])
|
||||||
|
else:
|
||||||
|
ts = original_date.shift(hours=db["utc_offset"]).format(_("dddd, MMMM D, YYYY H:m"), locale=languageHandler.curLang[:2])
|
||||||
|
text = "Unknown: %r" % (notification)
|
||||||
|
if notification.type == "mention":
|
||||||
|
text = _("{username} has mentionned you: {status}").format(username=user, status=",".join(compose_post(notification.status, db, relative_times, show_screen_names)))
|
||||||
|
elif notification.type == "reblog":
|
||||||
|
text = _("{username} has boosted: {status}").format(username=user, status=",".join(compose_post(notification.status, db, relative_times, show_screen_names)))
|
||||||
|
elif notification.type == "favourite":
|
||||||
|
text = _("{username} has added to favorites: {status}").format(username=user, status=",".join(compose_post(notification.status, db, relative_times, show_screen_names)))
|
||||||
|
elif notification.type == "follow":
|
||||||
|
text = _("{username} has followed you.").format(username=user)
|
||||||
|
elif notification.type == "poll":
|
||||||
|
text = _("A poll in which you have voted has expired: {status}").format(status=",".join(compose_post(notification.status, db, relative_times, show_screen_names)))
|
||||||
|
elif notification.type == "follow_request":
|
||||||
|
text = _("{username} wants to follow you.").format(username=user)
|
||||||
|
return [user, text, ts]
|
Loading…
Reference in New Issue
Block a user