give new unlinked users award immunity in rdrama

pull/157/head
Aevann 2023-06-23 14:37:22 +03:00
parent cc9274c843
commit 2452f94231
6 changed files with 28 additions and 8 deletions

View File

@ -312,6 +312,11 @@ class User(Base):
if user_forced_hats: return random.choice(user_forced_hats)
else: return None
@property
@lazy
def new_user(self):
return self.age < NEW_USER_AGE
@lazy
def hat_active(self, v):
if FEATURES['HATS']:
@ -325,7 +330,7 @@ class User(Base):
if self.is_cakeday:
return ('/i/hats/Cakeday.webp', "I've spent another year rotting my brain with dramaposting, please ridicule me 🤓")
if self.age < NEW_USER_HAT_AGE:
if self.new_user:
return ('/i/new-user.webp', "Hi, I'm new here! Please be gentle :)")
if self.forced_hat:
@ -337,6 +342,22 @@ class User(Base):
return ('', '')
@lazy
def immune_to_awards(self, v):
if SITE_NAME != 'rDrama':
return False
if v.id == self.id:
return False
if v.admin_level >= PERMS['IGNORE_AWARD_IMMUNITY']:
return False
if self.alts:
return False
if self.id in IMMUNE_TO_AWARDS:
return True
if self.new_user:
return True
return False
@property
@lazy
def name_color(self):

View File

@ -652,7 +652,7 @@ TRUESCORE_RESTRICTED_HOLES_MINIMUM = 100
LOGGEDIN_ACTIVE_TIME = 15 * 60
PFP_DEFAULT_MARSEY = True
NEW_USER_HAT_AGE = 0 # seconds of age to show new-user forced hat
NEW_USER_AGE = 7 * 86400
NOTIFICATION_SPAM_AGE_THRESHOLD = 0
COMMENT_SPAM_LENGTH_THRESHOLD = 0
UNDER_SIEGE_AGE_THRESHOLD = 10 * 60
@ -783,7 +783,6 @@ if SITE == 'rdrama.net':
TRUESCORE_CHAT_MINIMUM = 10
TRUESCORE_GHOST_MINIMUM = 10
NEW_USER_HAT_AGE = 7 * 86400
HOLE_COST = 50000
HOLE_INACTIVITY_DELETION = True

View File

@ -176,7 +176,7 @@ def award_thing(v, thing_type, id):
safe_username = f"@{thing.author_name}"
if SITE == 'rdrama.net' and author.id in IMMUNE_TO_AWARDS and v.admin_level < PERMS["IGNORE_AWARD_IMMUNITY"]:
if author.immune_to_awards(v):
abort(403, f"{safe_username} is immune to awards!")
if kind == "benefactor" and author.id == v.id:

View File

@ -386,7 +386,7 @@
<button type="button" class="btn caction py-0 nobackground px-1 text-muted" data-bs-toggle="modal" data-bs-target="#reportCommentModal" data-nonce="{{g.nonce}}" data-onclick="report_commentModal('{{c.id}}','{{c.author_name}}',)"><i class="fas fa-flag fa-fw"></i>Report</button>
{% if FEATURES['AWARDS'] -%}
<button type="button" class="btn caction py-0 nobackground px-1 text-muted" data-bs-toggle="modal" data-bs-target="#awardModal" data-url="/award/comment/{{c.id}}" data-nonce="{{g.nonce}}" {% if c.author_id in IMMUNE_TO_AWARDS and v.admin_level < PERMS['IGNORE_AWARD_IMMUNITY'] %}disabled{% endif %}><i class="fas fa-gift"></i>Give Award</button>
<button type="button" class="btn caction py-0 nobackground px-1 text-muted" data-bs-toggle="modal" data-bs-target="#awardModal" data-url="/award/comment/{{c.id}}" data-nonce="{{g.nonce}}" {% if c.author.immune_to_awards(v) %}disabled{% endif %}><i class="fas fa-gift"></i>Give Award</button>
{%- endif %}
<button type="button" id="unsave-{{c.id}}" class="btn caction py-0 nobackground px-1 {% if c.id in v.saved_comment_idlist %}d-md-inline-block{% endif %} text-muted d-none" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/unsave_comment/{{c.id}}','save-{{c.id}}','unsave-{{c.id}}','d-md-inline-block')"><i class="fas fa-save"></i>Unsave {% if c.num_savers %}<span data-bs-toggle="tooltip" data-bs-placement="bottom" title="Number of users who saved this comment">[{{c.num_savers}}]</span>{% endif %}</button>
@ -585,7 +585,7 @@
<button type="button" data-bs-toggle="modal" data-bs-dismiss="modal" data-bs-target="#reportCommentModal" data-nonce="{{g.nonce}}" data-onclick="report_commentModal('{{c.id}}','{{c.author_name}}')" class="list-group-item"><i class="fas fa-flag mr-2"></i>Report</button>
{% if FEATURES['AWARDS'] -%}
<button type="button" class="list-group-item" data-bs-toggle="modal" data-bs-target="#awardModal" data-url="/award/comment/{{c.id}}" data-nonce="{{g.nonce}}" {% if c.author_id in IMMUNE_TO_AWARDS and v.admin_level < PERMS['IGNORE_AWARD_IMMUNITY'] %}disabled{% endif %}><i class="fas fa-gift mr-2"></i>Give Award</button>
<button type="button" class="list-group-item" data-bs-toggle="modal" data-bs-target="#awardModal" data-url="/award/comment/{{c.id}}" data-nonce="{{g.nonce}}" {% if c.author.immune_to_awards(v) %}disabled{% endif %}><i class="fas fa-gift mr-2"></i>Give Award</button>
{%- endif %}
<button type="button" id="save2-{{c.id}}" class="list-group-item {% if c.id in v.saved_comment_idlist %}d-none{% endif %}" data-bs-dismiss="modal" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/save_comment/{{c.id}}','save2-{{c.id}}','unsave2-{{c.id}}','d-none')"><i class="fas fa-save mr-2"></i>Save {% if c.num_savers %}<span data-bs-toggle="tooltip" data-bs-placement="bottom" title="Number of users who saved this comment">[{{c.num_savers}}]</span>{% endif %}</button>

