app: avoid plugin env check for RunMultiHook and use pluginslock while accessing plugin env (#21803)

* app/channels: use pluginslock while accessing plugins environment

* when using RunMultiHook we don't need to do a nil check on plugin env

* trigger ci
Этот коммит содержится в:
Ibrahim Serdar Acikgoz
2022-12-07 10:00:47 +03:00
коммит произвёл GitHub
родитель 03a5b4a288
Коммит 617c024476
10 изменённых файлов: 179 добавлений и 222 удалений

Просмотреть файл

@@ -308,15 +308,13 @@ func (a *App) createUserOrGuest(c request.CTX, user *model.User, guest bool) (*m
message.Add("user_id", ruser.Id)
a.Publish(message)
if pluginsEnvironment := a.GetPluginsEnvironment(); pluginsEnvironment != nil {
a.Srv().Go(func() {
pluginContext := pluginContext(c)
a.ch.RunMultiHook(func(hooks plugin.Hooks) bool {
hooks.UserHasBeenCreated(pluginContext, ruser)
return true
}, plugin.UserHasBeenCreatedID)
})
}
pluginContext := pluginContext(c)
a.Srv().Go(func() {
a.ch.RunMultiHook(func(hooks plugin.Hooks) bool {
hooks.UserHasBeenCreated(pluginContext, ruser)
return true
}, plugin.UserHasBeenCreatedID)
})
_, cwsErr := a.SendSubscriptionHistoryEvent(ruser.Id)
if cwsErr != nil {