summaryrefslogtreecommitdiffstats
path: root/api/post.go
diff options
context:
space:
mode:
authorJoramWilander <jwawilander@gmail.com>2015-10-05 13:04:45 -0400
committerJoramWilander <jwawilander@gmail.com>2015-10-19 09:00:30 -0400
commit9de8bc4727132f8ec5d67f9d3e8a9642774c296c (patch)
tree16bbf4a682d944f4b69d3ceadf6a50dbdb553458 /api/post.go
parent182e59f2c016c7beb638d008f40147660ad0b5c4 (diff)
downloadchat-9de8bc4727132f8ec5d67f9d3e8a9642774c296c.tar.gz
chat-9de8bc4727132f8ec5d67f9d3e8a9642774c296c.tar.bz2
chat-9de8bc4727132f8ec5d67f9d3e8a9642774c296c.zip
Remove special team logic.
Diffstat (limited to 'api/post.go')
-rw-r--r--api/post.go48
1 files changed, 19 insertions, 29 deletions
diff --git a/api/post.go b/api/post.go
index 8770fde38..98c394727 100644
--- a/api/post.go
+++ b/api/post.go
@@ -155,7 +155,11 @@ func fireAndForgetWebhookEvent(c *Context, post *model.Post) {
chchan := Srv.Store.Webhook().GetOutgoingByChannel(post.ChannelId)
firstWord := strings.Split(post.Message, " ")[0]
- thchan := Srv.Store.Webhook().GetOutgoingByTriggerWord(c.Session.TeamId, post.ChannelId, firstWord)
+
+ var thchan store.StoreChannel
+ if len(firstWord) != 0 {
+ thchan = Srv.Store.Webhook().GetOutgoingByTriggerWord(c.Session.TeamId, post.ChannelId, firstWord)
+ }
hooks := []*model.OutgoingWebhook{}
@@ -166,38 +170,24 @@ func fireAndForgetWebhookEvent(c *Context, post *model.Post) {
hooks = append(hooks, result.Data.([]*model.OutgoingWebhook)...)
}
- if result := <-thchan; result.Err != nil {
- l4g.Error("Encountered error getting webhook by trigger word, err=%v", result.Err)
- return
- } else {
- hooks = append(hooks, result.Data.([]*model.OutgoingWebhook)...)
+ if thchan != nil {
+ if result := <-thchan; result.Err != nil {
+ l4g.Error("Encountered error getting webhook by trigger word, err=%v", result.Err)
+ return
+ } else {
+ hooks = append(hooks, result.Data.([]*model.OutgoingWebhook)...)
+ }
}
cchan := Srv.Store.Channel().Get(post.ChannelId)
uchan := Srv.Store.User().Get(post.UserId)
+ tchan := Srv.Store.Team().Get(c.Session.TeamId)
- tchan := make(chan *model.Team)
- isTeamBeingFetched := make(map[string]bool)
- for _, hook := range hooks {
- if !isTeamBeingFetched[hook.TeamId] {
- isTeamBeingFetched[hook.TeamId] = true
- go func() {
- if result := <-Srv.Store.Team().Get(hook.TeamId); result.Err != nil {
- l4g.Error("Encountered error getting team, team_id=%s, err=%v", hook.TeamId, result.Err)
- tchan <- nil
- } else {
- tchan <- result.Data.(*model.Team)
- }
- }()
- }
- }
-
- teams := make(map[string]*model.Team)
- for range isTeamBeingFetched {
- team := <-tchan
- if team != nil {
- teams[team.Id] = team
- }
+ var team *model.Team
+ if result := <-tchan; result.Err != nil {
+ l4g.Error("Encountered error getting team, team_id=%s, err=%v", c.Session.TeamId, result.Err)
+ } else {
+ team = result.Data.(*model.Team)
}
var channel *model.Channel
@@ -220,7 +210,7 @@ func fireAndForgetWebhookEvent(c *Context, post *model.Post) {
p.Set("token", hook.Token)
p.Set("team_id", hook.TeamId)
- if team, ok := teams[hook.TeamId]; ok {
+ if team != nil {
p.Set("team_domain", team.Name)
}