fix: don't allow users to create chats with themselves

This commit is contained in:
trisua 2025-09-07 11:18:54 -04:00
parent 361d3d8e30
commit 3942ad5a19
2 changed files with 5 additions and 1 deletions

View file

@ -60,7 +60,7 @@
(div
("class" "card banner")
(img
("src" "{{ config.service_hosts.buckets }}/banners/{{ profile.id }}")))
("src" "{{ config.service_hosts.buckets|safe }}/banners/{{ profile.id }}")))
(div
("class" "card flex flex_col gap_ch")
(text "{{ components::avatar(id=profile.id, size=\"160px\") }}")

View file

@ -43,6 +43,10 @@ pub async fn create_request(
};
req.members.dedup();
if req.members.contains(&user.username) {
return Json(Error::MiscError("Cannot create a chat with yourself".to_string()).into());
}
if (req.members.len() > 2 && req.style == ChatStyle::Direct)
| (req.members.len() >= GC_MAXIMUM_MEMBERS && req.style != ChatStyle::Direct)
{