mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-06 16:52:18 +00:00
feat: notification loginname (#381)
* feat: add login names to notify user * feat: add login names to initial mail * feat: add login names to initial mail
This commit is contained in:
@@ -2,6 +2,7 @@ package view
|
||||
|
||||
import (
|
||||
caos_errs "github.com/caos/zitadel/internal/errors"
|
||||
global_model "github.com/caos/zitadel/internal/model"
|
||||
usr_model "github.com/caos/zitadel/internal/user/model"
|
||||
"github.com/caos/zitadel/internal/user/repository/view/model"
|
||||
"github.com/caos/zitadel/internal/view/repository"
|
||||
@@ -10,7 +11,7 @@ import (
|
||||
|
||||
func NotifyUserByID(db *gorm.DB, table, userID string) (*model.NotifyUser, error) {
|
||||
user := new(model.NotifyUser)
|
||||
query := repository.PrepareGetByKey(table, model.UserSearchKey(usr_model.NotifyUserSearchKeyUserID), userID)
|
||||
query := repository.PrepareGetByKey(table, model.NotifyUserSearchKey(usr_model.NotifyUserSearchKeyUserID), userID)
|
||||
err := query(db, user)
|
||||
if caos_errs.IsNotFound(err) {
|
||||
return nil, caos_errs.ThrowNotFound(nil, "VIEW-Gad31", "Errors.User.NotFound")
|
||||
@@ -18,6 +19,20 @@ func NotifyUserByID(db *gorm.DB, table, userID string) (*model.NotifyUser, error
|
||||
return user, err
|
||||
}
|
||||
|
||||
func NotifyUsersByOrgID(db *gorm.DB, table, orgID string) ([]*model.NotifyUser, error) {
|
||||
users := make([]*model.NotifyUser, 0)
|
||||
orgIDQuery := &usr_model.NotifyUserSearchQuery{
|
||||
Key: usr_model.NotifyUserSearchKeyResourceOwner,
|
||||
Method: global_model.SearchMethodEquals,
|
||||
Value: orgID,
|
||||
}
|
||||
query := repository.PrepareSearchQuery(table, model.NotifyUserSearchRequest{
|
||||
Queries: []*usr_model.NotifyUserSearchQuery{orgIDQuery},
|
||||
})
|
||||
_, err := query(db, &users)
|
||||
return users, err
|
||||
}
|
||||
|
||||
func PutNotifyUser(db *gorm.DB, table string, project *model.NotifyUser) error {
|
||||
save := repository.PrepareSave(table)
|
||||
return save(db, project)
|
||||
|
||||
Reference in New Issue
Block a user