fix: don't allow communities to be renamed to in-use names
This commit is contained in:
parent
5995aaf31c
commit
e092d46586
7 changed files with 50 additions and 11 deletions
|
@ -211,7 +211,7 @@
|
|||
{% endif %} {% endif %} {% if can_manage_community or
|
||||
is_manager %}
|
||||
<a
|
||||
href="/community/{{ community.title }}/manage"
|
||||
href="/community/{{ community.id }}/manage"
|
||||
class="button primary"
|
||||
>
|
||||
{{ icon "settings" }}
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
{% if can_manage_roles %}
|
||||
<a
|
||||
href="/community/{{ community.title }}/manage?uid={{ item[1].id }}#/members"
|
||||
href="/community/{{ community.id }}/manage?uid={{ item[1].id }}#/members"
|
||||
class="button small quaternary"
|
||||
>
|
||||
{{ icon "pencil" }}
|
||||
|
|
|
@ -94,7 +94,7 @@ pub async fn update_title_request(
|
|||
None => return Json(Error::NotAllowed.into()),
|
||||
};
|
||||
|
||||
match data.update_community_title(id, user, req.title).await {
|
||||
match data.update_community_title(id, user, &req.title).await {
|
||||
Ok(_) => Json(ApiReturn {
|
||||
ok: true,
|
||||
message: "Community updated".to_string(),
|
||||
|
|
|
@ -369,10 +369,10 @@ pub async fn feed_request(
|
|||
))
|
||||
}
|
||||
|
||||
/// `/community/{title}/manage`
|
||||
/// `/community/{id}/manage`
|
||||
pub async fn settings_request(
|
||||
jar: CookieJar,
|
||||
Path(title): Path<String>,
|
||||
Path(id): Path<usize>,
|
||||
Extension(data): Extension<State>,
|
||||
) -> impl IntoResponse {
|
||||
let data = data.read().await;
|
||||
|
@ -385,7 +385,7 @@ pub async fn settings_request(
|
|||
}
|
||||
};
|
||||
|
||||
let community = match data.0.get_community_by_title(&title.to_lowercase()).await {
|
||||
let community = match data.0.get_community_by_id_no_void(id).await {
|
||||
Ok(ua) => ua,
|
||||
Err(e) => return Err(Html(render_error(e, &jar, &data, &Some(user)).await)),
|
||||
};
|
||||
|
|
|
@ -55,10 +55,7 @@ pub fn routes() -> Router {
|
|||
get(communities::create_post_request),
|
||||
)
|
||||
.route("/community/{title}", get(communities::feed_request))
|
||||
.route(
|
||||
"/community/{title}/manage",
|
||||
get(communities::settings_request),
|
||||
)
|
||||
.route("/community/{id}/manage", get(communities::settings_request))
|
||||
.route(
|
||||
"/community/{title}/members",
|
||||
get(communities::members_request),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue