Automatic Merge
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
e8c7e7d025
Коммит
ef896a4ea6
@@ -100,9 +100,10 @@ type Actions struct {
|
||||
|
||||
// SlackImporter is a service that allows to import slack dumps into mattermost
|
||||
type SlackImporter struct {
|
||||
store store.Store
|
||||
actions Actions
|
||||
config *model.Config
|
||||
store store.Store
|
||||
actions Actions
|
||||
config *model.Config
|
||||
isAdminImport bool
|
||||
}
|
||||
|
||||
// New creates a new SlackImporter service instance. It receive a store, a set of actions and the current config.
|
||||
@@ -115,6 +116,17 @@ func New(store store.Store, actions Actions, config *model.Config) *SlackImporte
|
||||
}
|
||||
}
|
||||
|
||||
// NewWithAdminFlag creates a new SlackImporter service instance with information about whether this is an admin import.
|
||||
// This allows for enhanced security controls based on the importing user's role.
|
||||
func NewWithAdminFlag(store store.Store, actions Actions, config *model.Config, isAdminImport bool) *SlackImporter {
|
||||
return &SlackImporter{
|
||||
store: store,
|
||||
actions: actions,
|
||||
config: config,
|
||||
isAdminImport: isAdminImport,
|
||||
}
|
||||
}
|
||||
|
||||
func (si *SlackImporter) SlackImport(rctx request.CTX, fileData multipart.File, fileSize int64, teamID string) (*model.AppError, *bytes.Buffer) {
|
||||
// Create log file
|
||||
log := bytes.NewBufferString(i18n.T("api.slackimport.slack_import.log"))
|
||||
@@ -718,8 +730,15 @@ func (si *SlackImporter) oldImportUser(rctx request.CTX, team *model.Team, user
|
||||
return nil
|
||||
}
|
||||
|
||||
if _, err := si.store.User().VerifyEmail(ruser.Id, ruser.Email); err != nil {
|
||||
rctx.Logger().Warn("Failed to set email verified.", mlog.Err(err))
|
||||
// Only system admins can automatically verify emails during import
|
||||
if si.isAdminImport {
|
||||
if _, err := si.store.User().VerifyEmail(ruser.Id, ruser.Email); err != nil {
|
||||
rctx.Logger().Warn("Failed to set email verified for admin import.", mlog.Err(err))
|
||||
}
|
||||
} else {
|
||||
// Non-admin users: emails remain unverified
|
||||
rctx.Logger().Debug("Email verification skipped for non-admin import.",
|
||||
mlog.String("user_email", ruser.Email))
|
||||
}
|
||||
|
||||
if _, err := si.actions.JoinUserToTeam(team, user, ""); err != nil {
|
||||
|
||||
Ссылка в новой задаче
Block a user