diff options
author | JoramWilander <jwawilander@gmail.com> | 2015-10-16 11:17:24 -0400 |
---|---|---|
committer | JoramWilander <jwawilander@gmail.com> | 2015-10-19 09:00:30 -0400 |
commit | f24ea30a75ad52b695f5f275139af1c0495624ac (patch) | |
tree | 74ea933bb3e67019a24d168b2f55e61800c1c243 /model/outgoing_webhook.go | |
parent | 9de8bc4727132f8ec5d67f9d3e8a9642774c296c (diff) | |
download | chat-f24ea30a75ad52b695f5f275139af1c0495624ac.tar.gz chat-f24ea30a75ad52b695f5f275139af1c0495624ac.tar.bz2 chat-f24ea30a75ad52b695f5f275139af1c0495624ac.zip |
Refactor to hit database less often.
Diffstat (limited to 'model/outgoing_webhook.go')
-rw-r--r-- | model/outgoing_webhook.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/model/outgoing_webhook.go b/model/outgoing_webhook.go index 64d58ac9d..8958dd5b0 100644 --- a/model/outgoing_webhook.go +++ b/model/outgoing_webhook.go @@ -119,3 +119,17 @@ func (o *OutgoingWebhook) PreSave() { func (o *OutgoingWebhook) PreUpdate() { o.UpdateAt = GetMillis() } + +func (o *OutgoingWebhook) HasTriggerWord(word string) bool { + if len(o.TriggerWords) == 0 || len(word) == 0 { + return false + } + + for _, trigger := range o.TriggerWords { + if trigger == word { + return true + } + } + + return false +} |