MM-11575: change plugin nil semantics (#9212)

* change MessageWillBePosted nil return semantics

* change FileWillBeUploaded nil return semantics

* use LogDebug to verify plugin inputs vs. the confusing Delete(User|Team)
Этот коммит содержится в:
Jesse Hallam
2018-08-03 13:15:51 -04:00
коммит произвёл GitHub
родитель 1ecb98d9f5
Коммит 04749027f6
5 изменённых файлов: 477 добавлений и 176 удалений

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

@@ -162,14 +162,22 @@ func (a *App) CreatePost(post *model.Post, channel *model.Channel, triggerWebhoo
}
if a.PluginsReady() {
var rejectionReason string
var rejectionError *model.AppError
pluginContext := &plugin.Context{}
a.Plugins.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
post, rejectionReason = hooks.MessageWillBePosted(pluginContext, post)
return post != nil
replacementPost, rejectionReason := hooks.MessageWillBePosted(pluginContext, post)
if rejectionReason != "" {
rejectionError = model.NewAppError("createPost", "Post rejected by plugin. "+rejectionReason, nil, "", http.StatusBadRequest)
return false
}
if replacementPost != nil {
post = replacementPost
}
return true
}, plugin.MessageWillBePostedId)
if post == nil {
return nil, model.NewAppError("createPost", "Post rejected by plugin. "+rejectionReason, nil, "", http.StatusBadRequest)
if rejectionError != nil {
return nil, rejectionError
}
}