Remove unused reddit mentions notifications

In the distant past, the codebase would check pushshift for keyword
mentions and generate notifications to admins about them. I can't
find where we removed it, but I don't think it was ever operative.

Since these notifications don't get generated, we don't need a
notifications page for them.
This commit is contained in:
TLSM 2023-07-09 03:35:35 -04:00 committed by Ben Rog-Wilhelm
parent 75950e9466
commit edafe22024
4 changed files with 4 additions and 41 deletions

View file

@ -348,25 +348,15 @@ class User(CreatedBase):
def post_notifications_count(self): def post_notifications_count(self):
return g.db.query(Notification.user_id).join(Comment).filter(Notification.user_id == self.id, Notification.read == False, Comment.author_id == AUTOJANNY_ID).count() return g.db.query(Notification.user_id).join(Comment).filter(Notification.user_id == self.id, Notification.read == False, Comment.author_id == AUTOJANNY_ID).count()
@property
@lazy
def reddit_notifications_count(self):
return g.db.query(Notification.user_id).join(Comment).filter(Notification.user_id == self.id, Notification.read == False, Comment.state_mod == StateMod.VISIBLE, Comment.state_user_deleted_utc == None, Comment.body_html.like('%<p>New site mention: <a href="https://old.reddit.com/r/%'), Comment.parent_submission == None, Comment.author_id == NOTIFICATIONS_ID).count()
@property @property
@lazy @lazy
def normal_count(self): def normal_count(self):
return self.notifications_count - self.post_notifications_count - self.reddit_notifications_count return self.notifications_count - self.post_notifications_count
@property @property
@lazy @lazy
def do_posts(self): def do_posts(self):
return self.post_notifications_count and self.notifications_count-self.reddit_notifications_count == self.post_notifications_count return self.post_notifications_count and self.notifications_count == self.post_notifications_count
@property
@lazy
def do_reddit(self):
return self.notifications_count == self.reddit_notifications_count
@property @property
@lazy @lazy

View file

@ -49,7 +49,6 @@ def notifications(v):
messages = request.values.get('messages') messages = request.values.get('messages')
modmail = request.values.get('modmail') modmail = request.values.get('modmail')
posts = request.values.get('posts') posts = request.values.get('posts')
reddit = request.values.get('reddit')
if modmail and v.admin_level >= 2: if modmail and v.admin_level >= 2:
comments = g.db.query(Comment).filter(Comment.sentto == MODMAIL_ID).order_by(Comment.id.desc()).offset(25*(page-1)).limit(26).all() comments = g.db.query(Comment).filter(Comment.sentto == MODMAIL_ID).order_by(Comment.id.desc()).offset(25*(page-1)).limit(26).all()
next_exists = (len(comments) > 25) next_exists = (len(comments) > 25)
@ -79,24 +78,6 @@ def notifications(v):
g.db.commit() g.db.commit()
next_exists = (len(notifications) > len(listing))
elif reddit:
notifications = g.db.query(Notification, Comment).join(Comment, Notification.comment_id == Comment.id).filter(Notification.user_id == v.id, Comment.body_html.like('%<p>New site mention: <a href="https://old.reddit.com/r/%'), Comment.parent_submission == None, Comment.author_id == NOTIFICATIONS_ID).order_by(Notification.created_utc.desc()).offset(25 * (page - 1)).limit(101).all()
listing = []
for index, x in enumerate(notifications[:100]):
n, c = x
if n.read and index > 24: break
elif not n.read:
n.read = True
c.unread = True
g.db.add(n)
if n.created_utc > 1620391248: c.notif_utc = n.created_utc
listing.append(c)
g.db.commit()
next_exists = (len(notifications) > len(listing)) next_exists = (len(notifications) > len(listing))
else: else:
comments = g.db.query(Comment, Notification).join(Notification, Notification.comment_id == Comment.id).filter( comments = g.db.query(Comment, Notification).join(Notification, Notification.comment_id == Comment.id).filter(
@ -104,7 +85,6 @@ def notifications(v):
Comment.state_mod == StateMod.VISIBLE, Comment.state_mod == StateMod.VISIBLE,
Comment.state_user_deleted_utc == None, Comment.state_user_deleted_utc == None,
Comment.author_id != AUTOJANNY_ID, Comment.author_id != AUTOJANNY_ID,
Comment.body_html.notlike('%<p>New site mention: <a href="https://old.reddit.com/r/%')
).order_by(Notification.created_utc.desc()) ).order_by(Notification.created_utc.desc())
if not (v and (v.shadowbanned or v.admin_level >= 3)): if not (v and (v.shadowbanned or v.admin_level >= 3)):

View file

@ -27,7 +27,7 @@
{% if v %} {% if v %}
{% if v.notifications_count %} {% if v.notifications_count %}
<a class="mobile-nav-icon d-md-none pl-0" href="/notifications{% if v.do_posts %}?posts=true{% elif v.do_reddit %}?reddit=true{% endif %}" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Notifications"><i class="fas fa-bell align-middle text-danger" {% if v.do_posts %}style="color:blue!important"{% elif v.do_reddit %}style="color:#805ad5!important"{% endif %}></i><span class="notif-count ml-1" style="padding-left: 4.5px;{% if v.do_posts %}background:blue{% elif v.do_reddit %}background:#805ad5{% endif %}">{{v.notifications_count}}</span></a> <a class="mobile-nav-icon d-md-none pl-0" href="/notifications{% if v.do_posts %}?posts=true{% endif %}" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Notifications"><i class="fas fa-bell align-middle text-danger" {% if v.do_posts %}style="color:blue!important"{% endif %}></i><span class="notif-count ml-1" style="padding-left: 4.5px;{% if v.do_posts %}background:blue{% endif %}">{{v.notifications_count}}</span></a>
{% else %} {% else %}
<a class="mobile-nav-icon d-md-none" href="/notifications" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Notifications"><i class="fas fa-bell align-middle text-gray-500 black"></i></a> <a class="mobile-nav-icon d-md-none" href="/notifications" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Notifications"><i class="fas fa-bell align-middle text-gray-500 black"></i></a>
{% endif %} {% endif %}
@ -57,7 +57,7 @@
{% if v.notifications_count %} {% if v.notifications_count %}
<li class="nav-item d-flex align-items-center text-center justify-content-center mx-1"> <li class="nav-item d-flex align-items-center text-center justify-content-center mx-1">
<a class="nav-link position-relative" href="/notifications{% if v.do_posts %}?posts=true{% elif v.do_reddit %}?reddit=true{% endif %}" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Notifications"><i class="fas fa-bell text-danger" {% if v.do_posts %}style="color:blue!important"{% elif v.do_reddit %}style="color:#805ad5!important"{% endif %}></i><span class="notif-count ml-1" style="padding-left: 4.5px;{% if v.do_posts %}background:blue{% elif v.do_reddit %}background:#805ad5{% endif %}">{{v.notifications_count}}</span></a> <a class="nav-link position-relative" href="/notifications{% if v.do_posts %}?posts=true{% endif %}" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Notifications"><i class="fas fa-bell text-danger" {% if v.do_posts %}style="color:blue!important"{% endif %}></i><span class="notif-count ml-1" style="padding-left: 4.5px;{% if v.do_posts %}background:blue{% endif %}">{{v.notifications_count}}</span></a>
</li> </li>
{% else %} {% else %}

View file

@ -35,13 +35,6 @@
</a> </a>
</li> </li>
{% endif %} {% endif %}
{% if v.admin_level %}
<li class="nav-item">
<a class="nav-link py-3{% if '/notifications?reddit=true' in request.full_path %} active{% endif %}" href="/notifications?reddit=true">
Reddit {% if v.reddit_notifications_count %}<span class="font-weight-bold" style="color:#805ad5">({{v.reddit_notifications_count}})</span>{% endif %}
</a>
</li>
{% endif %}
</ul> </ul>
</div> </div>
</div> </div>