remotes/1693045480750635534/spooky-22
Aevann1 2022-03-01 02:06:50 +02:00
parent 93b2866e8b
commit c22f4e4e95
6 changed files with 40 additions and 33 deletions

View File

@ -58,7 +58,8 @@ class Comment(Base):
reports = relationship("CommentFlag", viewonly=True)
def __init__(self, *args, **kwargs):
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
if "created_utc" not in kwargs:
kwargs["created_utc"] = int(time.time())
super().__init__(*args, **kwargs)
def __repr__(self):

View File

@ -48,7 +48,7 @@ def notif_comment(text, autojanny=False):
text_html = sanitize(text, alert=True)
existing = g.db.query(Comment.id).filter_by(author_id=author_id, parent_submission=None, distinguish_level=6, body_html=text_html, created_utc=0).first()
existing = g.db.query(Comment.id).filter_by(author_id=author_id, parent_submission=None, distinguish_level=6, body_html=text_html, created_utc=0).one_or_none()
if existing: return existing[0]
else: return create_comment(text_html, autojanny)

View File

@ -61,7 +61,7 @@ def notifications(v):
x.read = True
c.unread = True
g.db.add(x)
if not c.created_utc: c.created_utc = x.created_utc
if not c.created_utc: c.notif_utc = x.notif_utc
listing.append(c)
g.db.commit()
@ -85,7 +85,7 @@ def notifications(v):
try: c = comments[i]
except: continue
if not x.read: c.unread = True
if not c.created_utc: c.created_utc = x.created_utc
if not c.created_utc: c.notif_utc = x.notif_utc
x.read = True
g.db.add(x)
i += 1

View File

@ -97,21 +97,23 @@ def publish(pid, v):
if not post.ghost:
notify_users = NOTIFY_USERS(f'{post.title} {post.body}', v)
text = f"@{v.username} has mentioned you: [{post.title}]({post.shortlink})"
if post.sub: text += f" in <a href='/s/{post.sub}'>/s/{post.sub}"
if notify_users:
text = f"@{v.username} has mentioned you: [{post.title}]({post.shortlink})"
if post.sub: text += f" in <a href='/s/{post.sub}'>/s/{post.sub}"
cid = notif_comment(text)
for x in notify_users:
add_notif(cid, x)
cid = notif_comment(text)
for x in notify_users:
add_notif(cid, x)
text = f"@{v.username} has made a new post: [{post.title}]({post.shortlink})"
if post.sub: text += f" in <a href='/s/{post.sub}'>/s/{post.sub}"
if v.followers:
text = f"@{v.username} has made a new post: [{post.title}]({post.shortlink})"
if post.sub: text += f" in <a href='/s/{post.sub}'>/s/{post.sub}"
cid = notif_comment(text, autojanny=True)
for follow in v.followers:
user = get_account(follow.user_id)
if post.club and not user.paid_dues: continue
add_notif(cid, user.id)
cid = notif_comment(text, autojanny=True)
for follow in v.followers:
user = get_account(follow.user_id)
if post.club and not user.paid_dues: continue
add_notif(cid, user.id)
cache.delete_memoized(frontlist)
@ -574,9 +576,10 @@ def edit_post(pid, v):
if not p.private and not p.ghost:
notify_users = NOTIFY_USERS(f'{title} {body}', v)
cid = notif_comment(f"@{v.username} has mentioned you: [{p.title}]({p.shortlink})")
for x in notify_users:
add_notif(cid, x)
if notify_users:
cid = notif_comment(f"@{v.username} has mentioned you: [{p.title}]({p.shortlink})")
for x in notify_users:
add_notif(cid, x)
@ -1172,14 +1175,15 @@ def submit_post(v, sub=None):
notify_users = NOTIFY_USERS(f'{title} {body}', v)
text = f"@{v.username} has mentioned you: [{post.title}]({post.shortlink})"
if post.sub: text += f" in <a href='/s/{post.sub}'>/s/{post.sub}"
if notify_users:
text = f"@{v.username} has mentioned you: [{post.title}]({post.shortlink})"
if post.sub: text += f" in <a href='/s/{post.sub}'>/s/{post.sub}"
cid = notif_comment(text)
for x in notify_users:
add_notif(cid, x)
cid = notif_comment(text)
for x in notify_users:
add_notif(cid, x)
if request.values.get('followers'):
if request.values.get('followers') and v.followers:
text = f"@{v.username} has made a new post: [{post.title}]({post.shortlink})"
if post.sub: text += f" in <a href='/s/{post.sub}'>/s/{post.sub}"

View File

@ -193,10 +193,10 @@ def settings_profile_post(v):
notify_users = NOTIFY_USERS(friends, v)
cid = notif_comment(f"@{v.username} has added you to their friends list!")
for x in notify_users:
add_notif(cid, x)
if notify_users:
cid = notif_comment(f"@{v.username} has added you to their friends list!")
for x in notify_users:
add_notif(cid, x)
v.friends = friends[:500]
v.friends_html=friends_html
@ -229,10 +229,10 @@ def settings_profile_post(v):
notify_users = NOTIFY_USERS(enemies, v)
cid = notif_comment(f"@{v.username} has added you to their enemies list!")
for x in notify_users:
add_notif(cid, x)
if notify_users:
cid = notif_comment(f"@{v.username} has added you to their enemies list!")
for x in notify_users:
add_notif(cid, x)
v.enemies = enemies[:500]
v.enemies_html=enemies_html

View File

@ -235,6 +235,8 @@
{% if c.created_utc %}
<span id="timestamp-{{c.id}}" onmouseover="timestamp('timestamp-{{c.id}}','{{c.created_utc}}')" data-bs-toggle="tooltip" data-bs-placement="bottom" class="time-stamp">&nbsp;{{c.age_string}}</span>
{% elif c.notif_utc %}
<span id="timestamp-{{c.id}}" onmouseover="timestamp('timestamp-{{c.id}}','{{c.notif_utc}}')" data-bs-toggle="tooltip" data-bs-placement="bottom" class="time-stamp">&nbsp;{{c.age_string}}</span>
{% endif %}
{% if c.edited_utc %}