transfers fix

remotes/1693045480750635534/spooky-22
Aevann1 2022-03-04 18:53:28 +02:00
parent 0d7b632265
commit 6d6b199a3b
4 changed files with 10 additions and 11 deletions

View File

@ -118,8 +118,8 @@ class Comment(Base):
@property
@lazy
def age_string(self):
if self.created_utc: timestamp = self.created_utc
elif self.notif_utc: timestamp = self.notif_utc
if self.notif_utc: timestamp = self.notif_utc
elif self.created_utc: timestamp = self.created_utc
else: return None
age = int(time.time()) - timestamp

View File

@ -9,7 +9,6 @@ def create_comment(text_html, autojanny=False):
new_comment = Comment(author_id=author_id,
parent_submission=None,
created_utc=0,
body_html=text_html)
g.db.add(new_comment)
g.db.flush()
@ -22,7 +21,7 @@ def send_repeatable_notification(uid, text, autojanny=False):
text_html = sanitize(text)
existing_comment = g.db.query(Comment.id).filter_by(author_id=author_id, parent_submission=None, body_html=text_html, created_utc=0).first()
existing_comment = g.db.query(Comment.id).filter_by(author_id=author_id, parent_submission=None, body_html=text_html).first()
if existing_comment:
cid = existing_comment[0]
@ -47,7 +46,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, body_html=text_html, created_utc=0).one_or_none()
existing = g.db.query(Comment.id).filter_by(author_id=author_id, parent_submission=None, body_html=text_html).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.notif_utc = x.created_utc
c.notif_utc = x.created_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.notif_utc = x.created_utc
c.notif_utc = x.created_utc
x.read = True
g.db.add(x)
i += 1
@ -556,7 +556,7 @@ def all_comments(v):
@auth_required
def transfers(v):
comments = g.db.query(Comment).filter(Comment.author_id == NOTIFICATIONS_ID, Comment.parent_submission == None, Comment.distinguish_level == 6, Comment.body_html.like("%</a> has transferred %"), Comment.created_utc == 0).order_by(Comment.id.desc())
comments = g.db.query(Comment).filter(Comment.author_id == NOTIFICATIONS_ID, Comment.parent_submission == None, Comment.body_html.like("%</a> has transferred %")).order_by(Comment.id.desc())
if request.headers.get("Authorization"): return {"data": [x.json for x in comments.all()]}

View File

@ -231,10 +231,10 @@
{% if c.parent_comment_id and not standalone and level != 1 %}<a href="#comment-{{c.parent_comment_id}}-only" class="text-muted ml-2"><i class="fas fa-reply fa-sm fa-fw fa-flip-horizontal mr-1"></i>{{c.parent_comment.author_name}}</a>{% endif %}
{% 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 %}
{% if 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>
{% elif 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>
{% endif %}
{% if c.edited_utc %}