Show dormant moderators; fixed a couple of regressions

This commit is contained in:
Jaakko Keränen 2023-11-10 14:58:45 +02:00
parent bcdf1e7962
commit 263498483c
No known key found for this signature in database
GPG Key ID: BACCFCFB98DB2EDC
3 changed files with 15 additions and 12 deletions

View File

@ -219,7 +219,7 @@ Bubble is open source:
if num_notifs > 0:
notifs += f' — 🔔 {num_notifs} notification{plural_s(num_notifs)}'
num_drafts = self.db.count_posts(user=self.user, draft=True)
num_drafts = self.db.count_posts(user=self.user, draft=True, is_comment=None)
if num_drafts > 0:
notifs += f' — ✏️ {num_drafts} draft{plural_s(num_drafts)}'

View File

@ -683,8 +683,11 @@ def make_feed_page(session):
if context.url:
topinfo += f'=> {context.url}\n'
# Users moderating this subspace.
now = time.time()
for mod in context_mods:
topinfo += f'=> /u/{mod.name} {mod.avatar} Moderated by: {mod.name}\n'
dormant_days = (now - mod.ts_active) / 3600 / 24
dormant = f' · 😴 {int(dormant_days)} days' if dormant_days > 60 else ''
topinfo += f'=> /u/{mod.name} {mod.avatar} Moderated by: {mod.name}{dormant}\n'
if session.is_context_locked:
topinfo += '=> /help/locked 🔒 Locked\n'
@ -720,13 +723,13 @@ def make_feed_page(session):
sort_mode = ' 💬'
feed_sort_mode = Post.SORT_CREATED
omit_user_subspaces = (user.flags & User.HOME_NO_USERS_FEED_FLAG) != 0
omit_nonuser_subspaces = (user.flags & User.HOME_USERS_FEED_FLAG) != 0
rotate_per_day = (session.is_rotation_enabled()
and not context
and not is_flat_feed
and feed_sort_mode == Post.SORT_CREATED
and not filter_by_followed)
if not is_issue_tracker and not context:
omit_user_subspaces = (user.flags & User.HOME_NO_USERS_FEED_FLAG) != 0
omit_nonuser_subspaces = (user.flags & User.HOME_USERS_FEED_FLAG) != 0
rotate_per_day = (session.is_rotation_enabled()
and not is_flat_feed
and feed_sort_mode == Post.SORT_CREATED
and not filter_by_followed)
# Pagination.
num_total = db.count_posts(subspace=context,

View File

@ -1201,16 +1201,16 @@ class Database:
cur = self.conn.cursor()
cur.execute("""
SELECT
u.id, u.avatar, u.name
u.id, u.avatar, u.name, UNIX_TIMESTAMP(u.ts_active)
FROM mods m JOIN users u ON u.id=m.user
WHERE m.subspace=?
ORDER BY u.name
""", (subspace,))
mods = []
for (id, avatar, name) in cur:
for (id, avatar, name, ts_active) in cur:
mods.append(User(id, name, None, None, None, avatar, None, None, None, None, None, None, None,
None, None, None, None, None, None))
None, None, ts_active, None, None, None))
return mods
def modify_mods(self, subspace, actor=None, add=None, remove=None):