diff --git a/files/assets/js/comments_v.js b/files/assets/js/comments_v.js index 70d2b9bbd..e78d03c54 100644 --- a/files/assets/js/comments_v.js +++ b/files/assets/js/comments_v.js @@ -143,6 +143,7 @@ function post_reply(id){ document.getElementById('reply-form-body-'+id).value = '' document.getElementById('message-reply-'+id).innerHTML = '' ToggleReplyBox('reply-message-'+id) + document.getElementById('file-upload').value = null; } else { showToast(false, getMessageFromJsonData(false, data)); } @@ -179,6 +180,7 @@ function comment_edit(id){ bs_trigger(commentForm); document.getElementById('filename-edit-reply-' + id).innerHTML = ''; document.getElementById('comment-edit-body-' + id).value = data["body"]; + document.getElementById('file-edit-reply-'+id).value = null; } else { showToast(false, getMessageFromJsonData(false, data)); @@ -239,6 +241,7 @@ function post_comment(fullname, wall_user_id, hide){ document.getElementById('form-preview-'+fullname).innerHTML = '' document.getElementById('charcount-'+fullname).innerHTML = '' document.getElementById('filename-show-reply-' + fullname).innerHTML = ''; + document.getElementById('file-upload-reply-'+fullname).value = null; } else { showToast(false, getMessageFromJsonData(false, data)); diff --git a/files/assets/js/core.js b/files/assets/js/core.js index 52f36060e..cbef8ecda 100644 --- a/files/assets/js/core.js +++ b/files/assets/js/core.js @@ -292,7 +292,7 @@ function changename(s1,s2) { if (files.length > 4) { alert("You can't upload more than 4 files at one time!") - document.getElementById(s2).files = null + document.getElementById(s2).value = null return } let filename = ''; diff --git a/files/assets/js/submit.js b/files/assets/js/submit.js index 38c3b1a19..593f0839a 100644 --- a/files/assets/js/submit.js +++ b/files/assets/js/submit.js @@ -72,7 +72,7 @@ document.onpaste = function(event) { for (const file of files) filename += file.name + ', ' filename = filename.toLowerCase().slice(0, -2) - document.getElementById('file-upload-submit').files = files; + document.getElementById('file-upload-submit').value = files; document.getElementById('filename-show-submit').textContent = filename; } else { diff --git a/files/helpers/get.py b/files/helpers/get.py index 85c4c2056..ce6d94d5b 100644 --- a/files/helpers/get.py +++ b/files/helpers/get.py @@ -131,14 +131,12 @@ def get_post(i:Union[str, int], v:Optional[User]=None, graceful=False) -> Option ) post=post.filter(Submission.id == i - ).join( + ).outerjoin( vt, vt.c.submission_id == Submission.id, - isouter=True - ).join( + ).outerjoin( blocking, blocking.c.target_id == Submission.author_id, - isouter=True ) post=post.one_or_none() @@ -179,16 +177,14 @@ def get_posts(pids:Iterable[int], v:Optional[User]=None, eager:bool=False, extra blocked.c.target_id, ).filter( Submission.id.in_(pids) - ).join( - vt, vt.c.submission_id==Submission.id, isouter=True - ).join( + ).outerjoin( + vt, vt.c.submission_id==Submission.id + ).outerjoin( blocking, blocking.c.target_id == Submission.author_id, - isouter=True - ).join( + ).outerjoin( blocked, blocked.c.user_id == Submission.author_id, - isouter=True ) else: query = g.db.query(Submission).filter(Submission.id.in_(pids)) @@ -320,18 +316,15 @@ def get_comments_v_properties(v:User, include_shadowbanned=True, should_keep_fun comments = comments.join(Comment.author).filter(User.shadowbanned == None) comments = comments.filter(*criterion) - comments = comments.join( + comments = comments.outerjoin( votes, votes.c.comment_id == Comment.id, - isouter=True - ).join( + ).outerjoin( blocking, blocking.c.target_id == Comment.author_id, - isouter=True - ).join( + ).outerjoin( blocked, blocked.c.user_id == Comment.author_id, - isouter=True ) queried = comments.all() output = [] diff --git a/files/routes/comments.py b/files/routes/comments.py index ae6dadf81..c465a93bb 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -79,7 +79,6 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None, sub=None): else: template = "submission.html" return render_template(template, v=v, p=post, sort=sort, comment_info=comment_info, render_replies=True, sub=post.subr) -#- API @app.post("/comment") @limiter.limit("1/second;20/minute;200/hour;1000/day") @auth_required @@ -311,7 +310,7 @@ def comment(v): v.comment_count = g.db.query(Comment).filter( Comment.author_id == v.id, - Comment.parent_submission != None, + or_(Comment.parent_submission != None, Comment.wall_user_id != None), Comment.deleted_utc == 0 ).count() g.db.add(v) @@ -346,7 +345,6 @@ def comment(v): return {"comment": render_template("comments.html", v=v, comments=[c])} -#- API @app.post("/wall_comment") @limiter.limit("1/second;20/minute;200/hour;1000/day") @auth_required @@ -523,7 +521,7 @@ def wall_comment(v): v.comment_count = g.db.query(Comment).filter( Comment.author_id == v.id, - Comment.parent_submission != None, + or_(Comment.parent_submission != None, Comment.wall_user_id != None), Comment.deleted_utc == 0 ).count() g.db.add(v) @@ -550,6 +548,8 @@ def wall_comment(v): g.db.flush() + cache.delete_memoized(comment_idlist) + if v.client: return c.json(db=g.db) return {"comment": render_template("comments.html", v=v, comments=[c])} @@ -644,7 +644,7 @@ def delete_comment(cid, v): g.db.flush() v.comment_count = g.db.query(Comment).filter( Comment.author_id == v.id, - Comment.parent_submission != None, + or_(Comment.parent_submission != None, Comment.wall_user_id != None), Comment.deleted_utc == 0 ).count() g.db.add(v) @@ -664,7 +664,7 @@ def undelete_comment(cid, v): g.db.flush() v.comment_count = g.db.query(Comment).filter( Comment.author_id == v.id, - Comment.parent_submission != None, + or_(Comment.parent_submission != None, Comment.wall_user_id != None), Comment.deleted_utc == 0 ).count() g.db.add(v) diff --git a/files/routes/front.py b/files/routes/front.py index ec2656c7b..d3c5b5613 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -210,8 +210,10 @@ def all_comments(v:User): @cache.memoize(timeout=86400) def comment_idlist(v=None, page=1, sort="new", t="all", gt=0, lt=0, site=None): comments = g.db.query(Comment.id) \ - .join(Comment.post) \ - .filter(Comment.parent_submission != None) + .outerjoin(Comment.post) \ + .filter( + or_(Comment.parent_submission != None, Comment.wall_user_id != None), + ) if v.admin_level < PERMS['POST_COMMENT_MODERATION']: comments = comments.filter( diff --git a/files/routes/search.py b/files/routes/search.py index 6bee4b7a5..f1cca4c52 100644 --- a/files/routes/search.py +++ b/files/routes/search.py @@ -181,8 +181,11 @@ def searchcomments(v:User): criteria = searchparse(query) - comments = g.db.query(Comment.id).join(Comment.post) \ - .filter(Comment.parent_submission != None, Comment.author_id.notin_(v.userblocks)) + comments = g.db.query(Comment.id).outerjoin(Comment.post) \ + .filter( + or_(Comment.parent_submission != None, Comment.wall_user_id != None), + Comment.author_id.notin_(v.userblocks), + ) if 'post' in criteria: diff --git a/files/routes/users.py b/files/routes/users.py index 6bc58949a..7e2972314 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -938,11 +938,11 @@ def u_username_comments(username, v=None): comment_post_author = aliased(User) comments = g.db.query(Comment.id) \ - .join(Comment.post) \ - .join(comment_post_author, Submission.author) \ + .outerjoin(Comment.post) \ + .outerjoin(comment_post_author, Submission.author) \ .filter( Comment.author_id == u.id, - Comment.parent_submission != None + or_(Comment.parent_submission != None, Comment.wall_user_id != None), ) if not v or (v.id != u.id and v.admin_level < PERMS['POST_COMMENT_MODERATION']): diff --git a/files/templates/comments.html b/files/templates/comments.html index 358151a20..deed36fbf 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -93,7 +93,7 @@ {% elif c.author_id==AUTOJANNY_ID %} Notification {% elif c.wall_user_id %} - {% if request.path == '/notifications' %} + {% if not wall %} {% if c.wall_user_id == v.id %} Your Profile Wall {% else %}