fix: correctly create SMTP provider list (#8724)

# Which Problems Are Solved

https://github.com/zitadel/zitadel/pull/8545 incorrectly created the
list of current smtp providers, if an SMTP provider was changed, that
was created before https://github.com/zitadel/zitadel/pull/6932 /
[v2.50.0](https://github.com/zitadel/zitadel/releases/tag/v2.50.0)).
This led to problems when trying to send emails to users (email
verification and OTP email).

# How the Problems Are Solved

Correctly handle events of old SMTP configurations, which do not have an
id set.

# Additional Changes

None

# Additional Context

- relates to #8545
- support requests from cloud customers

(cherry picked from commit 0bcf136f6f)
This commit is contained in:
Stefan Benz
2024-10-04 11:34:44 +02:00
committed by Livio Spring
parent 5215d98a30
commit 1f07d4128f
3 changed files with 240 additions and 103 deletions

View File

@@ -14,26 +14,26 @@ import (
)
var (
prepareSMTPConfigStmt = `SELECT projections.smtp_configs4.creation_date,` +
` projections.smtp_configs4.change_date,` +
` projections.smtp_configs4.resource_owner,` +
` projections.smtp_configs4.sequence,` +
` projections.smtp_configs4.id,` +
` projections.smtp_configs4.state,` +
` projections.smtp_configs4.description,` +
` projections.smtp_configs4_smtp.id,` +
` projections.smtp_configs4_smtp.tls,` +
` projections.smtp_configs4_smtp.sender_address,` +
` projections.smtp_configs4_smtp.sender_name,` +
` projections.smtp_configs4_smtp.reply_to_address,` +
` projections.smtp_configs4_smtp.host,` +
` projections.smtp_configs4_smtp.username,` +
` projections.smtp_configs4_smtp.password,` +
` projections.smtp_configs4_http.id,` +
` projections.smtp_configs4_http.endpoint` +
` FROM projections.smtp_configs4` +
` LEFT JOIN projections.smtp_configs4_smtp ON projections.smtp_configs4.id = projections.smtp_configs4_smtp.id AND projections.smtp_configs4.instance_id = projections.smtp_configs4_smtp.instance_id` +
` LEFT JOIN projections.smtp_configs4_http ON projections.smtp_configs4.id = projections.smtp_configs4_http.id AND projections.smtp_configs4.instance_id = projections.smtp_configs4_http.instance_id` +
prepareSMTPConfigStmt = `SELECT projections.smtp_configs5.creation_date,` +
` projections.smtp_configs5.change_date,` +
` projections.smtp_configs5.resource_owner,` +
` projections.smtp_configs5.sequence,` +
` projections.smtp_configs5.id,` +
` projections.smtp_configs5.state,` +
` projections.smtp_configs5.description,` +
` projections.smtp_configs5_smtp.id,` +
` projections.smtp_configs5_smtp.tls,` +
` projections.smtp_configs5_smtp.sender_address,` +
` projections.smtp_configs5_smtp.sender_name,` +
` projections.smtp_configs5_smtp.reply_to_address,` +
` projections.smtp_configs5_smtp.host,` +
` projections.smtp_configs5_smtp.username,` +
` projections.smtp_configs5_smtp.password,` +
` projections.smtp_configs5_http.id,` +
` projections.smtp_configs5_http.endpoint` +
` FROM projections.smtp_configs5` +
` LEFT JOIN projections.smtp_configs5_smtp ON projections.smtp_configs5.id = projections.smtp_configs5_smtp.id AND projections.smtp_configs5.instance_id = projections.smtp_configs5_smtp.instance_id` +
` LEFT JOIN projections.smtp_configs5_http ON projections.smtp_configs5.id = projections.smtp_configs5_http.id AND projections.smtp_configs5.instance_id = projections.smtp_configs5_http.instance_id` +
` AS OF SYSTEM TIME '-1 ms'`
prepareSMTPConfigCols = []string{
"creation_date",