Show new account status on recently created profiles

This may help with detecting spammers or trolls
main
Bob Mottram 2024-02-16 11:29:02 +00:00
parent 4e78dcf9fe
commit a6eb5ae044
2 changed files with 20 additions and 2 deletions

View File

@ -3493,6 +3493,17 @@ def media_file_mime_type(filename: str) -> str:
return extensions[file_ext]
def time_days_ago(datestr: str) -> int:
"""returns the number of days ago for the given date
"""
date1 = \
date_from_string_format(datestr,
["%Y-%m-%dT%H:%M:%S%z"])
if not date1:
return 0
return (date1 - date_epoch()).days
def is_recent_post(post_json_object: {}, max_days: int) -> bool:
""" Is the given post recent?
"""

View File

@ -10,6 +10,7 @@ __module_group__ = "Web Interface"
import os
from pprint import pprint
from webfinger import webfinger_handle
from utils import time_days_ago
from utils import uninvert_text
from utils import get_attributed_to
from utils import get_url_from_post
@ -662,8 +663,11 @@ def _get_profile_header(base_dir: str, http_prefix: str, nickname: str,
' <p><b>@' + nickname + '@' + domain_full + \
actor_proxied + acct_blog_str + '</b><br>\n'
if joined_date:
joined_str = translate['Joined']
if time_days_ago(joined_date) < 7:
joined_str = '<b>' + translate['New account'] + '</b>'
html_str += \
' <p>' + translate['Joined'] + ' ' + \
' <p>' + joined_str + ' ' + \
joined_date.split('T')[0] + '<br>\n'
if moved_to:
new_nickname = get_nickname_from_actor(moved_to)
@ -816,7 +820,10 @@ def _get_profile_header_after_search(base_dir: str,
' <p><b>@' + search_nickname + '@' + search_domain_full + \
actor_proxied + '</b><br>\n'
if joined_date:
html_str += ' <p>' + translate['Joined'] + ' ' + \
joined_str = translate['Joined']
if time_days_ago(joined_date) < 7:
joined_str = '<b>' + translate['New account'] + '</b>'
html_str += ' <p>' + joined_str + ' ' + \
joined_date.split('T')[0] + '</p>\n'
if follows_you:
if not you_follow: