diff --git a/files/assets/css/main.css b/files/assets/css/main.css index 2c3485c8f..542399125 100644 --- a/files/assets/css/main.css +++ b/files/assets/css/main.css @@ -220,6 +220,7 @@ .fa-scarecrow:before{content:"\f70d"} .fa-chart-simple:before{content:"\e473"} .fa-memo:before{content:"\e1d8"} +.fa-file-pen:before{content:"\f31c"} /* do not remove - fixes hand, talking, marsey-love components from breaking out of the comment box diff --git a/files/assets/js/comments_v.js b/files/assets/js/comments_v.js index a3ee3a04f..d74470d53 100644 --- a/files/assets/js/comments_v.js +++ b/files/assets/js/comments_v.js @@ -281,6 +281,10 @@ function post_comment(fullname, hide){ } catch(e) {} + const admin_note_el = document.getElementById('admin-note-'+fullname) + if (admin_note_el) + form.append('admin_note', admin_note_el.checked); + const xhr = new XMLHttpRequest(); url = '/comment'; xhr.open("POST", url); diff --git a/files/helpers/can_see.py b/files/helpers/can_see.py index 5c37866cd..4914501d2 100644 --- a/files/helpers/can_see.py +++ b/files/helpers/can_see.py @@ -29,6 +29,8 @@ def can_see(user, obj): if SITE == 'watchpeopledie.tv' and obj.id in {5, 17212, 22653, 23814}: return False else: + if obj.pinned == "Admin Note": + return user.admin_level >= PERMS['ADMIN_NOTES'] if hasattr(obj, 'is_blocking') and obj.is_blocking and not request.path.endswith(f'/{obj.id}'): return False if obj.parent_post: diff --git a/files/helpers/config/const.py b/files/helpers/config/const.py index 829f33d18..2ab42d3da 100644 --- a/files/helpers/config/const.py +++ b/files/helpers/config/const.py @@ -175,6 +175,7 @@ PERMS = { # Minimum admin_level to perform action. 'NOTIFICATIONS_MODERATOR_ACTIONS': 1, 'EXEMPT_FROM_IP_LOGGING': 1, 'USER_BADGES': 1, + 'ADMIN_NOTES': 1, 'IS_PERMA_PROGSTACKED': 2, 'USER_LINK': 2, diff --git a/files/routes/comments.py b/files/routes/comments.py index d073882a7..48dbba795 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -249,6 +249,12 @@ def comment(v): g.db.add(c) g.db.flush() + if not posting_to_post and request.values.get('admin_note') and v.admin_level >= PERMS['ADMIN_NOTES']: + c.pinned = "Admin Note" + + if c.parent_comment_id and c.parent_comment.pinned == "Admin Note": + c.pinned = "Admin Note" + process_options(v, c) execute_blackjack(v, c, c.body, "comment") @@ -297,39 +303,40 @@ def comment(v): execute_longpostbot(c, level, body, body_html, post_target, v) execute_zozbot(c, level, post_target, v) - notify_users = NOTIFY_USERS(body, v, ghost=c.ghost, obj=c, commenters_ping_post_id=commenters_ping_post_id) + if c.pinned != "Admin Note": + notify_users = NOTIFY_USERS(body, v, ghost=c.ghost, obj=c, commenters_ping_post_id=commenters_ping_post_id) - if notify_users == 'everyone': - alert_everyone(c.id) - else: - push_notif(notify_users, f'New mention of you by @{c.author_name}', c.body, c) + if notify_users == 'everyone': + alert_everyone(c.id) + else: + push_notif(notify_users, f'New mention of you by @{c.author_name}', c.body, c) - if c.level == 1 and posting_to_post: - subscriber_ids = [x[0] for x in g.db.query(Subscription.user_id).filter(Subscription.post_id == post_target.id, Subscription.user_id != v.id)] + if c.level == 1 and posting_to_post: + subscriber_ids = [x[0] for x in g.db.query(Subscription.user_id).filter(Subscription.post_id == post_target.id, Subscription.user_id != v.id)] - notify_users.update(subscriber_ids) + notify_users.update(subscriber_ids) - push_notif(subscriber_ids, f'New comment in subscribed thread by @{c.author_name}', c.body, c) + push_notif(subscriber_ids, f'New comment in subscribed thread by @{c.author_name}', c.body, c) - if parent_user.id != v.id and notify_op: - notify_users.add(parent_user.id) + if parent_user.id != v.id and notify_op: + notify_users.add(parent_user.id) - notify_users -= BOT_IDs + notify_users -= BOT_IDs - if v.shadowbanned or c.is_banned: - notify_users = [x[0] for x in g.db.query(User.id).filter(User.id.in_(notify_users), User.admin_level >= PERMS['USER_SHADOWBAN']).all()] + if v.shadowbanned or c.is_banned: + notify_users = [x[0] for x in g.db.query(User.id).filter(User.id.in_(notify_users), User.admin_level >= PERMS['USER_SHADOWBAN']).all()] - for x in notify_users: - n = Notification(comment_id=c.id, user_id=x) - g.db.add(n) + for x in notify_users: + n = Notification(comment_id=c.id, user_id=x) + g.db.add(n) - if parent_user.id != v.id and notify_op: - if isinstance(parent, User): - title = f"New comment on your wall by @{c.author_name}" - else: - title = f'New reply by @{c.author_name}' + if parent_user.id != v.id and notify_op: + if isinstance(parent, User): + title = f"New comment on your wall by @{c.author_name}" + else: + title = f'New reply by @{c.author_name}' - push_notif({parent_user.id}, title, c.body, c) + push_notif({parent_user.id}, title, c.body, c) vote = CommentVote(user_id=v.id, comment_id=c.id, diff --git a/files/routes/users.py b/files/routes/users.py index 4e87134fb..ee05bb017 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -899,15 +899,19 @@ def u_username_wall(v, username): comments = comments.join(Comment.author).filter(or_(User.id == v.id, User.shadowbanned == None)) total = comments.count() - comments = comments.order_by(Comment.created_utc.desc()) \ - .offset(PAGE_SIZE * (page - 1)).limit(PAGE_SIZE).all() - if v: - comments = [c[0] for c in comments] - if v and v.client: + if v.admin_level >= PERMS['ADMIN_NOTES']: + pinned = [c[0] for c in comments.filter(Comment.pinned != None).order_by(Comment.created_utc.desc())] + else: + pinned = [] + + comments = comments.filter(Comment.pinned == None).order_by(Comment.created_utc.desc()) .offset(PAGE_SIZE * (page - 1)).limit(PAGE_SIZE).all() + comments = [c[0] for c in comments] + + if v.client: return {"data": [c.json for c in comments]} - return render_template("userpage/wall.html", u=u, v=v, listing=comments, page=page, total=total, is_following=is_following, standalone=True, render_replies=True, wall=True) + return render_template("userpage/wall.html", u=u, v=v, pinned=pinned, listing=comments, page=page, total=total, is_following=is_following, standalone=True, render_replies=True, wall=True) @app.get("/@/wall/comment/") diff --git a/files/templates/comments.html b/files/templates/comments.html index e19c658c6..a87cdf643 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -149,8 +149,10 @@ {%- include 'admin/shadowbanned_tooltip.html' -%} {% endwith %} - {% if c.pinned %} - + {% if c.pinned == 'Admin Note' %} + + {% elif c.pinned %} + {% endif %} {% if c.distinguished and not c.ghost %} diff --git a/files/templates/userpage/wall.html b/files/templates/userpage/wall.html index 0398c9f2d..c7286c78b 100644 --- a/files/templates/userpage/wall.html +++ b/files/templates/userpage/wall.html @@ -10,6 +10,13 @@
+ {% if pinned %} + {% with comments=pinned %} + {% include "comments.html" %} + {% endwith %} +
+ {% endif %} + {% with comments=listing %} {% include "comments.html" %} {% endwith %} @@ -22,7 +29,7 @@ {% endif %} {{macros.ghost_box(text, '', 1)}} {% endif %} -
+
{% endblock %} diff --git a/files/templates/util/macros.html b/files/templates/util/macros.html index 273a8c1ba..72ab1c18d 100644 --- a/files/templates/util/macros.html +++ b/files/templates/util/macros.html @@ -171,6 +171,13 @@ {{file_btn('file-upload-reply-' ~ target_fullname)}} + {% if v.admin_level >= PERMS['ADMIN_NOTES'] and target_fullname.startswith('u_') %} +
+ + +
+ {% endif %} + {% if enable_cancel_button %}