diff --git a/files/assets/js/settings_blocks.js b/files/assets/js/settings_blocks.js new file mode 100644 index 000000000..343c6d316 --- /dev/null +++ b/files/assets/js/settings_blocks.js @@ -0,0 +1,32 @@ +function block_user() { + const usernameField = document.getElementById("block-username"); + const isValidUsername = usernameField.checkValidity(); + username = usernameField.value; + if (isValidUsername) { + const xhr = new XMLHttpRequest(); + xhr.open("post", "/settings/block"); + xhr.setRequestHeader('xhr', 'xhr'); + f=new FormData(); + f.append("username", username); + f.append("formkey", formkey()); + xhr.onload=function(){ + if (xhr.status<300) { + location.reload(); + } + else { + showToast(false, "Error, please try again later."); + } + } + xhr.send(f) + } +} + +function unblock_user(t, url) { + postToast(t, url, + { + }, + () => { + t.parentElement.parentElement.remove(); + } + ); +} diff --git a/files/assets/js/settings_security.js b/files/assets/js/settings_security.js index 7a32a3e6a..6a0778e87 100644 --- a/files/assets/js/settings_security.js +++ b/files/assets/js/settings_security.js @@ -9,37 +9,4 @@ function emailVerifyText() { document.getElementById("email-verify-text").innerHTML = "Verification email sent! Please check your inbox."; } -function block_user() { - const usernameField = document.getElementById("block-username"); - const isValidUsername = usernameField.checkValidity(); - username = usernameField.value; - if (isValidUsername) { - const xhr = new XMLHttpRequest(); - xhr.open("post", "/settings/block"); - xhr.setRequestHeader('xhr', 'xhr'); - f=new FormData(); - f.append("username", username); - f.append("formkey", formkey()); - xhr.onload=function(){ - if (xhr.status<300) { - location.reload(); - } - else { - showToast(false, "Error, please try again later."); - } - } - xhr.send(f) - } -} - -function unblock_user(t, url) { - postToast(t, url, - { - }, - () => { - t.parentElement.parentElement.remove(); - } - ); -} - document.getElementById('2faToggle').addEventListener('change', () => {twoStepModal.show()}) diff --git a/files/routes/settings.py b/files/routes/settings.py index 4025c808a..f78fc960e 100644 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -649,6 +649,11 @@ def settings_security(v:User): msg=get_msg() ) +@app.get("/settings/blocks") +@auth_required +def settings_blocks(v:User): + return render_template("settings/blocks.html", v=v) + @app.post("/settings/block") @limiter.limit('1/second', scope=rpath) @limiter.limit('1/second', scope=rpath, key_func=get_ID) diff --git a/files/templates/settings.html b/files/templates/settings.html index ccb904d8c..9ff99dd8a 100644 --- a/files/templates/settings.html +++ b/files/templates/settings.html @@ -21,6 +21,7 @@ + {% if FEATURES["BOTS"] %} {% endif %} diff --git a/files/templates/settings/blocks.html b/files/templates/settings/blocks.html new file mode 100644 index 000000000..6ec53b570 --- /dev/null +++ b/files/templates/settings/blocks.html @@ -0,0 +1,82 @@ +{% extends "settings.html" %} +{% block pagetitle %}Blocks{% endblock %} +{% block content %} + +
+
+
+
+
+
+
+
+
Users you block
+

You have blocked the following users. They cannot reply to your content or notify you with a username mention.

+
+
+ +
+
+ {% if v.blocking.first() %} +
+
+ + + + + + + + {% for block in v.blocking %} + {% set user=block.target %} + + + + + {% else %} + + {% endfor %} + +
UserUnblock
+ {% include "user_in_table.html" %} + + +
There are no blocked users
+
+ {% else %} + {{macros.ghost_box('No blocked users', '', 2)}} + {% endif %} +
+
+
+
+
+
+ + + +
+
+ Error. Please try again. +
+
+{% endblock %} diff --git a/files/templates/settings/security.html b/files/templates/settings/security.html index d9d025031..76d017e41 100644 --- a/files/templates/settings/security.html +++ b/files/templates/settings/security.html @@ -124,50 +124,6 @@ -
-
-
-
-
-
Users you block
-

You have blocked the following users. They cannot reply to your content or notify you with a username mention.

-
-
- -
-
- {% if v.blocking.first() %} -
-
- - - - - - - - {% for block in v.blocking %} - {% set user=block.target %} - - - - - {% else %} - - {% endfor %} - -
UserUnblock
- {% include "user_in_table.html" %} - - -
There are no blocked users
-
- {% else %} - {{macros.ghost_box('No blocked users', '', 2)}} - {% endif %} -
-
-
@@ -229,27 +185,6 @@ - -
Error. Please try again.