add: ability to mask your account when creating a question
This commit is contained in:
parent
973373426a
commit
0634819278
11 changed files with 125 additions and 79 deletions
|
@ -43,6 +43,7 @@ version = "1.0.0"
|
|||
"general:label.could_not_find_post" = "Could not find original post..."
|
||||
"general:label.timeline_end" = "That's a wrap!"
|
||||
"general:label.loading" = "Working on it!"
|
||||
"general:label.send_anonymously" = "Send anonymously"
|
||||
|
||||
"general:label.supporter_motivation" = "Become a supporter!"
|
||||
"general:action.become_supporter" = "Become supporter"
|
||||
|
|
|
@ -627,7 +627,7 @@
|
|||
(text "{%- endif %} {%- endmacro %} {% macro question(question, owner, show_community=true, secondary=false, profile=false) -%}")
|
||||
(div
|
||||
("class" "card question {% if secondary -%}secondary{%- endif %} flex gap-2")
|
||||
(text "{% if owner.id == 0 -%}")
|
||||
(text "{% if owner.id == 0 or question.context.mask_owner -%}")
|
||||
(span
|
||||
(text "{% if profile and profile.settings.anonymous_avatar_url -%}")
|
||||
(img
|
||||
|
@ -636,7 +636,7 @@
|
|||
("class" "avatar shadow")
|
||||
("loading" "lazy")
|
||||
("style" "--size: 52px"))
|
||||
(text "{% else %} {{ self::avatar(username=owner.username, selector_type=\"username\", size=\"52px\") }} {%- endif %}"))
|
||||
(text "{% else %} {{ self::avatar(username=\"anonymous\", selector_type=\"username\", size=\"52px\") }} {%- endif %}"))
|
||||
(text "{% else %}")
|
||||
(a
|
||||
("href" "/@{{ owner.username }}")
|
||||
|
@ -648,7 +648,7 @@
|
|||
("class" "flex items-center gap-2 flex-wrap")
|
||||
(span
|
||||
("class" "name")
|
||||
(text "{% if owner.id == 0 -%} {% if profile and profile.settings.anonymous_username -%}")
|
||||
(text "{% if owner.id == 0 or question.context.mask_owner -%} {% if profile and profile.settings.anonymous_username -%}")
|
||||
(span
|
||||
("class" "flex items-center gap-2")
|
||||
(b
|
||||
|
@ -696,7 +696,7 @@
|
|||
(text "{{ self::post_media(upload_ids=question.drawings) }}")
|
||||
; anonymous user ip thing
|
||||
; this is only shown if the post author is anonymous AND we are a helper
|
||||
(text "{% if is_helper and owner.id == 0 %}")
|
||||
(text "{% if is_helper and (owner.id == 0 or question.context.mask_owner) -%}")
|
||||
(details
|
||||
("class" "card tiny lowered w-full")
|
||||
(summary
|
||||
|
@ -705,12 +705,22 @@
|
|||
(span (text "View IP")))
|
||||
|
||||
(pre (code (text "{{ question.ip }}"))))
|
||||
(text "{% endif %}")
|
||||
|
||||
(text "{% if question.context.mask_owner -%}")
|
||||
(details
|
||||
("class" "card tiny lowered w-full")
|
||||
(summary
|
||||
("class" "w-full flex gap-2 flex-wrap items-center")
|
||||
(icon (text "venetian-mask"))
|
||||
(span (text "Unmask")))
|
||||
|
||||
(text "{{ self::full_username(user=owner) }}"))
|
||||
(text "{%- endif %} {%- endif %}")
|
||||
; ...
|
||||
(div
|
||||
("class" "flex gap-2 items-center justify-between"))))
|
||||
|
||||
(text "{%- endmacro %} {% macro create_question_form(receiver=\"0\", community=\"\", header=\"\", is_global=false, drawing_enabled=false) -%}")
|
||||
(text "{%- endmacro %} {% macro create_question_form(receiver=\"0\", community=\"\", header=\"\", is_global=false, drawing_enabled=false, allow_anonymous=false) -%}")
|
||||
(div
|
||||
("class" "card-nest")
|
||||
(div
|
||||
|
@ -741,6 +751,8 @@
|
|||
("required" "")
|
||||
("minlength" "2")
|
||||
("maxlength" "4096")))
|
||||
(div
|
||||
("class" "flex w-full justify-between gap-2 flex-collapse")
|
||||
(div
|
||||
("class" "flex gap-2")
|
||||
(button
|
||||
|
@ -786,6 +798,20 @@
|
|||
document.querySelector(\"[ui_ident=add_drawing]\").classList.remove(\"hidden\");
|
||||
document.querySelector(\"[ui_ident=remove_drawing]\").classList.add(\"hidden\");
|
||||
}"))
|
||||
(text "{%- endif %}"))
|
||||
|
||||
(text "{% if not is_global and allow_anonymous -%}")
|
||||
(div
|
||||
("class" "flex gap-2 items-center")
|
||||
(input
|
||||
("type" "checkbox")
|
||||
("name" "mask_owner")
|
||||
("id" "mask_owner")
|
||||
("class" "w-content"))
|
||||
|
||||
(label
|
||||
("for" "mask_owner")
|
||||
(b (str (text "general:label.send_anonymously")))))
|
||||
(text "{%- endif %}"))))
|
||||
|
||||
(script
|
||||
|
@ -811,6 +837,7 @@
|
|||
receiver: \"{{ receiver }}\",
|
||||
community: \"{{ community }}\",
|
||||
is_global: \"{{ is_global }}\" == \"true\",
|
||||
mask_owner: (e.target.mask_owner || { checked:false }).checked
|
||||
}),
|
||||
);
|
||||
|
||||
|
@ -1136,12 +1163,12 @@
|
|||
(str (text "general:link.reference")))
|
||||
|
||||
(button
|
||||
("onclick" "trigger('me::achievement', ['OpenTos']); Turbo.visit('{{ config.policies.terms_of_service }}')")
|
||||
("onclick" "trigger('me::achievement_link', ['OpenTos', '{{ config.policies.terms_of_service }}'])")
|
||||
(icon (text "heart-handshake"))
|
||||
(text "Terms of service"))
|
||||
|
||||
(button
|
||||
("onclick" "trigger('me::achievement', ['OpenPrivacyPolicy']); Turbo.visit('{{ config.policies.privacy }}')")
|
||||
("onclick" "trigger('me::achievement_link', ['OpenPrivacyPolicy', '{{ config.policies.privacy }}'])")
|
||||
(icon (text "cookie"))
|
||||
(text "Privacy policy"))
|
||||
(b ("class" "title") (str (text "general:label.account")))
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
(text "{% extends \"profile/base.html\" %} {% block content %} {% if profile.settings.enable_questions and (user or profile.settings.allow_anonymous_questions) %}")
|
||||
(div
|
||||
("style" "display: contents")
|
||||
(text "{{ components::create_question_form(receiver=profile.id, header=profile.settings.motivational_header, drawing_enabled=profile.settings.enable_drawings) }}"))
|
||||
(text "{{ components::create_question_form(receiver=profile.id, header=profile.settings.motivational_header, drawing_enabled=profile.settings.enable_drawings, allow_anonymous=profile.settings.allow_anonymous_questions) }}"))
|
||||
|
||||
(text "{%- endif %} {{ macros::profile_nav(selected=\"media\") }}")
|
||||
(div
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
(text "{% extends \"profile/base.html\" %} {% block content %} {% if profile.settings.enable_questions and (user or profile.settings.allow_anonymous_questions) %}")
|
||||
(div
|
||||
("style" "display: contents")
|
||||
(text "{{ components::create_question_form(receiver=profile.id, header=profile.settings.motivational_header, drawing_enabled=profile.settings.enable_drawings) }}"))
|
||||
(text "{{ components::create_question_form(receiver=profile.id, header=profile.settings.motivational_header, drawing_enabled=profile.settings.enable_drawings, allow_anonymous=profile.settings.allow_anonymous_questions) }}"))
|
||||
|
||||
(text "{%- endif %} {{ macros::profile_nav(selected=\"outbox\") }}")
|
||||
(div
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
(text "{% extends \"profile/base.html\" %} {% block content %} {% if profile.settings.enable_questions and (user or profile.settings.allow_anonymous_questions) %}")
|
||||
(div
|
||||
("style" "display: contents")
|
||||
(text "{{ components::create_question_form(receiver=profile.id, header=profile.settings.motivational_header, drawing_enabled=profile.settings.enable_drawings) }}"))
|
||||
(text "{{ components::create_question_form(receiver=profile.id, header=profile.settings.motivational_header, drawing_enabled=profile.settings.enable_drawings, allow_anonymous=profile.settings.allow_anonymous_questions) }}"))
|
||||
|
||||
(text "{%- endif %} {% if not tag and pinned|length != 0 -%}")
|
||||
(div
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
(text "{% extends \"profile/base.html\" %} {% block content %} {% if profile.settings.enable_questions and (user or profile.settings.allow_anonymous_questions) %}")
|
||||
(div
|
||||
("style" "display: contents")
|
||||
(text "{{ components::create_question_form(receiver=profile.id, header=profile.settings.motivational_header, drawing_enabled=profile.settings.enable_drawings) }}"))
|
||||
(text "{{ components::create_question_form(receiver=profile.id, header=profile.settings.motivational_header, drawing_enabled=profile.settings.enable_drawings, allow_anonymous=profile.settings.allow_anonymous_questions) }}"))
|
||||
|
||||
(text "{%- endif %} {{ macros::profile_nav(selected=\"replies\") }}")
|
||||
(div
|
||||
|
|
|
@ -342,7 +342,8 @@
|
|||
},
|
||||
);
|
||||
|
||||
self.define("achievement", async (_, name) => {
|
||||
self.define("achievement", (_, name) => {
|
||||
return new Promise((resolve) => {
|
||||
fetch("/api/v1/auth/user/me/achievement", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
|
@ -360,8 +361,16 @@
|
|||
res.message,
|
||||
]);
|
||||
}
|
||||
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
self.define("achievement_link", async (_, name, href) => {
|
||||
await self.achievement(name);
|
||||
Turbo.visit(href);
|
||||
});
|
||||
|
||||
self.define("report", (_, asset, asset_type) => {
|
||||
window.open(
|
||||
|
|
|
@ -92,6 +92,10 @@ pub async fn create_request(
|
|||
}
|
||||
}
|
||||
|
||||
if req.mask_owner && !req.is_global {
|
||||
props.context.mask_owner = true;
|
||||
}
|
||||
|
||||
match data
|
||||
.create_question(props, drawings.iter().map(|x| x.to_vec()).collect())
|
||||
.await
|
||||
|
|
|
@ -790,6 +790,8 @@ pub struct CreateQuestion {
|
|||
pub receiver: String,
|
||||
#[serde(default)]
|
||||
pub community: String,
|
||||
#[serde(default)]
|
||||
pub mask_owner: bool,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
|
|
|
@ -381,6 +381,9 @@ impl Question {
|
|||
pub struct QuestionContext {
|
||||
#[serde(default)]
|
||||
pub is_nsfw: bool,
|
||||
/// If the owner is shown as anonymous in the UI.
|
||||
#[serde(default)]
|
||||
pub mask_owner: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue