Merge remote-tracking branch 'origin/master'

This commit is contained in:
M_Kececi
2026-05-22 14:57:34 +03:00
parent d886fba6de
commit 1f90b9f9ce
25 changed files with 2767 additions and 687 deletions

View File

@@ -36,31 +36,18 @@ func ensureMkMail(tx *sql.Tx, email string) error {
if errors.Is(err, sql.ErrNoRows) {
newID := utils.NewUUID()
_, err = tx.Exec(`
INSERT INTO mk_mail (
id,
email,
display_name,
"type",
is_primary,
external_id,
is_active,
created_at
)
VALUES ($1, $2, '', 'user', true, true, true, NOW())
`, newID, mail)
// Keep this insert intentionally minimal because mk_mail schema may vary between environments.
// Only rely on columns we already SELECT elsewhere (id/email/display_name/is_active).
_, err = tx.Exec(`INSERT INTO mk_mail (id, email, display_name, is_active) VALUES ($1, $2, '', true)`, newID, mail)
return err
}
// Exists: normalize + activate. Avoid touching created_at.
// Exists: normalize + activate.
_, err = tx.Exec(`
UPDATE mk_mail
SET
email = $2,
display_name = COALESCE(display_name, ''),
"type" = 'user',
is_primary = true,
external_id = true,
is_active = true
WHERE id::text = $1
`, id, mail)