Skip to content

Commit 27f1415

Browse files
authored
Add enabled to MailContext (#2107)
1 parent 38d6e46 commit 27f1415

5 files changed

Lines changed: 39 additions & 25 deletions

.sqlx/query-7da77fd66308e3e5bc4c45855532718f0f441b30a6643dbec7bc0d9129a6d948.json renamed to .sqlx/query-0b752b8845dce49b701f3d46f1c7af3e036045d793d13ceb61c99ce0844ad753.json

Lines changed: 8 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.lock

Lines changed: 20 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/defguard_mail/src/mail_context.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ pub(crate) struct MailContext {
1111
language_tag: String,
1212
/// Text to be replaced.
1313
pub(crate) text: String,
14+
#[allow(unused)]
15+
enabled: bool,
1416
}
1517

1618
impl MailContext {
@@ -19,7 +21,7 @@ impl MailContext {
1921
// E: PgExecutor<'e>,
2022
// {
2123
// query_scalar!(
22-
// "INSERT INTO mail_context (template, section, language_tag, text) \
24+
// "INSERT INTO mail_context (template, section, language_tag, text, enabled) \
2325
// VALUES ($1, $2, $3, $4) \
2426
// ON CONFLICT ON CONSTRAINT template_section_language DO \
2527
// UPDATE SET text = $4",
@@ -44,8 +46,8 @@ impl MailContext {
4446
{
4547
query_as!(
4648
Self,
47-
"SELECT template, section, language_tag, text FROM mail_context \
48-
WHERE template = $1 AND language_tag = $2",
49+
"SELECT template, section, language_tag, text, enabled FROM mail_context \
50+
WHERE template = $1 AND language_tag = $2 AND enabled",
4951
template,
5052
language_tag
5153
)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ALTER TABLE mail_context
2+
DROP COLUMN enabled,
3+
ADD CONSTRAINT template_section_language UNIQUE (template, section, language_tag);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ALTER TABLE mail_context
2+
ADD COLUMN enabled BOOL NOT NULL DEFAULT true,
3+
DROP CONSTRAINT template_section_language;

0 commit comments

Comments
 (0)