View File

@ -11,7 +11,7 @@
{% endif %}
{% if v and FEATURES['AWARDS'] %}
<button type="button" class="list-inline-item d-none d-md-inline-block" data-bs-toggle="modal" data-bs-target="#awardModal" data-url='/award/post/{{p.id}}' data-nonce="{{g.nonce}}" {% if p.author_id in IMMUNE_TO_AWARDS and v.admin_level < PERMS['IGNORE_AWARD_IMMUNITY'] %}disabled{% endif %}><i class="fas fa-gift fa-fw"></i>Give Award</button>
<button type="button" class="list-inline-item d-none d-md-inline-block" data-bs-toggle="modal" data-bs-target="#awardModal" data-url='/award/post/{{p.id}}' data-nonce="{{g.nonce}}" {% if p.author.immune_to_awards(v) %}disabled{% endif %}><i class="fas fa-gift fa-fw"></i>Give Award</button>
{% endif %}
<button type="button" class="list-inline-item copy-link" data-clipboard-text="{% if SITE == 'rdrama.net' %}{{SITE_FULL}}{{p.shortlink}}{% else %}{{p.permalink}}{% endif %}"><i class="fas fa-copy"></i>Copy link</button>

View File

@ -17,7 +17,7 @@
<button type="button" class="nobackground btn btn-link btn-block btn-lg text-left text-muted" data-bs-toggle="modal" data-bs-dismiss="modal" data-bs-target="#reportPostModal" data-nonce="{{g.nonce}}" data-onclick="report_postModal('{{p.id}}')"><i class="far fa-flag text-center text-muted mr-2"></i>Report</button>
{% if FEATURES['AWARDS'] -%}
<button type="button" class="nobackground btn btn-link btn-block btn-lg text-left text-muted" data-bs-toggle="modal" data-bs-dismiss="modal" data-bs-target="#awardModal" data-url='/award/post/{{p.id}}' data-nonce="{{g.nonce}}" {% if p.author_id in IMMUNE_TO_AWARDS and v.admin_level < PERMS['IGNORE_AWARD_IMMUNITY'] %}disabled{% endif %}><i class="fas fa-gift text-center text-muted mr-2"></i>Give Award</button>
<button type="button" class="nobackground btn btn-link btn-block btn-lg text-left text-muted" data-bs-toggle="modal" data-bs-dismiss="modal" data-bs-target="#awardModal" data-url='/award/post/{{p.id}}' data-nonce="{{g.nonce}}" {% if p.author.immune_to_awards(v) %}disabled{% endif %}><i class="fas fa-gift text-center text-muted mr-2"></i>Give Award</button>
{%- endif %}
<button type="button" id="subscribe2-{{p.id}}" class="{% if p.id in v.subscribed_idlist %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-muted" data-areyousure="postToastSwitch(this,'/subscribe/{{p.id}}','subscribe2-{{p.id}}','unsubscribe2-{{p.id}}','d-none')" data-nonce="{{g.nonce}}" data-onclick="areyousure(this)" data-dismiss="modal"><i class="fas fa-bell text-center text-muted mr-2"></i>Subscribe {% if p.num_subscribers %}<span data-bs-toggle="tooltip" data-bs-placement="bottom" title="Number of subscribers">[{{p.num_subscribers}}]</span>{% endif %}</button>