add: ability to ip block users from their profile

This commit is contained in:
trisua 2025-06-28 13:15:37 -04:00
parent a799c777ea
commit 0163391380
12 changed files with 241 additions and 20 deletions

View file

@ -505,7 +505,7 @@ media_theme_pref();
return now - last_seen <= maximum_time_to_be_considered_idle;
});
self.define("hooks::online_indicator", ({ $ }) => {
self.define("hooks::online_indicator", async ({ $ }) => {
for (const element of Array.from(
document.querySelectorAll("[hook=online_indicator]") || [],
)) {
@ -513,8 +513,8 @@ media_theme_pref();
element.getAttribute("hook-arg:last_seen"),
);
const is_online = $.last_seen_just_now(last_seen);
const is_idle = $.last_seen_recently(last_seen);
const is_online = await $.last_seen_just_now(last_seen);
const is_idle = await $.last_seen_recently(last_seen);
const offline = element.querySelector("[hook_ui_ident=offline]");
const online = element.querySelector("[hook_ui_ident=online]");

View file

@ -402,6 +402,27 @@
});
});
self.define("remove_ip_block", async (_, id) => {
if (
!(await trigger("atto::confirm", [
"Are you sure you want to do this?",
]))
) {
return;
}
fetch(`/api/v1/auth/ip/${id}/unblock_ip`, {
method: "POST",
})
.then((res) => res.json())
.then((res) => {
trigger("atto::toast", [
res.ok ? "success" : "error",
res.message,
]);
});
});
self.define("notifications_stream", ({ _, streams }) => {
const element = document.getElementById("notifications_span");