M res/lang/en.ftl => res/lang/en.ftl +10 -1
@@ 9,9 9,13 @@ action_flag = flag
add = Add
add_by_remote_id = Add by ID:
administration = Administration
+administration_community_creation_requirement = Communities can be created by
administration_edit = Edit Instance Details
-administration_signup_allowed = Signups are currently
+administration_edit_invitations_enabled = Invitations:
administration_edit_signup_allowed = Public Signups:
+administration_invitation_creation_requirement = Invitations can be created by
+administration_invitations_enabled = Invitations are currently
+administration_signup_allowed = Signups are currently
all = All
all_title = The Whole Known Network
allowed_false = not allowed
@@ 51,6 55,8 @@ delete = delete
delete_yes = Yes, delete
description = Description
edit = Edit
+enabled_true = enabled
+enabled_false = disabled
fetch = Fetch
flag_comment_prompt = Add a comment:
flag_dismiss = Dismiss
@@ 157,6 163,8 @@ remove_upvote = Remove upvote
reply = reply
reply_submit = Reply
reply_to = Reply to
+requirement_none = all users
+requirement_site_admin = site admins
save = Save
score = { $score } { $score ->
[one] like
@@ 222,6 230,7 @@ title = Title
to = to
to_parent = View Parent
to_post = Comment on
+unknown = [unknown]
upvote = Upvote
url = URL
user_bot_tag = bot
M src/resp_types.rs => src/resp_types.rs +5 -0
@@ 297,6 297,11 @@ pub struct RespInstanceInfo<'a> {
pub description: Content<'a>,
pub software: RespInstanceSoftwareInfo<'a>,
pub signup_allowed: bool,
+ pub invitations_enabled: bool,
+ pub community_creation_requirement: Option<Cow<'a, str>>,
+ pub invitation_creation_requirement: Option<Cow<'a, str>>,
+
+ pub web_push_vapid_key: Cow<'a, str>,
}
#[derive(Deserialize, Debug)]
M src/routes/administration.rs => src/routes/administration.rs +119 -21
@@ 60,6 60,40 @@ async fn page_administration(
&lang::ALLOWED_FALSE
})}</strong>
</li>
+ <li>
+ {lang.tr(&lang::ADMINISTRATION_INVITATIONS_ENABLED)}{" "}
+ <strong>{lang.tr(if api_res.invitations_enabled {
+ &lang::ENABLED_TRUE
+ } else {
+ &lang::ENABLED_FALSE
+ })}</strong>
+ {
+ if api_res.invitations_enabled {
+ Some(render::rsx! {
+ <ul>
+ <li>
+ {lang.tr(&lang::ADMINISTRATION_INVITATION_CREATION_REQUIREMENT)}{" "}
+ <strong>{lang.tr(match api_res.invitation_creation_requirement.as_deref() {
+ None => &lang::REQUIREMENT_NONE,
+ Some("site_admin") => &lang::REQUIREMENT_SITE_ADMIN,
+ Some(_) => &lang::UNKNOWN,
+ })}</strong>
+ </li>
+ </ul>
+ })
+ } else {
+ None
+ }
+ }
+ </li>
+ <li>
+ {lang.tr(&lang::ADMINISTRATION_COMMUNITY_CREATION_REQUIREMENT)}{" "}
+ <strong>{lang.tr(match api_res.community_creation_requirement.as_deref() {
+ None => &lang::REQUIREMENT_NONE,
+ Some("site_admin") => &lang::REQUIREMENT_SITE_ADMIN,
+ Some(_) => &lang::UNKNOWN,
+ })}</strong>
+ </li>
</ul>
</HTPage>
}))
@@ 113,6 147,19 @@ async fn page_administration_edit_inner(
let api_res: RespInstanceInfo = serde_json::from_slice(&api_res)?;
let signup_allowed_value = Some(crate::bool_as_str(api_res.signup_allowed));
+ let invitations_enabled_value = Some(crate::bool_as_str(api_res.invitations_enabled));
+ let invitation_creation_requirement_value = Some(
+ api_res
+ .invitation_creation_requirement
+ .as_deref()
+ .unwrap_or(""),
+ );
+ let community_creation_requirement_value = Some(
+ api_res
+ .community_creation_requirement
+ .as_deref()
+ .unwrap_or(""),
+ );
let (description_content, description_format) = match api_res.description.content_markdown {
Some(content) => (content, "markdown"),
@@ 133,18 180,58 @@ async fn page_administration_edit_inner(
})
}
<form method={"POST"} action={"/administration/edit/submit"}>
- <label>
- {lang.tr(&lang::administration_edit_signup_allowed())}<br />
- <select name={"signup_allowed"}>
- <MaybeFillOption value={"true"} values={&prev_values} default_value={signup_allowed_value} name={"signup_allowed"}>
- {lang.tr(&lang::allowed_true())}
- </MaybeFillOption>
- <MaybeFillOption value={"false"} values={&prev_values} default_value={signup_allowed_value} name={"signup_allowed"}>
- {lang.tr(&lang::allowed_false())}
- </MaybeFillOption>
- </select>
- </label>
- <br />
+ <div>
+ <label>
+ {lang.tr(&lang::administration_edit_signup_allowed())}<br />
+ <select name={"signup_allowed"}>
+ <MaybeFillOption value={"true"} values={&prev_values} default_value={signup_allowed_value} name={"signup_allowed"}>
+ {lang.tr(&lang::allowed_true())}
+ </MaybeFillOption>
+ <MaybeFillOption value={"false"} values={&prev_values} default_value={signup_allowed_value} name={"signup_allowed"}>
+ {lang.tr(&lang::allowed_false())}
+ </MaybeFillOption>
+ </select>
+ </label>
+ </div>
+ <div>
+ <label>
+ {lang.tr(&lang::administration_edit_invitations_enabled())}<br />
+ <select name={"invitations_enabled"}>
+ <MaybeFillOption value={"true"} values={&prev_values} default_value={invitations_enabled_value} name={"invitations_enabled"}>
+ {lang.tr(&lang::enabled_true())}
+ </MaybeFillOption>
+ <MaybeFillOption value={"false"} values={&prev_values} default_value={invitations_enabled_value} name={"invitations_enabled"}>
+ {lang.tr(&lang::enabled_false())}
+ </MaybeFillOption>
+ </select>
+ </label>
+ </div>
+ <div>
+ <label>
+ {lang.tr(&lang::administration_invitation_creation_requirement())}{":"}<br />
+ <select name={"invitation_creation_requirement"}>
+ <MaybeFillOption value={""} values={&prev_values} default_value={invitation_creation_requirement_value} name={"invitation_creation_requirement"}>
+ {lang.tr(&lang::requirement_none())}
+ </MaybeFillOption>
+ <MaybeFillOption value={"site_admin"} values={&prev_values} default_value={invitation_creation_requirement_value} name={"invitation_creation_requirement"}>
+ {lang.tr(&lang::requirement_site_admin())}
+ </MaybeFillOption>
+ </select>
+ </label>
+ </div>
+ <div>
+ <label>
+ {lang.tr(&lang::administration_community_creation_requirement())}{":"}<br />
+ <select name={"community_creation_requirement"}>
+ <MaybeFillOption value={""} values={&prev_values} default_value={community_creation_requirement_value} name={"community_creation_requirement"}>
+ {lang.tr(&lang::requirement_none())}
+ </MaybeFillOption>
+ <MaybeFillOption value={"site_admin"} values={&prev_values} default_value={community_creation_requirement_value} name={"community_creation_requirement"}>
+ {lang.tr(&lang::requirement_site_admin())}
+ </MaybeFillOption>
+ </select>
+ </label>
+ </div>
<label>
{lang.tr(&lang::description())}
<br />
@@ 184,15 271,26 @@ async fn handler_administration_edit_submit(
serde_urlencoded::from_bytes(&body)?;
let mut body = body_original.clone();
- body.insert(
- "signup_allowed".into(),
- body.get("signup_allowed")
- .and_then(|x| x.as_str())
- .ok_or(crate::Error::InternalStrStatic(
- "Failed to extract signup_allowed in administration edit",
- ))?
- .parse()?,
- );
+ for key in ["signup_allowed", "invitations_enabled"] {
+ body.insert(
+ key.into(),
+ body.get(key)
+ .and_then(|x| x.as_str())
+ .ok_or(crate::Error::InternalStrStatic(
+ "Failed to extract value in administration edit",
+ ))?
+ .parse()?,
+ );
+ }
+
+ for key in [
+ "invitation_creation_requirement",
+ "community_creation_requirement",
+ ] {
+ if body.get(key).and_then(|x| x.as_str()) == Some("") {
+ body.insert(key.into(), serde_json::Value::Null);
+ }
+ }
if let Some(content) = body.remove("description") {
let content = content.as_str().ok_or(crate::Error::InternalStrStatic(