created
This commit is contained in:
parent
113bb8b694
commit
ff919ec9f0
6 changed files with 40 additions and 33 deletions
|
@ -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):
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -97,21 +97,23 @@ 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)
|
||||||
|
|
||||||
text = f"@{v.username} has mentioned you: [{post.title}]({post.shortlink})"
|
if notify_users:
|
||||||
if post.sub: text += f" in <a href='/s/{post.sub}'>/s/{post.sub}"
|
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)
|
cid = notif_comment(text)
|
||||||
for x in notify_users:
|
for x in notify_users:
|
||||||
add_notif(cid, x)
|
add_notif(cid, x)
|
||||||
|
|
||||||
text = f"@{v.username} has made a new post: [{post.title}]({post.shortlink})"
|
if v.followers:
|
||||||
if post.sub: text += f" in <a href='/s/{post.sub}'>/s/{post.sub}"
|
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)
|
cid = notif_comment(text, autojanny=True)
|
||||||
for follow in v.followers:
|
for follow in v.followers:
|
||||||
user = get_account(follow.user_id)
|
user = get_account(follow.user_id)
|
||||||
if post.club and not user.paid_dues: continue
|
if post.club and not user.paid_dues: continue
|
||||||
add_notif(cid, user.id)
|
add_notif(cid, user.id)
|
||||||
|
|
||||||
|
|
||||||
cache.delete_memoized(frontlist)
|
cache.delete_memoized(frontlist)
|
||||||
|
@ -574,9 +576,10 @@ 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)
|
||||||
cid = notif_comment(f"@{v.username} has mentioned you: [{p.title}]({p.shortlink})")
|
if notify_users:
|
||||||
for x in notify_users:
|
cid = notif_comment(f"@{v.username} has mentioned you: [{p.title}]({p.shortlink})")
|
||||||
add_notif(cid, x)
|
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)
|
notify_users = NOTIFY_USERS(f'{title} {body}', v)
|
||||||
|
|
||||||
text = f"@{v.username} has mentioned you: [{post.title}]({post.shortlink})"
|
if notify_users:
|
||||||
if post.sub: text += f" in <a href='/s/{post.sub}'>/s/{post.sub}"
|
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)
|
cid = notif_comment(text)
|
||||||
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}"
|
||||||
|
|
||||||
|
|
|
@ -193,10 +193,10 @@ def settings_profile_post(v):
|
||||||
|
|
||||||
notify_users = NOTIFY_USERS(friends, v)
|
notify_users = NOTIFY_USERS(friends, v)
|
||||||
|
|
||||||
cid = notif_comment(f"@{v.username} has added you to their friends list!")
|
if notify_users:
|
||||||
|
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)
|
||||||
|
|
||||||
v.friends = friends[:500]
|
v.friends = friends[:500]
|
||||||
v.friends_html=friends_html
|
v.friends_html=friends_html
|
||||||
|
@ -229,10 +229,10 @@ def settings_profile_post(v):
|
||||||
|
|
||||||
notify_users = NOTIFY_USERS(enemies, v)
|
notify_users = NOTIFY_USERS(enemies, v)
|
||||||
|
|
||||||
cid = notif_comment(f"@{v.username} has added you to their enemies list!")
|
if notify_users:
|
||||||
|
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)
|
||||||
|
|
||||||
v.enemies = enemies[:500]
|
v.enemies = enemies[:500]
|
||||||
v.enemies_html=enemies_html
|
v.enemies_html=enemies_html
|
||||||
|
|
|
@ -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"> {{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"> {{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"> {{c.age_string}}</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if c.edited_utc %}
|
{% if c.edited_utc %}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue