Skip to content

Commit

Permalink
Use basic auth in publish requests
Browse files Browse the repository at this point in the history
Fixes #12
  • Loading branch information
ranfdev committed Nov 27, 2023
1 parent 80154ca commit 7d86e95
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions ntfy-daemon/src/system_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,16 @@ impl SubscriptionImpl {

fn _publish<'a>(&'a mut self, msg: &'a str) -> impl Future<Output = Result<(), capnp::Error>> {
let msg = msg.to_owned();
let req = self.env.http.post(&self.model.borrow().server).body(msg);
let server = &self.model.borrow().server;
let creds = self.env.credentials.get(server);
let mut req = self.env.http.post(server);
if let Some(creds) = creds {
req = req.basic_auth(creds.username, Some(creds.password));
}

async move {
info!("sending message");
let res = req.send().await;
let res = req.body(msg).send().await;
match res {
Err(e) => Err(capnp::Error::failed(e.to_string())),
Ok(res) => {
Expand Down

0 comments on commit 7d86e95

Please sign in to comment.