Skip to content

Commit

Permalink
fea(messages): use existing Attachment struct in delivery message
Browse files Browse the repository at this point in the history
Signed-off-by: Naian <126972030+nain-F49FF806@users.noreply.github.com>
  • Loading branch information
nain-F49FF806 committed Oct 19, 2023
1 parent e4a0028 commit 032d00f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 53 deletions.
32 changes: 0 additions & 32 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion messages/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,3 @@ messages_macros = { path = "../messages_macros" }
diddoc_legacy = { path = "../diddoc_legacy" }
shared_vcx = { path = "../shared_vcx" }
did_parser = { path = "../did_parser" }
serde_with = { version = "3.4.0", features = ["base64"] }
34 changes: 14 additions & 20 deletions messages/src/msg_fields/protocols/pickup/delivery.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use serde::{Deserialize, Serialize};
use serde_with::{base64::Base64, serde_as};
use typed_builder::TypedBuilder;

use crate::{
decorators::{thread::Thread, transport::Transport},
decorators::{attachment::Attachment, thread::Thread, transport::Transport},
msg_parts::MsgParts,
};

Expand All @@ -15,21 +14,7 @@ pub struct DeliveryContent {
#[serde(skip_serializing_if = "Option::is_none")]
pub recipient_key: Option<String>,
#[serde(rename = "~attach")]
pub attach: Vec<DeliveryAttach>,
}

#[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)]
pub struct DeliveryAttach {
#[serde(rename = "@id")]
pub id: String,
pub data: DeliveryAttachData,
}

#[serde_as]
#[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)]
pub struct DeliveryAttachData {
#[serde_as(as = "Base64")]
pub base64: Vec<u8>,
pub attach: Vec<Attachment>,
}

#[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)]
Expand All @@ -52,7 +37,12 @@ mod tests {

use super::*;
use crate::{
decorators::thread::Thread, misc::test_utils, msg_types::protocols::pickup::PickupTypeV2_0,
decorators::{
attachment::{AttachmentData, AttachmentType},
thread::Thread,
},
misc::test_utils,
msg_types::protocols::pickup::PickupTypeV2_0,
};
#[test]
fn test_delivery() {
Expand All @@ -72,9 +62,13 @@ mod tests {
}]
}
);
let attach = DeliveryAttach::builder()
let attach = Attachment::builder()
.id("<messageid>".to_owned())
.data(DeliveryAttachData::builder().base64("".into()).build())
.data(
AttachmentData::builder()
.content(AttachmentType::Base64("".into()))
.build(),
)
.build();
let content = DeliveryContent::builder()
.recipient_key("<key for messages>".to_owned())
Expand Down

0 comments on commit 032d00f

Please sign in to comment.