From 22ce88ee5383dfa5bceb22dcef0f6b27ff60bb35 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Fri, 10 Jul 2020 10:29:32 +0200 Subject: [PATCH] Can update like status of a post --- src/controllers/likes_controller.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/controllers/likes_controller.rs b/src/controllers/likes_controller.rs index b407d2c..a56862c 100644 --- a/src/controllers/likes_controller.rs +++ b/src/controllers/likes_controller.rs @@ -3,10 +3,11 @@ //! @author Pierre Hubert use crate::controllers::routes::RequestResult; -use crate::data::http_request_handler::HttpRequestHandler; use crate::data::error::ExecError; +use crate::data::http_request_handler::HttpRequestHandler; +use crate::data::post::PostAccessLevel; +use crate::helpers::{likes_helper, user_helper}; use crate::helpers::likes_helper::LikeType; -use crate::helpers::{user_helper, likes_helper}; struct LikeTarget(u64, LikeType); @@ -29,6 +30,15 @@ pub fn update(r: &mut HttpRequestHandler) -> RequestResult { } + // In case of post + "post" => { + let post = r.post_post_with_access("id", PostAccessLevel::BASIC_ACCESS)?; + + // TODO : delete any notification targeting this user about the post + + LikeTarget(post.id, LikeType::POST) + } + _ => { r.internal_error(ExecError::boxed_new("Unsupported like type!"))?; unreachable!();