Merge branch 'serra-allgood/#754-display-error-for-duplicated-blocklist-email' of https://github.com/serra-allgood/Plume into gh-pr-818

This commit is contained in:
Ana Gelez 2020-11-22 12:43:46 +01:00
commit f28ab19dc0

View File

@ -210,12 +210,20 @@ pub fn add_email_blocklist(
form: LenientForm<NewBlocklistedEmail>,
rockets: PlumeRocket,
) -> Result<Flash<Redirect>, ErrorPage> {
BlocklistedEmail::insert(&*rockets.conn, form.0)?;
let result = BlocklistedEmail::insert(&*rockets.conn, form.0);
if let Err(Error::Db(_)) = result {
Ok(Flash::error(
Redirect::to(uri!(admin_email_blocklist: page = None)),
i18n!(rockets.intl.catalog, "Email already blocked")
))
} else {
Ok(Flash::success(
Redirect::to(uri!(admin_email_blocklist: page = None)),
i18n!(rockets.intl.catalog, "Email Blocked"),
))
}
}
#[get("/admin/emails?<page>")]
pub fn admin_email_blocklist(
_mod: Moderator,