This commit is contained in:
Aevann1 2022-03-01 02:06:50 +02:00
parent 113bb8b694
commit ff919ec9f0
6 changed files with 40 additions and 33 deletions

View file

@ -58,7 +58,8 @@ class Comment(Base):
reports = relationship("CommentFlag", viewonly=True) reports = relationship("CommentFlag", viewonly=True)
def __init__(self, *args, **kwargs): 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) super().__init__(*args, **kwargs)
def __repr__(self): def __repr__(self):

View file

@ -48,7 +48,7 @@ def notif_comment(text, autojanny=False):
text_html = sanitize(text, alert=True) 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] if existing: return existing[0]
else: return create_comment(text_html, autojanny) else: return create_comment(text_html, autojanny)

View file

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

View file

@ -97,6 +97,7 @@ def publish(pid, v):
if not post.ghost: if not post.ghost:
notify_users = NOTIFY_USERS(f'{post.title} {post.body}', v) notify_users = NOTIFY_USERS(f'{post.title} {post.body}', v)
if notify_users:
text = f"@{v.username} has mentioned you: [{post.title}]({post.shortlink})" 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 post.sub: text += f" in <a href='/s/{post.sub}'>/s/{post.sub}"
@ -104,6 +105,7 @@ def publish(pid, v):
for x in notify_users: for x in notify_users:
add_notif(cid, x) add_notif(cid, x)
if v.followers:
text = f"@{v.username} has made a new post: [{post.title}]({post.shortlink})" 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 post.sub: text += f" in <a href='/s/{post.sub}'>/s/{post.sub}"
@ -574,6 +576,7 @@ def edit_post(pid, v):
if not p.private and not p.ghost: if not p.private and not p.ghost:
notify_users = NOTIFY_USERS(f'{title} {body}', v) notify_users = NOTIFY_USERS(f'{title} {body}', v)
if notify_users:
cid = notif_comment(f"@{v.username} has mentioned you: [{p.title}]({p.shortlink})") cid = notif_comment(f"@{v.username} has mentioned you: [{p.title}]({p.shortlink})")
for x in notify_users: for x in notify_users:
add_notif(cid, x) add_notif(cid, x)
@ -1172,6 +1175,7 @@ def submit_post(v, sub=None):
notify_users = NOTIFY_USERS(f'{title} {body}', v) notify_users = NOTIFY_USERS(f'{title} {body}', v)
if notify_users:
text = f"@{v.username} has mentioned you: [{post.title}]({post.shortlink})" 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 post.sub: text += f" in <a href='/s/{post.sub}'>/s/{post.sub}"
@ -1179,7 +1183,7 @@ def submit_post(v, sub=None):
for x in notify_users: for x in notify_users:
add_notif(cid, x) 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})" 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 post.sub: text += f" in <a href='/s/{post.sub}'>/s/{post.sub}"

View file

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

View file

@ -235,6 +235,8 @@
{% if c.created_utc %} {% 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> <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 %} {% endif %}
{% if c.edited_utc %} {% if c.edited_utc %}