Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Leshiy committed Jan 14, 2025
1 parent d5d5780 commit 0bee3fc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
4 changes: 2 additions & 2 deletions catalyst-gateway/bin/src/service/api/documents/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use put_document::MAXIMUM_DOCUMENT_SIZE;

use crate::service::{
common::{
auth::{none_or_rbac::NoneOrRBAC, rbac::scheme::CatalystRBACSecurityScheme},
auth::none_or_rbac::NoneOrRBAC,
objects::document::bad_put_request::PutDocumentBadRequest,
tags::ApiTags,
types::{generic::uuidv7::UUIDv7, payload::cbor::Cbor},
Expand Down Expand Up @@ -71,7 +71,7 @@ impl DocumentApi {
&self, /// The document to PUT
cbor: Cbor,
/// Authorization required.
_auth: CatalystRBACSecurityScheme,
_auth: NoneOrRBAC,
) -> put_document::AllResponses {
match cbor.into_bytes_with_limit(MAXIMUM_DOCUMENT_SIZE).await {
Ok(doc_bytes) => put_document::endpoint(doc_bytes).await,
Expand Down
20 changes: 18 additions & 2 deletions catalyst-gateway/bin/src/service/api/documents/put_document.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Implementation of the PUT `/document` endpoint
use anyhow::anyhow;
use catalyst_signed_doc::CatalystSignedDocument;
use poem_openapi::{payload::Json, ApiResponse};

Expand Down Expand Up @@ -49,8 +50,23 @@ pub(crate) async fn endpoint(doc_bytes: Vec<u8>) -> AllResponses {
.into_iter()
.map(|kid| kid.to_string())
.collect();
let doc_body =
SignedDocBody::new(doc.doc_id(), doc.doc_ver(), doc.doc_type(), authors, None);

let doc_meta_json = match serde_json::to_value(doc.doc_meta()) {
Ok(json) => json,
Err(e) => {
return AllResponses::internal_error(&anyhow!(
"Cannot decode document metadata into JSON, err: {e}"
))
},
};

let doc_body = SignedDocBody::new(
doc.doc_id(),
doc.doc_ver(),
doc.doc_type(),
authors,
Some(doc_meta_json),
);

let payload = if doc.doc_content().is_json() {
match serde_json::from_slice(doc.doc_content().bytes()) {
Expand Down

0 comments on commit 0bee3fc

Please sign in to comment.