#10883 adding const error string DismissPostError to be returned by MessageWillBePosted (#10921)

Adds an exported const string that can be used by plugins to signal a client that the incoming post should be dismissed, instead of the current behavior which just leaves it pending.
Этот коммит содержится в:
Evan do Carmo
2019-06-06 00:16:28 -04:00
коммит произвёл Hanzei
родитель 16c11d7bf9
Коммит c73bc21d1e
3 изменённых файлов: 13 добавлений и 1 удалений

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

@@ -236,7 +236,11 @@ func (a *App) CreatePost(post *model.Post, channel *model.Channel, triggerWebhoo
pluginsEnvironment.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
replacementPost, rejectionReason := hooks.MessageWillBePosted(pluginContext, post)
if rejectionReason != "" {
rejectionError = model.NewAppError("createPost", "Post rejected by plugin. "+rejectionReason, nil, "", http.StatusBadRequest)
id := "Post rejected by plugin. " + rejectionReason
if rejectionReason == plugin.DismissPostError {
id = plugin.DismissPostError
}
rejectionError = model.NewAppError("createPost", id, nil, "", http.StatusBadRequest)
return false
}
if replacementPost != nil {
@@ -245,6 +249,7 @@ func (a *App) CreatePost(post *model.Post, channel *model.Channel, triggerWebhoo
return true
}, plugin.MessageWillBePostedId)
if rejectionError != nil {
return nil, rejectionError
}