mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2024-11-23 05:49:22 +00:00
Export all conversation messages
This commit is contained in:
parent
1a7018b5e3
commit
30edf5f1a6
@ -4,6 +4,7 @@
|
|||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
use crate::api_data::comment_api::CommentAPI;
|
use crate::api_data::comment_api::CommentAPI;
|
||||||
|
use crate::api_data::conversation_message_api::ConversationMessageAPI;
|
||||||
use crate::api_data::movie_api::MovieAPI;
|
use crate::api_data::movie_api::MovieAPI;
|
||||||
use crate::api_data::post_api::PostAPI;
|
use crate::api_data::post_api::PostAPI;
|
||||||
use crate::api_data::survey_response_api::SurveyResponseAPI;
|
use crate::api_data::survey_response_api::SurveyResponseAPI;
|
||||||
@ -22,6 +23,7 @@ pub struct AccountExportAPI {
|
|||||||
likes: Vec<UserLikeAPI>,
|
likes: Vec<UserLikeAPI>,
|
||||||
survey_responses: Vec<SurveyResponseAPI>,
|
survey_responses: Vec<SurveyResponseAPI>,
|
||||||
movies: Vec<MovieAPI>,
|
movies: Vec<MovieAPI>,
|
||||||
|
all_conversation_messages: Vec<ConversationMessageAPI>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AccountExportAPI {
|
impl AccountExportAPI {
|
||||||
@ -35,6 +37,7 @@ impl AccountExportAPI {
|
|||||||
likes: UserLikeAPI::for_list(&export.likes),
|
likes: UserLikeAPI::for_list(&export.likes),
|
||||||
survey_responses: SurveyResponseAPI::for_list(&export.survey_responses),
|
survey_responses: SurveyResponseAPI::for_list(&export.survey_responses),
|
||||||
movies: MovieAPI::for_list(&export.movies),
|
movies: MovieAPI::for_list(&export.movies),
|
||||||
|
all_conversation_messages: ConversationMessageAPI::for_list(&export.all_conversation_messages),
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(export)
|
Ok(export)
|
||||||
|
@ -3,11 +3,12 @@
|
|||||||
//! @author Pierre Hubert
|
//! @author Pierre Hubert
|
||||||
|
|
||||||
use crate::data::comment::Comment;
|
use crate::data::comment::Comment;
|
||||||
|
use crate::data::conversation_message::ConversationMessage;
|
||||||
|
use crate::data::movie::Movie;
|
||||||
use crate::data::post::Post;
|
use crate::data::post::Post;
|
||||||
use crate::data::survey_response::SurveyResponse;
|
use crate::data::survey_response::SurveyResponse;
|
||||||
use crate::data::user::User;
|
use crate::data::user::User;
|
||||||
use crate::data::user_like::UserLike;
|
use crate::data::user_like::UserLike;
|
||||||
use crate::data::movie::Movie;
|
|
||||||
|
|
||||||
pub struct AccountExport {
|
pub struct AccountExport {
|
||||||
pub user: User,
|
pub user: User,
|
||||||
@ -16,4 +17,5 @@ pub struct AccountExport {
|
|||||||
pub likes: Vec<UserLike>,
|
pub likes: Vec<UserLike>,
|
||||||
pub survey_responses: Vec<SurveyResponse>,
|
pub survey_responses: Vec<SurveyResponse>,
|
||||||
pub movies: Vec<Movie>,
|
pub movies: Vec<Movie>,
|
||||||
|
pub all_conversation_messages: Vec<ConversationMessage>,
|
||||||
}
|
}
|
@ -6,7 +6,7 @@ use crate::data::error::{ExecError, ResultBoxError};
|
|||||||
use crate::data::new_account::NewAccount;
|
use crate::data::new_account::NewAccount;
|
||||||
use crate::data::user::UserID;
|
use crate::data::user::UserID;
|
||||||
use crate::data::user_token::UserAccessToken;
|
use crate::data::user_token::UserAccessToken;
|
||||||
use crate::helpers::{comments_helper, database, likes_helper, posts_helper, survey_helper, user_helper, movies_helper};
|
use crate::helpers::{comments_helper, conversations_helper, database, likes_helper, movies_helper, posts_helper, survey_helper, user_helper};
|
||||||
use crate::helpers::database::{DeleteQuery, InsertQuery, QueryInfo};
|
use crate::helpers::database::{DeleteQuery, InsertQuery, QueryInfo};
|
||||||
use crate::utils::crypt_utils::{crypt_pass, rand_str};
|
use crate::utils::crypt_utils::{crypt_pass, rand_str};
|
||||||
use crate::utils::date_utils::{mysql_date, time};
|
use crate::utils::date_utils::{mysql_date, time};
|
||||||
@ -200,6 +200,7 @@ pub fn export(user_id: &UserID) -> ResultBoxError<AccountExport> {
|
|||||||
likes: likes_helper::export_all_user(user_id)?,
|
likes: likes_helper::export_all_user(user_id)?,
|
||||||
survey_responses: survey_helper::export_all_user_responses(user_id)?,
|
survey_responses: survey_helper::export_all_user_responses(user_id)?,
|
||||||
movies: movies_helper::get_list_user(user_id)?,
|
movies: movies_helper::get_list_user(user_id)?,
|
||||||
|
all_conversation_messages: conversations_helper::export_all_user_messages(user_id)?,
|
||||||
|
|
||||||
//TODO : add other fields
|
//TODO : add other fields
|
||||||
};
|
};
|
||||||
|
@ -253,6 +253,13 @@ pub fn get_user_messages_for_conversations(conv_id: u64, user_id: &UserID) -> Re
|
|||||||
.exec(db_to_conversation_message)
|
.exec(db_to_conversation_message)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Export all the messages of a given user on all conversations
|
||||||
|
pub fn export_all_user_messages(user_id: &UserID) -> ResultBoxError<Vec<ConversationMessage>> {
|
||||||
|
database::QueryInfo::new(CONV_MESSAGES_TABLE)
|
||||||
|
.cond_user_id("user_id", user_id)
|
||||||
|
.exec(db_to_conversation_message)
|
||||||
|
}
|
||||||
|
|
||||||
/// Get the entire list of messages of a given conversation
|
/// Get the entire list of messages of a given conversation
|
||||||
pub fn get_all_messages(conv_id: u64) -> ResultBoxError<Vec<ConversationMessage>> {
|
pub fn get_all_messages(conv_id: u64) -> ResultBoxError<Vec<ConversationMessage>> {
|
||||||
database::QueryInfo::new(CONV_MESSAGES_TABLE)
|
database::QueryInfo::new(CONV_MESSAGES_TABLE)
|
||||||
|
Loading…
Reference in New Issue
Block a user