From 8908c8b1840f64f0bc82e37437703afed419f3f9 Mon Sep 17 00:00:00 2001 From: Felix Date: Fri, 17 Apr 2020 16:55:28 +0200 Subject: Some code cleanup and better logging --- server/src/apub/user_inbox.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'server/src/apub/user_inbox.rs') diff --git a/server/src/apub/user_inbox.rs b/server/src/apub/user_inbox.rs index 02517afe..3b8d1df3 100644 --- a/server/src/apub/user_inbox.rs +++ b/server/src/apub/user_inbox.rs @@ -6,21 +6,31 @@ use actix_web::{web, HttpResponse}; use diesel::r2d2::{ConnectionManager, Pool}; use diesel::PgConnection; use failure::Error; +use log::debug; +use serde::Deserialize; #[serde(untagged)] -#[derive(serde::Deserialize)] +#[derive(Deserialize, Debug)] pub enum UserAcceptedObjects { Create(Create), Update(Update), Accept(Accept), } +#[derive(Deserialize)] +pub struct Params { + user_name: String, +} + pub async fn user_inbox( input: web::Json, + params: web::Query, db: web::Data>>, ) -> Result { let input = input.into_inner(); let conn = &db.get().unwrap(); + debug!("User {} received activity: {:?}", ¶ms.user_name, &input); + match input { UserAcceptedObjects::Create(c) => handle_create(&c, conn), UserAcceptedObjects::Update(u) => handle_update(&u, conn), @@ -57,8 +67,8 @@ fn handle_update(update: &Update, conn: &PgConnection) -> Result Result { - println!("received accept: {:?}", &accept); +fn handle_accept(_accept: &Accept, _conn: &PgConnection) -> Result { + // TODO: make sure that we actually requested a follow // TODO: at this point, indicate to the user that they are following the community Ok(HttpResponse::Ok().finish()) } -- cgit v1.2.3