allow ppl to disable purple notifs

pull/225/head
Aevann 2024-02-29 01:53:52 +02:00
parent 8e2dc4bd95
commit f6b67a52cb
7 changed files with 19 additions and 6 deletions

View File

@ -150,6 +150,7 @@ class User(Base):
grinch = Column(Boolean, default=SITE_NAME != 'rDrama') #don't put in an if condition, it will cause an error bc it has a not-null constraint
group_creation_notifs = Column(Boolean, default=False)
effortpost_notifs = Column(Boolean, default=False)
offsite_mentions = Column(Boolean)
if SITE_NAME == 'WPD' and not IS_LOCALHOST:
nitter = False
@ -561,7 +562,7 @@ class User(Base):
@property
@lazy
def can_view_offsite_mentions(self):
return self.has_badge(140) or self.admin_level >= PERMS['NOTIFICATIONS_OFFSITE']
return self.offsite_mentions or self.admin_level >= PERMS['NOTIFICATIONS_OFFSITE']
@lazy
def can_edit(self, target):

View File

@ -452,6 +452,7 @@ def award_thing(v, thing_type, id):
elif kind == "eye":
badge_grant(badge_id=83, user=author)
elif kind == "offsitementions":
author.offsite_mentions = True
badge_grant(user=author, badge_id=140)
elif kind == "alt":
badge_grant(badge_id=84, user=author)

View File

@ -268,7 +268,7 @@ def notifications_modactions(v):
@app.get("/notifications/offsite")
@app.get("/notifications/site_mentions")
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
@auth_required

View File

@ -186,8 +186,15 @@ def settings_personal_post(v):
if v.spider: badge_grant(user=v, badge_id=179)
else:
badge = v.has_badge(179)
if badge:
g.db.delete(badge)
if badge: g.db.delete(badge)
elif not updated and request.values.get("offsite_mentions", v.offsite_mentions) != v.offsite_mentions:
updated = True
v.offsite_mentions = int(request.values.get("offsite_mentions") == 'true')
if v.offsite_mentions: badge_grant(user=v, badge_id=140)
else:
badge = v.has_badge(140)
if badge: g.db.delete(badge)
elif not updated and request.values.get("cursormarsey", v.cursormarsey) != v.cursormarsey:
updated = True

View File

@ -40,8 +40,8 @@
{% endif %}
{% if v.can_view_offsite_mentions %}
<li class="nav-item">
<a class="nav-link py-3{% if request.path == '/notifications/offsite' %} active{% endif %}" href="/notifications/offsite">
Offsite {% if v.offsite_notifications_count %}<span class="font-weight-bold" style="color:#805ad5">({{v.offsite_notifications_count}})</span>{% endif %}
<a class="nav-link py-3{% if request.path == '/notifications/site_mentions' %} active{% endif %}" href="/notifications/site_mentions">
Site Mentions {% if v.offsite_notifications_count %}<span class="font-weight-bold" style="color:#805ad5">({{v.offsite_notifications_count}})</span>{% endif %}
</a>
</li>
{% endif %}

View File

@ -170,6 +170,9 @@
<section id="site-settings-notifications" class="settings-section-section">
<h5>Notifications</h5>
<div class="settings-section rounded">
{% if v.offsite_mentions != None %}
{{common.toggle_section('Site Mention Notifications', 'offsite_mentions', 'offsite_mentions', v.offsite_mentions, 'Get a notification when people on other sites talk about us', false)}}
{% endif %}
{{common.toggle_section('Effortpost Notifications', 'effortpost_notifs', 'effortpost_notifs', v.effortpost_notifs, 'Get a notification when a new effortpost is made.', false)}}
{% if SITE_NAME != 'WPD' %}
{{common.toggle_section('Hole Creation and Deletion Notifications', 'hole_creation_notifs', 'hole_creation_notifs', v.hole_creation_notifs, 'Get a notification when a hole is made or deleted.', false)}}

View File

@ -0,0 +1 @@
alter table users add column offsite_mentions bool;