Skip to content

Commit

Permalink
Save responses to cache
Browse files Browse the repository at this point in the history
  • Loading branch information
damccull committed Jun 24, 2023
1 parent 5342823 commit 6b1585c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions zero2prod/src/routes/admin/newsletters/post.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::{
e400, e500,
email_client::EmailClient,
error::ResponseError,
idempotency::{get_saved_response, IdempotencyKey},
idempotency::{get_saved_response, save_response, IdempotencyKey},
};

use newsletter_types::*;
Expand Down Expand Up @@ -89,8 +89,11 @@ pub async fn publish_newsletter(
}
}
let flash = flash.info(PUBLISH_SUCCESS_INFO_MESSAGE);

Ok((flash, Redirect::to("/admin/newsletters")).into_response())
let response = (flash, Redirect::to("/admin/newsletters")).into_response();
let response = save_response(&db_pool, &idempotency_key, *user_id, response)
.await
.map_err(e500)?;
Ok(response)
}

#[tracing::instrument(name = "Get confirmed subscribers", skip(db_pool))]
Expand Down

0 comments on commit 6b1585c

Please sign in to comment.