Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions rfd-api/src/endpoints/rfd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use crate::{
endpoints::UNLIMITED,
permissions::RfdPermission,
search::{MeiliSearchResult, SearchRequest},
util::response::{client_error, internal_error, unauthorized},
util::response::{client_error, internal_error, not_implemented, unauthorized},
};

#[derive(Debug, Deserialize, JsonSchema)]
Expand Down Expand Up @@ -180,7 +180,10 @@ pub async fn view_rfd_discussion(
rqctx: RequestContext<RfdContext>,
path: Path<RfdPathParams>,
) -> Result<HttpResponseOk<()>, HttpError> {
unimplemented!()
let ctx = rqctx.context();
let caller = ctx.v_ctx().get_caller(&rqctx).await?;
let path = path.into_inner();
view_rfd_discussion_op(ctx, &caller, path.number, None).await
}

// Specific RFD revision endpoints
Expand Down Expand Up @@ -295,7 +298,10 @@ pub async fn view_rfd_revision_discussion(
rqctx: RequestContext<RfdContext>,
path: Path<RfdRevisionPathParams>,
) -> Result<HttpResponseOk<()>, HttpError> {
unimplemented!()
let ctx = rqctx.context();
let caller = ctx.v_ctx().get_caller(&rqctx).await?;
let path = path.into_inner();
view_rfd_discussion_op(ctx, &caller, path.number, Some(path.revision.into())).await
}

#[derive(Debug, Deserialize, JsonSchema)]
Expand Down Expand Up @@ -486,15 +492,18 @@ async fn view_rfd_attr_op(
}
}

#[allow(dead_code)]
#[instrument(skip(_ctx, caller), fields(caller = ?caller.id), err(Debug))]
async fn view_rfd_discussion_op(
_ctx: &RfdContext,
caller: &Caller<RfdPermission>,
number: String,
revision: Option<RfdRevisionIdentifier>,
) -> Result<HttpResponseOk<RfdWithRaw>, HttpError> {
unimplemented!()
_number: String,
_revision: Option<RfdRevisionIdentifier>,
) -> Result<HttpResponseOk<()>, HttpError> {
// Discussion retrieval is not implemented. Respond with a well formed error rather than
// panicking, which drops the connection and leaves clients with an empty response body.
Err(not_implemented(
"RFD discussion retrieval is not implemented",
))
}

#[instrument(skip(ctx, caller), fields(caller = ?caller.id), err(Debug))]
Expand Down
16 changes: 15 additions & 1 deletion rfd-api/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

pub mod response {
use dropshot::{ClientErrorStatusCode, HttpError};
use dropshot::{ClientErrorStatusCode, ErrorStatusCode, HttpError};
use std::error::Error;
use tracing::instrument;

Expand Down Expand Up @@ -36,4 +36,18 @@ pub mod response {
tracing::error!(internal_message, "Request failed");
HttpError::for_internal_error(internal_message)
}

pub fn not_implemented<S>(message: S) -> HttpError
where
S: ToString,
{
let message = message.to_string();
HttpError {
status_code: ErrorStatusCode::NOT_IMPLEMENTED,
error_code: None,
external_message: message.clone(),
internal_message: message,
headers: None,
}
}
}
Loading