add settings for hole and ping group creation notifs

master
Aevann 2024-02-08 05:35:37 +02:00
parent c31c9d1777
commit 73af394f9e
8 changed files with 36 additions and 15 deletions

View File

@ -148,6 +148,7 @@ class User(Base):
lifetimedonated_visible = Column(Boolean, default=False)
blacklisted_by = Column(Integer, ForeignKey("users.id"))
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)
if SITE_NAME == 'WPD':
nitter = False
@ -156,6 +157,7 @@ class User(Base):
reddit = 'old.reddit.com'
pronouns = 'they/them'
earlylife = 0
hole_creation_notifs = False
hidevotedon = Column(Boolean, default=False)
else:
nitter = Column(Boolean, default=False)
@ -164,6 +166,7 @@ class User(Base):
reddit = Column(String, default='old.reddit.com')
pronouns = Column(String, default='they/them')
earlylife = Column(Integer, default=0)
hole_creation_notifs = Column(Boolean, default=True)
hidevotedon = False
if IS_HOMOWEEN():

View File

@ -313,3 +313,16 @@ def alert_admins(body):
g.db.flush()
new_comment.top_comment_id = new_comment.id
def alert_active_users(body, v, extra_criteria):
body_html = sanitize(body, blackjack="notification")
cid = create_comment(body_html)
t = time.time() - 604800
notified_users = [x[0] for x in g.db.query(User.id).filter(
User.last_active > t,
User.id != v.id,
extra_criteria,
)]
for uid in notified_users:
add_notif(cid, uid, body, check_existing=False)

View File

@ -174,8 +174,6 @@ PERMS = { # Minimum admin_level to perform action.
'VIEW_LAST_ACTIVE': 1,
'ENABLE_VOTE_BUTTONS_ON_USER_PAGE': 1,
'NOTIFICATIONS_HOLE_INACTIVITY_DELETION': 1,
'NOTIFICATIONS_HOLE_CREATION': 1,
'NOTIFICATIONS_GROUP_CREATION': 1,
'NOTIFICATIONS_MODERATOR_ACTIONS': 1,
'EXEMPT_FROM_IP_LOGGING': 1,
@ -236,8 +234,6 @@ if SITE_NAME == 'rDrama':
patron = "Paypig"
PERMS['NOTIFICATIONS_HOLE_CREATION'] = 0
TAGLINES = (
"largest online LGBTQ+ club",
"largest online furfest",

View File

@ -54,9 +54,8 @@ def create_group(v):
g.db.flush() #Necessary, to make linkfying the ping group in the notification work
admins = [x[0] for x in g.db.query(User.id).filter(User.admin_level >= PERMS['NOTIFICATIONS_GROUP_CREATION'], User.id != v.id)]
for admin in admins:
send_repeatable_notification(admin, f":!marseyparty: !{group} has been created by @{v.username} :marseyparty:")
text = f":!marseyparty: !{group} has been created by @{v.username} :marseyparty:"
alert_active_users(text, v, User.group_creation_notifs == True)
return {"message": f"!{group} created successfully!"}

View File

@ -390,13 +390,7 @@ def create_sub2(v):
g.db.add(mod)
text = f":!marseyparty: /h/{hole} has been created by @{v.username} :marseyparty:"
text_html = sanitize(text, blackjack="notification")
cid = create_comment(text_html)
t = time.time() - 604800
excluded_ids = (v.id, 556, 868, 6289, 21238)
notified_users = [x[0] for x in g.db.query(User.id).filter(User.admin_level >= PERMS['NOTIFICATIONS_HOLE_CREATION'], User.last_active > t, User.id.notin_(excluded_ids))]
for uid in notified_users:
add_notif(cid, uid, text, check_existing=False)
alert_active_users(text, v, User.hole_creation_notifs == True)
return redirect(f"/h/{hole}")

View File

@ -175,6 +175,8 @@ def settings_personal_post(v):
updated = updated or update_flag("show_sigs", "show_sigs")
updated = updated or update_flag("is_private", "private")
updated = updated or update_flag("lifetimedonated_visible", "lifetimedonated_visible")
updated = updated or update_flag("hole_creation_notifs", "hole_creation_notifs")
updated = updated or update_flag("group_creation_notifs", "group_creation_notifs")
if not updated and request.values.get("spider", v.spider) != v.spider and v.spider <= 1:
updated = True

View File

@ -4,7 +4,6 @@
<div class="row settings-page" id="settings-page-advanced">
<div class="col col-lg-8">
<div class="settings">
{# toggle_section(title, id, name, flag, below_text) #}
<section id="site-settings-poor-mode-section" class="settings-section-section"> {# note: not using the thing from common just because of how much stuff there is in here #}
<h5>Poor Mode</h5>
<div class="settings-section rounded">
@ -157,6 +156,17 @@
</div>
</div>
</section>
<section id="site-settings-content-filters" class="settings-section-section">
<h5>Notifications</h5>
<div class="settings-section rounded">
{% if SITE_NAME != 'WPD' %}
{{common.toggle_section('Hole Creation Notifications', 'hole_creation_notifs', 'hole_creation_notifs', v.hole_creation_notifs, 'Get a notification when a new hole is made.', false)}}
{% endif %}
{{common.toggle_section('Ping Group Creation Notifications', 'group_creation_notifs', 'group_creation_notifs', v.group_creation_notifs, 'Get a notification when a new ping group is made.', false)}}
</div>
</section>
<section id="site-settings-sort-time-filter-section" class="settings-section-section">
<h5>RSS Feed</h5>
<p class="text-small text-muted">Subscribe to the {{SITE_NAME}} RSS feed.</p>

View File

@ -0,0 +1,4 @@
alter table users add column hole_creation_notifs bool default true not null;
alter table users add column group_creation_notifs bool default false not null;
alter table users alter column hole_creation_notifs drop default;
alter table users alter column group_creation_notifs drop default;