mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2024-12-28 14:38:52 +00:00
Can get information about a single conversation
This commit is contained in:
parent
619fc171e1
commit
b30dc049bf
@ -56,6 +56,7 @@ pub fn get_list(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
/// Get information about a single conversation
|
||||
pub fn get_single(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
let conversation_id = r.post_conv_id("conversationID")?;
|
||||
let conv = conversations_helper::get_single(conversation_id, r.user_id()?)?;
|
||||
|
||||
r.success("do it")
|
||||
r.set_response(ConversationAPI::new(&conv))
|
||||
}
|
@ -72,6 +72,25 @@ pub fn get_list_user(user_id: UserID) -> ResultBoxError<Vec<Conversation>> {
|
||||
.exec(db_to_conversation_info)
|
||||
}
|
||||
|
||||
/// Get information about a single conversation
|
||||
pub fn get_single(conv_id: u64, user_id: UserID) -> ResultBoxError<Conversation> {
|
||||
// Tables
|
||||
database::QueryInfo::new(CONV_LIST_TABLE)
|
||||
.alias("l")
|
||||
.join(CONV_USERS_TABLE, "u", "l.id = u.conv_id")
|
||||
|
||||
// Fields
|
||||
.add_field("*")
|
||||
.add_field("l.id as id")
|
||||
.add_field("l.user_id as owner_id")
|
||||
|
||||
// Conditions
|
||||
.cond_u64("l.id", conv_id)
|
||||
.cond_user_id("u.user_id", user_id)
|
||||
|
||||
.query_row(db_to_conversation_info)
|
||||
}
|
||||
|
||||
/// Get the list of members of a conversation
|
||||
pub fn get_list_members(conv_id: u64) -> ResultBoxError<Vec<UserID>> {
|
||||
database::QueryInfo::new(CONV_USERS_TABLE)
|
||||
|
Loading…
Reference in New Issue
Block a user