mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-13 19:44:21 +00:00
bdf3887f9e
* feat: default custom message text * feat: org custom message text * feat: org custom message text * feat: custom messages query side * feat: default messages * feat: message text user fields * feat: check for inactive user * feat: fix send password reset * feat: fix custom org text * feat: add variables to docs * feat: custom text tests * feat: fix notifications * feat: add custom text feature * feat: add custom text feature * feat: feature in custom message texts * feat: add custom text feature in frontend * feat: merge main * feat: feature tests * feat: change phone message in setup * fix: remove unused code, add event translation * fix: merge main and fix problems * fix: english translation file * fix: migration versions * fix: setup * feat: fix pr requests * feat: fix phone code message * feat: migration * feat: setup * fix: remove unused tests Co-authored-by: Livio Amstutz <livio.a@gmail.com>
55 lines
2.4 KiB
Go
55 lines
2.4 KiB
Go
package view
|
|
|
|
import (
|
|
"github.com/jinzhu/gorm"
|
|
|
|
"github.com/caos/zitadel/internal/domain"
|
|
caos_errs "github.com/caos/zitadel/internal/errors"
|
|
iam_model "github.com/caos/zitadel/internal/iam/model"
|
|
"github.com/caos/zitadel/internal/iam/repository/view/model"
|
|
"github.com/caos/zitadel/internal/view/repository"
|
|
)
|
|
|
|
func GetMessageTexts(db *gorm.DB, table string, aggregateID string) ([]*model.MessageTextView, error) {
|
|
texts := make([]*model.MessageTextView, 0)
|
|
queries := []*iam_model.MessageTextSearchQuery{
|
|
{
|
|
Key: iam_model.MessageTextSearchKeyAggregateID,
|
|
Value: aggregateID,
|
|
Method: domain.SearchMethodEquals,
|
|
},
|
|
}
|
|
query := repository.PrepareSearchQuery(table, model.MessageTextSearchRequest{Queries: queries})
|
|
_, err := query(db, &texts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return texts, nil
|
|
}
|
|
|
|
func GetMessageTextByIDs(db *gorm.DB, table, aggregateID, textType, lang string) (*model.MessageTextView, error) {
|
|
mailText := new(model.MessageTextView)
|
|
aggregateIDQuery := &model.MessageTextSearchQuery{Key: iam_model.MessageTextSearchKeyAggregateID, Value: aggregateID, Method: domain.SearchMethodEquals}
|
|
textTypeQuery := &model.MessageTextSearchQuery{Key: iam_model.MessageTextSearchKeyMessageTextType, Value: textType, Method: domain.SearchMethodEquals}
|
|
languageQuery := &model.MessageTextSearchQuery{Key: iam_model.MessageTextSearchKeyLanguage, Value: lang, Method: domain.SearchMethodEquals}
|
|
query := repository.PrepareGetByQuery(table, aggregateIDQuery, textTypeQuery, languageQuery)
|
|
err := query(db, mailText)
|
|
if caos_errs.IsNotFound(err) {
|
|
return nil, caos_errs.ThrowNotFound(nil, "VIEW-IiJjm", "Errors.IAM.CustomMessageText.NotExisting")
|
|
}
|
|
return mailText, err
|
|
}
|
|
|
|
func PutMessageText(db *gorm.DB, table string, mailText *model.MessageTextView) error {
|
|
save := repository.PrepareSave(table)
|
|
return save(db, mailText)
|
|
}
|
|
|
|
func DeleteMessageText(db *gorm.DB, table, aggregateID, textType, lang string) error {
|
|
aggregateIDSearch := repository.Key{Key: model.MessageTextSearchKey(iam_model.MessageTextSearchKeyAggregateID), Value: aggregateID}
|
|
textTypeSearch := repository.Key{Key: model.MessageTextSearchKey(iam_model.MessageTextSearchKeyMessageTextType), Value: textType}
|
|
languageSearch := repository.Key{Key: model.MessageTextSearchKey(iam_model.MessageTextSearchKeyLanguage), Value: lang}
|
|
delete := repository.PrepareDeleteByKeys(table, aggregateIDSearch, textTypeSearch, languageSearch)
|
|
return delete(db)
|
|
}
|