2025-06-01 12:25:33 -04:00
|
|
|
(text "{% extends \"root.html\" %} {% block head %}")
|
|
|
|
(title
|
|
|
|
(text "Requests - {{ config.name }}"))
|
|
|
|
|
|
|
|
(text "{% endblock %} {% block body %} {{ macros::nav(selected=\"requests\") }}")
|
|
|
|
(main
|
|
|
|
("class" "flex flex-col gap-2")
|
2025-06-01 19:26:55 -04:00
|
|
|
|
|
|
|
; viewing other user's requests warning
|
|
|
|
(text "{% if profile.id != user.id -%}")
|
|
|
|
(div
|
|
|
|
("class" "card w-full red flex gap-2 items-center")
|
|
|
|
(text "{{ icon \"skull\" }}")
|
|
|
|
(b
|
|
|
|
(text "Viewing other user's requests! Please be careful.")))
|
|
|
|
(text "{%- endif %}")
|
|
|
|
|
|
|
|
; ...
|
2025-06-01 12:25:33 -04:00
|
|
|
(div
|
|
|
|
("class" "card-nest")
|
|
|
|
(div
|
|
|
|
("class" "card small flex items-center justify-between gap-2")
|
|
|
|
(span
|
|
|
|
("class" "flex items-center gap-2")
|
|
|
|
(text "{{ icon \"inbox\" }}")
|
|
|
|
(span
|
|
|
|
(text "{{ text \"requests:label.requests\" }}")))
|
2025-06-01 19:26:55 -04:00
|
|
|
(text "{% if profile.id == user.id -%}")
|
2025-06-01 12:25:33 -04:00
|
|
|
(button
|
|
|
|
("onclick" "clear_requests()")
|
|
|
|
("class" "small red quaternary")
|
|
|
|
(text "{{ icon \"bomb\" }}")
|
|
|
|
(span
|
2025-06-01 19:26:55 -04:00
|
|
|
(text "{{ text \"notifs:action.clear\" }}")))
|
|
|
|
(text "{% endif %}"))
|
2025-06-01 12:25:33 -04:00
|
|
|
(div
|
|
|
|
("class" "card tertiary flex flex-col gap-4")
|
|
|
|
(text "{% for request in requests %} {% if request.action_type == \"CommunityJoin\" %}")
|
|
|
|
(div
|
|
|
|
("class" "card-nest")
|
|
|
|
(div
|
|
|
|
("class" "card small flex items-center gap-2")
|
|
|
|
(text "{{ icon \"user-plus\" }}")
|
|
|
|
(span
|
|
|
|
(text "{{ text \"requests:label.community_join_request\" }}")))
|
|
|
|
(div
|
|
|
|
("class" "card flex flex-wrap gap-2")
|
|
|
|
(a
|
|
|
|
("href" "/community/{{ request.linked_asset }}/manage?uid={{ request.id }}#/members")
|
|
|
|
("class" "button")
|
|
|
|
(text "{{ icon \"external-link\" }}")
|
|
|
|
(span
|
|
|
|
(text "{{ text \"requests:label.review\" }}")))
|
|
|
|
(button
|
|
|
|
("class" "quaternary red")
|
|
|
|
("onclick" "remove_request('{{ request.id }}', '{{ request.linked_asset }}')")
|
|
|
|
(text "{{ icon \"trash\" }}")
|
|
|
|
(span
|
|
|
|
(text "{{ text \"general:action.delete\" }}")))))
|
|
|
|
(text "{% elif request.action_type == \"Follow\" %}")
|
|
|
|
(div
|
|
|
|
("class" "card-nest")
|
|
|
|
(div
|
|
|
|
("class" "card small flex items-center gap-2")
|
|
|
|
(text "{{ icon \"user-plus\" }}")
|
|
|
|
(span
|
|
|
|
(text "{{ text \"requests:label.user_follow_request\" }}")))
|
|
|
|
(div
|
|
|
|
("class" "card flex flex-col gap-2")
|
|
|
|
(span
|
|
|
|
(text "{{ text \"requests:label.user_follow_request_message\" }}"))
|
|
|
|
(div
|
2025-06-02 16:11:27 -04:00
|
|
|
("class" "card flex flex-wrap w-full secondary gap-2")
|
2025-06-01 12:25:33 -04:00
|
|
|
(a
|
|
|
|
("href" "/api/v1/auth/user/find/{{ request.id }}")
|
|
|
|
("class" "button")
|
|
|
|
(text "{{ icon \"external-link\" }}")
|
|
|
|
(span
|
|
|
|
(text "{{ text \"requests:action.view_profile\" }}")))
|
|
|
|
(button
|
|
|
|
("class" "quaternary green")
|
|
|
|
("onclick" "accept_follow_request(event, '{{ request.id }}')")
|
|
|
|
(text "{{ icon \"check\" }}")
|
|
|
|
(span
|
|
|
|
(text "{{ text \"general:action.accept\" }}")))
|
|
|
|
(button
|
|
|
|
("class" "quaternary red")
|
|
|
|
("onclick" "remove_request('{{ request.id }}', '{{ request.linked_asset }}')")
|
|
|
|
(text "{{ icon \"trash\" }}")
|
|
|
|
(span
|
|
|
|
(text "{{ text \"general:action.delete\" }}"))))))
|
|
|
|
(text "{%- endif %} {% endfor %} {% for question in questions %}")
|
|
|
|
(div
|
|
|
|
("class" "card-nest")
|
|
|
|
(text "{{ components::question(question=question[0], owner=question[1], profile=user) }}")
|
|
|
|
(form
|
|
|
|
("class" "card flex flex-col gap-2")
|
|
|
|
("onsubmit" "answer_question_from_form(event, '{{ question[0].id }}')")
|
|
|
|
(div
|
|
|
|
("class" "flex flex-col gap-1")
|
|
|
|
(label
|
|
|
|
("for" "content")
|
|
|
|
(text "{{ text \"communities:label.content\" }}"))
|
|
|
|
(textarea
|
|
|
|
("type" "text")
|
|
|
|
("name" "content")
|
|
|
|
("id" "content")
|
|
|
|
("placeholder" "content")
|
|
|
|
("required" "")
|
|
|
|
("minlength" "2")
|
|
|
|
("maxlength" "4096")))
|
|
|
|
(div
|
|
|
|
("id" "files_list")
|
|
|
|
("class" "flex gap-2 flex-wrap"))
|
|
|
|
(div
|
|
|
|
("class" "flex flex-wrap w-full gap-2")
|
|
|
|
(text "{{ components::create_post_options() }}")
|
|
|
|
(button
|
|
|
|
("class" "primary")
|
|
|
|
(text "{{ text \"requests:label.answer\" }}"))
|
|
|
|
(button
|
|
|
|
("type" "button")
|
|
|
|
("class" "red quaternary")
|
|
|
|
("onclick" "trigger('me::remove_question', ['{{ question[0].id }}'])")
|
|
|
|
(text "{{ text \"general:action.delete\" }}"))
|
|
|
|
(button
|
|
|
|
("type" "button")
|
|
|
|
("class" "red quaternary")
|
|
|
|
("onclick" "trigger('me::ip_block_question', ['{{ question[0].id }}'])")
|
|
|
|
(text "{{ text \"auth:action.ip_block\" }}")))))
|
|
|
|
(text "{% endfor %}"))))
|
|
|
|
|
|
|
|
(script
|
|
|
|
(text "async function remove_request(id, linked_asset) {
|
|
|
|
if (
|
|
|
|
!(await trigger(\"atto::confirm\", [
|
|
|
|
\"Are you sure you want to do this?\",
|
|
|
|
]))
|
|
|
|
) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
fetch(`/api/v1/requests/${id}/${linked_asset}`, {
|
|
|
|
method: \"DELETE\",
|
|
|
|
})
|
|
|
|
.then((res) => res.json())
|
|
|
|
.then((res) => {
|
|
|
|
trigger(\"atto::toast\", [
|
|
|
|
res.ok ? \"success\" : \"error\",
|
|
|
|
res.message,
|
|
|
|
]);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async function clear_requests() {
|
|
|
|
if (
|
|
|
|
!(await trigger(\"atto::confirm\", [
|
|
|
|
\"Are you sure you want to do this?\",
|
|
|
|
]))
|
|
|
|
) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
fetch(\"/api/v1/requests/my\", {
|
|
|
|
method: \"DELETE\",
|
|
|
|
})
|
|
|
|
.then((res) => res.json())
|
|
|
|
.then((res) => {
|
|
|
|
trigger(\"atto::toast\", [
|
|
|
|
res.ok ? \"success\" : \"error\",
|
|
|
|
res.message,
|
|
|
|
]);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
window.answer_question_from_form = async (e, answering) => {
|
|
|
|
e.preventDefault();
|
|
|
|
await trigger(\"atto::debounce\", [\"posts::create\"]);
|
|
|
|
|
|
|
|
// create body
|
|
|
|
const body = new FormData();
|
|
|
|
|
|
|
|
if (e.target.file_picker) {
|
|
|
|
for (const file of e.target.file_picker.files) {
|
|
|
|
body.append(file.name, file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
body.append(
|
|
|
|
\"body\",
|
|
|
|
JSON.stringify({
|
|
|
|
content: e.target.content.value,
|
|
|
|
community: \"{{ config.town_square }}\",
|
|
|
|
answering,
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
|
|
|
|
// ...
|
|
|
|
fetch(\"/api/v1/posts\", {
|
|
|
|
method: \"POST\",
|
|
|
|
|
|
|
|
body,
|
|
|
|
})
|
|
|
|
.then((res) => res.json())
|
|
|
|
.then(async (res) => {
|
|
|
|
trigger(\"atto::toast\", [
|
|
|
|
res.ok ? \"success\" : \"error\",
|
|
|
|
res.message,
|
|
|
|
]);
|
|
|
|
|
|
|
|
if (res.ok) {
|
|
|
|
// update settings
|
|
|
|
await update_settings_maybe(res.payload);
|
|
|
|
|
|
|
|
// ...
|
|
|
|
e.target.parentElement.remove();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
globalThis.accept_follow_request = async (e, id) => {
|
|
|
|
await trigger(\"atto::debounce\", [\"users::follow\"]);
|
|
|
|
|
|
|
|
if (
|
|
|
|
!(await trigger(\"atto::confirm\", [
|
|
|
|
\"Are you sure you would like to do this?\",
|
|
|
|
]))
|
|
|
|
) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
fetch(`/api/v1/auth/user/${id}/follow/accept`, {
|
|
|
|
method: \"POST\",
|
|
|
|
})
|
|
|
|
.then((res) => res.json())
|
|
|
|
.then(async (res) => {
|
|
|
|
trigger(\"atto::toast\", [
|
|
|
|
res.ok ? \"success\" : \"error\",
|
|
|
|
res.message,
|
|
|
|
]);
|
|
|
|
|
|
|
|
if (res.ok) {
|
|
|
|
e.target.parentElement.parentElement.parentElement.parentElement.remove();
|
|
|
|
|
|
|
|
if (
|
|
|
|
await trigger(\"atto::confirm\", [
|
|
|
|
\"Would you like to follow this user back? This will allow them to view your profile.\",
|
|
|
|
])
|
|
|
|
) {
|
|
|
|
fetch(`/api/v1/auth/user/${id}/follow`, {
|
|
|
|
method: \"POST\",
|
|
|
|
})
|
|
|
|
.then((res) => res.json())
|
|
|
|
.then((res) => {
|
|
|
|
trigger(\"atto::toast\", [
|
|
|
|
res.ok ? \"success\" : \"error\",
|
|
|
|
res.message,
|
|
|
|
]);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};"))
|
|
|
|
|
|
|
|
(text "{% endblock %}")
|