From be858dc9cc281519f1270c0ec365302eac9d080a Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Fri, 5 Feb 2021 15:14:47 +0100 Subject: [PATCH] Add new TODOs --- src/controllers/user_ws_controller.rs | 2 ++ src/helpers/account_helper.rs | 3 ++- src/helpers/comments_helper.rs | 10 +++++++++- src/helpers/conversations_helper.rs | 17 +++++++++++++++-- src/helpers/notifications_helper.rs | 9 ++++++--- 5 files changed, 34 insertions(+), 7 deletions(-) diff --git a/src/controllers/user_ws_controller.rs b/src/controllers/user_ws_controller.rs index a6c6cd3..41a9f21 100644 --- a/src/controllers/user_ws_controller.rs +++ b/src/controllers/user_ws_controller.rs @@ -330,6 +330,8 @@ impl Actor for WsSession { } fn stopping(&mut self, ctx: &mut Self::Context) -> Running { + // TODO : send an event (user_ws_closed) + remove_connection(ctx.address()); Running::Stop } diff --git a/src/helpers/account_helper.rs b/src/helpers/account_helper.rs index 289d354..d6f027f 100644 --- a/src/helpers/account_helper.rs +++ b/src/helpers/account_helper.rs @@ -107,7 +107,8 @@ pub fn exists_mail(mail: &str) -> ResultBoxError { /// Destroy a given user login tokens pub fn destroy_login_tokens(id: &UserID, client: &APIClient) -> ResultBoxError<()> { - user_ws_controller::disconnect_user_from_client(id, client)?; + + // TODO : send an event (destroyed_login_tokens) database::delete(DeleteQuery::new(USER_ACCESS_TOKENS_TABLE) .cond_u32("service_id", client.id) diff --git a/src/helpers/comments_helper.rs b/src/helpers/comments_helper.rs index 5f15f6f..1d71302 100644 --- a/src/helpers/comments_helper.rs +++ b/src/helpers/comments_helper.rs @@ -23,6 +23,8 @@ pub fn create(c: &Comment) -> ResultBoxError { .insert()? .ok_or(ExecError::new("No ID returned after comment creation!"))?; + // TODO : emit an event + Ok(comment_id) } @@ -67,7 +69,11 @@ pub fn edit(comment_id: u64, new_content: &str) -> ResultBoxError { database::UpdateInfo::new(COMMENTS_TABLE) .cond_u64("ID", comment_id) .set_str("commentaire", new_content) - .exec() + .exec()?; + + // TODO : emit an event + + Ok(()) } /// Delete a single comment @@ -88,6 +94,8 @@ pub fn delete(c: &Comment) -> ResultBoxError { .cond_u64("ID", c.id) .exec()?; + // TODO : emit an event + Ok(()) } diff --git a/src/helpers/conversations_helper.rs b/src/helpers/conversations_helper.rs index 9f73766..4555476 100644 --- a/src/helpers/conversations_helper.rs +++ b/src/helpers/conversations_helper.rs @@ -322,6 +322,9 @@ pub fn send_message(msg: &NewConversationMessage) -> ResultBoxError<()> { .set_legacy_bool("saw_last_message", false) .exec()?; + // TODO : send an event (updated_number_unread_conversations) + // TODO : send an event (sent_conversation_message) + Ok(()) } @@ -330,7 +333,11 @@ pub fn update_message_content(msg_id: u64, new_content: &str) -> ResultBoxError< database::UpdateInfo::new(CONV_MESSAGES_TABLE) .cond_u64("id", msg_id) .set_str("message", new_content) - .exec() + .exec()?; + + // TODO : send an event (conv_message_updated) + + Ok(()) } /// Remove a message from a conversation @@ -348,6 +355,8 @@ pub fn delete_message(msg: &ConversationMessage) -> ResultBoxError<()> { .cond_u64("ID", msg.id) .exec()?; + // TODO : send en event (conv_message_deleted) + Ok(()) } @@ -395,7 +404,11 @@ pub fn mark_user_seen(conv_id: u64, user_id: &UserID) -> ResultBoxError<()> { .cond_user_id("user_id", user_id) .cond_legacy_bool("saw_last_message", false) .set_legacy_bool("saw_last_message", true) - .exec() + .exec()?; + + // TODO : push an event (updated_number_unread_conversations) + + Ok(()) } /// Remove a user from a conversation diff --git a/src/helpers/notifications_helper.rs b/src/helpers/notifications_helper.rs index 633dd42..d109a85 100644 --- a/src/helpers/notifications_helper.rs +++ b/src/helpers/notifications_helper.rs @@ -222,7 +222,7 @@ fn create(n: &PartialNotification) -> ResultBoxError { .add_values(notif_to_db(n, true)) .insert_drop_result()?; - // TODO : WebSocket : trigger notify system + // TODO : Send a notification (updated_number_conversations) Ok(()) } @@ -232,11 +232,14 @@ fn create(n: &PartialNotification) -> ResultBoxError { pub fn delete(notification: &PartialNotification) -> ResultBoxError { let conditions = notif_to_db(notification, false); - // Delete the notifications database::DeleteQuery::new(NOTIFICATIONS_TABLE) .add_conditions(conditions) - .exec() + .exec()?; + + // TODO : Send a notification (updated_number_conversations) + + OK(()) } /// Delete all the notifications of a given user