[MM-16709] Add helper method for plugins using MessageHasBeenPosted (#12539)

The PR introduces a method in helper interface. The method has common code for filtering to be used across plugins which use MessageHasBeenPosted.
Этот коммит содержится в:
Rajat Varyani
2019-11-18 15:17:32 +05:30
коммит произвёл Ben Schumacher
родитель 9b6a0674f7
Коммит f2fcfa8f9d
6 изменённых файлов: 326 добавлений и 13 удалений

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

@@ -8,6 +8,7 @@ import (
"fmt"
"io"
"net/http"
"strings"
"unicode/utf8"
)
@@ -217,3 +218,15 @@ func (l *BotList) Etag() string {
func MakeBotNotFoundError(userId string) *AppError {
return NewAppError("SqlBotStore.Get", "store.sql_bot.get.missing.app_error", map[string]interface{}{"user_id": userId}, "", http.StatusNotFound)
}
func IsBotDMChannel(channel *Channel, botUserID string) bool {
if channel.Type != CHANNEL_DIRECT {
return false
}
if !strings.HasPrefix(channel.Name, botUserID+"__") && !strings.HasSuffix(channel.Name, "__"+botUserID) {
return false
}
return true
}