mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2024-11-26 07:19:22 +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);
|
let allow_create = r.post_bool_opt("allowCreate", false);
|
||||||
|
|
||||||
// Query the database
|
// 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 list.is_empty() {
|
||||||
if !allow_create {
|
if !allow_create {
|
||||||
return r.not_found(format!("Not any private conversation was found. The server was not allowed to create a new one..."));
|
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))
|
r.set_response(ResFindPrivateConversations::new(list))
|
||||||
|
Loading…
Reference in New Issue
Block a user