add: user follow requests
add: nsfw questions fix: inherit nsfw status from questions fix: inherit community from questions
This commit is contained in:
parent
d6c7372610
commit
ad17acec98
24 changed files with 492 additions and 59 deletions
|
@ -58,6 +58,7 @@
|
|||
</main>
|
||||
|
||||
<script>
|
||||
const community = "{{ question.community }}";
|
||||
async function answer_question_from_form(e, answering) {
|
||||
e.preventDefault();
|
||||
await trigger("atto::debounce", ["posts::create"]);
|
||||
|
@ -68,7 +69,7 @@
|
|||
},
|
||||
body: JSON.stringify({
|
||||
content: e.target.content.value,
|
||||
community: "{{ config.town_square }}",
|
||||
community: community ? community : "{{ config.town_square }}",
|
||||
answering,
|
||||
}),
|
||||
})
|
||||
|
|
|
@ -619,7 +619,15 @@ show_community=true, secondary=false) -%}
|
|||
{{ icon "message-circle-heart" }}
|
||||
</span>
|
||||
|
||||
{% if question.community > 0 and show_community %}
|
||||
{% if question.context.is_nsfw %}
|
||||
<span
|
||||
title="NSFW community"
|
||||
class="flex items-center"
|
||||
style="color: var(--color-primary)"
|
||||
>
|
||||
{{ icon "square-asterisk" }}
|
||||
</span>
|
||||
{% endif %} {% if question.community > 0 and show_community %}
|
||||
<a
|
||||
href="/api/v1/communities/find/{{ question.community }}"
|
||||
class="flex items-center"
|
||||
|
|
|
@ -45,6 +45,47 @@
|
|||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{% elif request.action_type == "Follow" %}
|
||||
<div class="card-nest">
|
||||
<div class="card small flex items-center gap-2">
|
||||
{{ icon "user-plus" }}
|
||||
<span>{{ text "requests:label.user_follow_request" }}</span>
|
||||
</div>
|
||||
|
||||
<div class="card flex flex-col gap-2">
|
||||
<span>
|
||||
{{ text "requests:label.user_follow_request_message" }}
|
||||
</span>
|
||||
|
||||
<div class="card flex w-full secondary gap-2">
|
||||
<a
|
||||
href="/api/v1/auth/user/find/{{ request.id }}"
|
||||
class="button"
|
||||
>
|
||||
{{ icon "external-link" }}
|
||||
<span
|
||||
>{{ text "requests:action.view_profile" }}</span
|
||||
>
|
||||
</a>
|
||||
|
||||
<button
|
||||
class="quaternary green"
|
||||
onclick="accept_follow_request(event, '{{ request.id }}')"
|
||||
>
|
||||
{{ icon "check" }}
|
||||
<span>{{ text "general:action.accept" }}</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
class="quaternary red"
|
||||
onclick="remove_request('{{ request.id }}', '{{ request.linked_asset }}')"
|
||||
>
|
||||
{{ icon "trash" }}
|
||||
<span>{{ text "general:action.delete" }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %} {% endfor %} {% for question in questions %}
|
||||
<!-- prettier-ignore -->
|
||||
<div class="card-nest">
|
||||
|
@ -147,5 +188,49 @@
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
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,
|
||||
]);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
|
131
crates/app/src/public/html/profile/private.html
Normal file
131
crates/app/src/public/html/profile/private.html
Normal file
|
@ -0,0 +1,131 @@
|
|||
{% extends "root.html" %} {% block head %}
|
||||
<title>{{ profile.username }} (private profile) - {{ config.name }}</title>
|
||||
{% endblock %} {% block body %} {{ macros::nav() }}
|
||||
<main class="flex flex-col gap-2">
|
||||
<div class="card-nest">
|
||||
<div class="card small flex items-center justify-between gap-2">
|
||||
<div class="flex items-center gap-2">
|
||||
{{ components::avatar(username=profile.username, size="24px") }}
|
||||
<span>{{ profile.username }}</span>
|
||||
</div>
|
||||
|
||||
<b class="notification chip"
|
||||
>{{ text "auth:label.private_profile" }}</b
|
||||
>
|
||||
</div>
|
||||
|
||||
<div class="card flex flex-col gap-2">
|
||||
<span>{{ text "auth:label.private_profile_message" }}</span>
|
||||
|
||||
<div class="card w-full secondary flex gap-2">
|
||||
{% if user %} {% if not is_following %}
|
||||
<button
|
||||
onclick="toggle_follow_user(event)"
|
||||
class="{% if follow_requested %} hidden{% endif %}"
|
||||
atto_tag="user.follow_request"
|
||||
>
|
||||
{{ icon "user-plus" }}
|
||||
<span>{{ text "auto:action.request_to_follow" }}</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
onclick="cancel_follow_user(event)"
|
||||
class="quaternary red{% if not follow_requested %} hidden{% endif %}"
|
||||
atto_tag="user.cancel_request"
|
||||
>
|
||||
{{ icon "user-minus" }}
|
||||
<span>{{ text "auto:action.cancel_follow_request" }}</span>
|
||||
</button>
|
||||
{% else %}
|
||||
<button
|
||||
onclick="toggle_follow_user(event)"
|
||||
class="quaternary red"
|
||||
atto_tag="user.unfollow"
|
||||
>
|
||||
{{ icon "user-minus" }}
|
||||
<span>{{ text "auto:action.unfollow" }}</span>
|
||||
</button>
|
||||
{% endif %}
|
||||
|
||||
<script>
|
||||
globalThis.toggle_follow_user = async (e) => {
|
||||
await trigger("atto::debounce", ["users::follow"]);
|
||||
fetch("/api/v1/auth/user/{{ profile.id }}/follow", {
|
||||
method: "POST",
|
||||
})
|
||||
.then((res) => res.json())
|
||||
.then((res) => {
|
||||
trigger("atto::toast", [
|
||||
res.ok ? "success" : "error",
|
||||
res.message,
|
||||
]);
|
||||
|
||||
if (
|
||||
e.target.getAttribute("atto_tag") ===
|
||||
"user.follow_request"
|
||||
) {
|
||||
document
|
||||
.querySelector(
|
||||
'[atto_tag="user.follow_request"]',
|
||||
)
|
||||
.classList.add("hidden");
|
||||
|
||||
document
|
||||
.querySelector(
|
||||
'[atto_tag="user.cancel_request"]',
|
||||
)
|
||||
.classList.remove("hidden");
|
||||
} else {
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
globalThis.cancel_follow_user = async (e) => {
|
||||
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/{{ profile.id }}/follow/cancel",
|
||||
{
|
||||
method: "POST",
|
||||
},
|
||||
)
|
||||
.then((res) => res.json())
|
||||
.then((res) => {
|
||||
trigger("atto::toast", [
|
||||
res.ok ? "success" : "error",
|
||||
res.message,
|
||||
]);
|
||||
|
||||
document
|
||||
.querySelector(
|
||||
'[atto_tag="user.cancel_request"]',
|
||||
)
|
||||
.classList.add("hidden");
|
||||
document
|
||||
.querySelector(
|
||||
'[atto_tag="user.follow_request"]',
|
||||
)
|
||||
.classList.remove("hidden");
|
||||
});
|
||||
};
|
||||
</script>
|
||||
{% endif %}
|
||||
|
||||
<a href="/" class="button red quaternary">
|
||||
{{ icon "x" }}
|
||||
<span>{{ text "general:action.back" }}</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
{% endblock %}
|
|
@ -4,7 +4,7 @@
|
|||
<main class="flex flex-col gap-2">
|
||||
{{ macros::timelines_nav(selected="popular") }} {{
|
||||
macros::timelines_secondary_nav(posts="/popular",
|
||||
questions="/popular/questions", selected="popular") }}
|
||||
questions="/popular/questions", selected="questions") }}
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
<div class="card w-full flex flex-col gap-2">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue