From 397ab186f6232ef97e90ea633840b883a3f7e4a1 Mon Sep 17 00:00:00 2001 From: Aevann Date: Sat, 11 Mar 2023 09:11:58 +0200 Subject: [PATCH] hide a bunch of user customization on shadowbanned profiles --- files/classes/user.py | 10 ++++++-- files/templates/user_listing.html | 2 +- files/templates/userpage/banner.html | 32 +++++++++++++------------- files/templates/userpage/userpage.html | 4 ++-- files/templates/util/html_head.html | 2 +- 5 files changed, 28 insertions(+), 22 deletions(-) diff --git a/files/classes/user.py b/files/classes/user.py index ccb394c97..559c9c3ed 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -793,7 +793,7 @@ class User(Base): @property @lazy def banner_url(self): - if FEATURES['USERS_PROFILE_BANNER'] and self.bannerurl: + if FEATURES['USERS_PROFILE_BANNER'] and self.bannerurl and self.can_see_my_shit: return self.bannerurl return f"/i/{SITE_NAME}/site_preview.webp?v=3009" @@ -804,7 +804,7 @@ class User(Base): return f"{SITE_FULL}/e/chudsey.webp" if self.rainbow: return f"{SITE_FULL}/e/marseysalutepride.webp" - if self.profileurl: + if self.profileurl and self.can_see_my_shit: if self.profileurl.startswith('/'): return SITE_FULL + self.profileurl return self.profileurl return f"{SITE_FULL}/i/default-profile-pic.webp?v=1008" @@ -1207,3 +1207,9 @@ class User(Base): @lazy def can_toggle_event_music(self): return SITE_NAME != 'rDrama' or self.has_badge(91) + + @property + @lazy + def can_see_my_shit(self): + v = g.v + return not u.shadowbanned or (v and (v.id == u.id or v.can_see_shadowbanned)) diff --git a/files/templates/user_listing.html b/files/templates/user_listing.html index 70762a870..34371ddd7 100644 --- a/files/templates/user_listing.html +++ b/files/templates/user_listing.html @@ -32,7 +32,7 @@
Last active on
{%- endif %} - {% if FEATURES['USERS_PROFILE_BODYTEXT'] and not hide_bios and u.bio_html and (not u.shadowbanned or (v and (v.id == u.id or v.can_see_shadowbanned))) %} + {% if FEATURES['USERS_PROFILE_BODYTEXT'] and not hide_bios and u.bio_html and u.can_see_my_shit %}
{{u.bio_html | safe}}
{% endif %} diff --git a/files/templates/userpage/banner.html b/files/templates/userpage/banner.html index 9cd524650..7686d6dfc 100644 --- a/files/templates/userpage/banner.html +++ b/files/templates/userpage/banner.html @@ -13,10 +13,10 @@
- {% if FEATURES['PRONOUNS'] %} + {% if FEATURES['PRONOUNS'] and u.can_see_my_shit %}

{{u.pronouns}}

{% endif %} - {% if u.customtitle %} + {% if u.customtitle and u.can_see_my_shit %}

{{u.customtitle | safe}}

{% endif %} @@ -90,18 +90,18 @@
{% if FEATURES['USERS_PROFILE_BODYTEXT'] -%} - {% if u.bio_html and (not u.shadowbanned or (v and (v.id == u.id or v.can_see_shadowbanned))) %} + {% if u.bio_html and u.can_see_my_shit %}
{{u.bio_html | safe}}
{% else %}

No bio...

{% endif %} - {% if u.friends_html %} + {% if u.friends_html and u.can_see_my_shit %}

Friends:

{{u.friends_html | safe}}
{% endif %} - {% if u.enemies_html %} + {% if u.enemies_html and u.can_see_my_shit %}

Enemies:

{{u.enemies_html | safe}}
{% endif %} @@ -276,10 +276,10 @@
@@ -314,11 +314,11 @@ Follows you {% endif %} - {% if FEATURES['PRONOUNS'] %} + {% if FEATURES['PRONOUNS'] and u.can_see_my_shit %}

{{u.pronouns}}

{% endif %} - {% if u.customtitle %} + {% if u.customtitle and u.can_see_my_shit %}

{{u.customtitle | safe}}

{% endif %} @@ -351,16 +351,16 @@
{% if FEATURES['USERS_PROFILE_BODYTEXT'] -%} - {% if u.bio_html and (not u.shadowbanned or (v and (v.id == u.id or v.can_see_shadowbanned))) %} + {% if u.bio_html and u.can_see_my_shit %}
{{u.bio_html | safe}}
{% endif %} - {% if u.friends_html %} + {% if u.friends_html and u.can_see_my_shit %}

Friends:

{{u.friends_html | safe}}
{% endif %} - {% if u.enemies_html %} + {% if u.enemies_html and u.can_see_my_shit %}

Enemies:

{{u.enemies_html | safe}}
{% endif %} diff --git a/files/templates/userpage/userpage.html b/files/templates/userpage/userpage.html index 838f8b3aa..bb836a5ac 100644 --- a/files/templates/userpage/userpage.html +++ b/files/templates/userpage/userpage.html @@ -5,7 +5,7 @@ {% if u and u.profile_background %} {% endif %} - {% if u and (u.profilecss or u.profile_background) and not request.values.get('nocss') %} + {% if u and (u.profilecss or u.profile_background) and not request.values.get('nocss') and u.can_see_my_shit %} {% endif %} {% endblock %} @@ -27,7 +27,7 @@
{{u.username}}
{% endif %} -{% if not IS_FISTMAS() or SITE_NAME == 'WPD' %} +{% if (not IS_FISTMAS() or SITE_NAME == 'WPD') and u.can_see_my_shit %} {% endif %} {% endblock %} diff --git a/files/templates/util/html_head.html b/files/templates/util/html_head.html index 5b631fa1d..bbac0ffcb 100644 --- a/files/templates/util/html_head.html +++ b/files/templates/util/html_head.html @@ -50,7 +50,7 @@ {{0 if u.shadowbanned else u.real_comment_count(v)}} Comments {%- endif -%} - {% if u.bio and (not u.shadowbanned or (v and (v.id == u.id or v.can_see_shadowbanned))) %} + {% if u.bio and u.can_see_my_shit %} - {{u.bio}} {% endif %} {% endset %}