add: connect to socket by community

direct messages/groups connect by channel id, everything else should connect by channel with the "is_channel" header set to true
This commit is contained in:
trisua 2025-04-29 16:53:34 -04:00
parent c1c8cdbfcd
commit 0304461389
20 changed files with 241 additions and 160 deletions

View file

@ -63,7 +63,7 @@ pub async fn create_group_request(
// check for existing
if members.len() == 1 {
let other_user = members.get(0).unwrap().to_owned();
let other_user = members.first().unwrap().to_owned();
if let Ok(channel) = data.get_channel_by_owner_member(user.id, other_user).await {
return Json(ApiReturn {
ok: true,
@ -80,21 +80,18 @@ pub async fn create_group_request(
Err(e) => return Json(e.into()),
};
if other_user.settings.private_chats {
if data
if other_user.settings.private_chats && data
.get_userfollow_by_initiator_receiver(other_user.id, user.id)
.await
.is_err()
{
return Json(Error::NotAllowed.into());
}
.is_err() {
return Json(Error::NotAllowed.into());
}
}
// ...
let mut props = Channel::new(0, user.id, 0, req.title);
props.members = members;
let id = props.id.clone();
let id = props.id;
match data.create_channel(props).await {
Ok(_) => Json(ApiReturn {