diff --git a/peach-web/src/context/sbot.rs b/peach-web/src/context/sbot.rs index 2bb5b63..c745501 100644 --- a/peach-web/src/context/sbot.rs +++ b/peach-web/src/context/sbot.rs @@ -468,6 +468,8 @@ pub struct PrivateContext { pub sbot_status: Option, // local peer id (whoami) pub id: Option, + // id of the peer being messaged + pub recipient_id: Option, } impl PrivateContext { @@ -481,10 +483,11 @@ impl PrivateContext { sbot_config: None, sbot_status: None, id: None, + recipient_id: None, } } - pub async fn build() -> Result { + pub async fn build(recipient_id: Option) -> Result { let mut context = Self::default(); // retrieve current ui theme @@ -500,6 +503,8 @@ impl PrivateContext { let mut sbot_client = init_sbot_with_config(&sbot_config).await?; + context.recipient_id = recipient_id; + let local_id = sbot_client.whoami().await?; context.id = Some(local_id); } else { diff --git a/peach-web/src/routes/scuttlebutt.rs b/peach-web/src/routes/scuttlebutt.rs index 9ed2d49..04d537c 100644 --- a/peach-web/src/routes/scuttlebutt.rs +++ b/peach-web/src/routes/scuttlebutt.rs @@ -102,10 +102,19 @@ pub async fn create_invite(invite: Form, _auth: Authenticated) -> Flash< // HELPERS AND ROUTES FOR /private /// A private message composition and publication page. -#[get("/private")] -pub async fn private(flash: Option>, _auth: Authenticated) -> Template { +#[get("/private?")] +pub async fn private( + mut public_key: Option, + flash: Option>, + _auth: Authenticated, +) -> Template { + if let Some(ref key) = public_key { + // `url_decode` replaces '+' with ' ', so we need to revert that + public_key = Some(key.replace(' ', "+")); + } + // build the private context object - let context = PrivateContext::build().await; + let context = PrivateContext::build(public_key).await; match context { // we were able to build the context without errors @@ -141,7 +150,7 @@ pub struct Private { /// Publish a private message. #[post("/private", data = "")] pub async fn private_post(private: Form, _auth: Authenticated) -> Flash { - let url = uri!("/scuttlebutt", private); + let url = uri!("/scuttlebutt", private(None::)); // retrieve go-sbot systemd process status let sbot_status = match SbotStatus::read() { diff --git a/peach-web/templates/scuttlebutt/private.html.tera b/peach-web/templates/scuttlebutt/private.html.tera index b626299..45c6f72 100644 --- a/peach-web/templates/scuttlebutt/private.html.tera +++ b/peach-web/templates/scuttlebutt/private.html.tera @@ -6,10 +6,10 @@
- +
- +
diff --git a/peach-web/templates/scuttlebutt/profile.html.tera b/peach-web/templates/scuttlebutt/profile.html.tera index 9237134..a4cde01 100644 --- a/peach-web/templates/scuttlebutt/profile.html.tera +++ b/peach-web/templates/scuttlebutt/profile.html.tera @@ -63,7 +63,7 @@ {% else %}

Unable to determine block state

{% endif %} - Send Private Message + Send Private Message {%- endif %} {%- endif %}