mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2024-12-28 14:38:52 +00:00
Auto-create conversation
This commit is contained in:
parent
633974a401
commit
e71b5bcc83
@ -135,12 +135,22 @@ pub fn find_private(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
let allow_create = r.post_bool_opt("allowCreate", false);
|
||||
|
||||
// Query the database
|
||||
let list = conversations_helper::find_private(r.user_id()?, other_user)?;
|
||||
let mut list = conversations_helper::find_private(r.user_id()?, other_user)?;
|
||||
|
||||
if list.is_empty() {
|
||||
if !allow_create {
|
||||
return r.not_found(format!("Not any private conversation was found. The server was not allowed to create a new one..."));
|
||||
}
|
||||
|
||||
let new_conv = NewConversation {
|
||||
owner_id: r.user_id()?,
|
||||
name: None,
|
||||
owner_following: true,
|
||||
members: vec![r.user_id()?, other_user],
|
||||
can_everyone_add_members: true,
|
||||
};
|
||||
let conv_id = conversations_helper::create(&new_conv)?;
|
||||
list.push(conv_id);
|
||||
}
|
||||
|
||||
r.set_response(ResFindPrivateConversations::new(list))
|
||||
|
Loading…
Reference in New Issue
Block a user