summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/mattermost/platform/model/outgoing_webhook.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2016-08-15 18:47:31 +0200
committerWim <wim@42.be>2016-08-15 18:47:31 +0200
commit24defcb970838133eb82f4fbbc516630fb81cae6 (patch)
treede88bd0761b08ee35d8f2ddbcb133f7899b4264d /vendor/github.com/mattermost/platform/model/outgoing_webhook.go
parenta1a11a88b334a4deb78915336def0113eec9738b (diff)
downloadmatterbridge-msglm-24defcb970838133eb82f4fbbc516630fb81cae6.tar.gz
matterbridge-msglm-24defcb970838133eb82f4fbbc516630fb81cae6.tar.bz2
matterbridge-msglm-24defcb970838133eb82f4fbbc516630fb81cae6.zip
Sync with mattermost 3.3.0
Diffstat (limited to 'vendor/github.com/mattermost/platform/model/outgoing_webhook.go')
-rw-r--r--vendor/github.com/mattermost/platform/model/outgoing_webhook.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/vendor/github.com/mattermost/platform/model/outgoing_webhook.go b/vendor/github.com/mattermost/platform/model/outgoing_webhook.go
index ee7a32f1..ec2ed75c 100644
--- a/vendor/github.com/mattermost/platform/model/outgoing_webhook.go
+++ b/vendor/github.com/mattermost/platform/model/outgoing_webhook.go
@@ -9,6 +9,7 @@ import (
"io"
"net/url"
"strconv"
+ "strings"
)
type OutgoingWebhook struct {
@@ -21,6 +22,7 @@ type OutgoingWebhook struct {
ChannelId string `json:"channel_id"`
TeamId string `json:"team_id"`
TriggerWords StringArray `json:"trigger_words"`
+ TriggerWhen int `json:"trigger_when"`
CallbackURLs StringArray `json:"callback_urls"`
DisplayName string `json:"display_name"`
Description string `json:"description"`
@@ -171,6 +173,10 @@ func (o *OutgoingWebhook) IsValid() *AppError {
return NewLocAppError("OutgoingWebhook.IsValid", "model.outgoing_hook.is_valid.content_type.app_error", nil, "")
}
+ if o.TriggerWhen > 1 {
+ return NewLocAppError("OutgoingWebhook.IsValid", "model.outgoing_hook.is_valid.content_type.app_error", nil, "")
+ }
+
return nil
}
@@ -204,3 +210,17 @@ func (o *OutgoingWebhook) HasTriggerWord(word string) bool {
return false
}
+
+func (o *OutgoingWebhook) TriggerWordStartsWith(word string) bool {
+ if len(o.TriggerWords) == 0 || len(word) == 0 {
+ return false
+ }
+
+ for _, trigger := range o.TriggerWords {
+ if strings.HasPrefix(word, trigger) {
+ return true
+ }
+ }
+
+ return false
+}