diff options
Diffstat (limited to 'src/micropub')
-rw-r--r-- | src/micropub/mod.rs | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/src/micropub/mod.rs b/src/micropub/mod.rs index fbab582..ac038f8 100644 --- a/src/micropub/mod.rs +++ b/src/micropub/mod.rs @@ -569,7 +569,8 @@ async fn _query<D: Storage>( QueryType::SyndicateTo ], "channels": channels, - "_kittybox_authority": user_authority.as_str() + "_kittybox_authority": user_authority.as_str(), + "syndicate-to": [] }).as_object().unwrap())) }, QueryType::Source => { @@ -596,17 +597,44 @@ async fn _query<D: Storage>( )) }, Err(err) => { - return Box::new(warp::reply::json(&MicropubError::new( + Box::new(warp::reply::json(&MicropubError::new( ErrorType::InternalServerError, &format!("Backend error: {}", err) ))) } } }, - None => todo!() + None => { + // Here, one should probably attempt to query at least the main feed and collect posts + // Using a pre-made query function can't be done because it does unneeded filtering + // Don't implement for now, this is optional + Box::new(warp::reply::with_status( + warp::reply::json(&MicropubError::new( + ErrorType::InvalidRequest, + "Querying for post list is not implemented yet." + )), + StatusCode::BAD_REQUEST + )) + } } }, - _ => todo!() + QueryType::Channel => { + let channels: Vec<MicropubChannel> = match db.get_channels(user_authority.as_str()).await { + Ok(chans) => chans, + Err(err) => return Box::new(warp::reply::with_status( + warp::reply::json(&MicropubError::new( + ErrorType::InternalServerError, + &format!("Error fetching channels: {}", err) + )), + StatusCode::INTERNAL_SERVER_ERROR + )) + }; + + Box::new(warp::reply::json(&json!({ "channels": channels }))) + }, + QueryType::SyndicateTo => { + Box::new(warp::reply::json(&json!({ "syndicate-to": [] }))) + } } } |