Remove special team logic.
Этот коммит содержится в:
48
api/post.go
48
api/post.go
@@ -155,7 +155,11 @@ func fireAndForgetWebhookEvent(c *Context, post *model.Post) {
|
|||||||
chchan := Srv.Store.Webhook().GetOutgoingByChannel(post.ChannelId)
|
chchan := Srv.Store.Webhook().GetOutgoingByChannel(post.ChannelId)
|
||||||
|
|
||||||
firstWord := strings.Split(post.Message, " ")[0]
|
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{}
|
hooks := []*model.OutgoingWebhook{}
|
||||||
|
|
||||||
@@ -166,38 +170,24 @@ func fireAndForgetWebhookEvent(c *Context, post *model.Post) {
|
|||||||
hooks = append(hooks, result.Data.([]*model.OutgoingWebhook)...)
|
hooks = append(hooks, result.Data.([]*model.OutgoingWebhook)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
if result := <-thchan; result.Err != nil {
|
if thchan != nil {
|
||||||
l4g.Error("Encountered error getting webhook by trigger word, err=%v", result.Err)
|
if result := <-thchan; result.Err != nil {
|
||||||
return
|
l4g.Error("Encountered error getting webhook by trigger word, err=%v", result.Err)
|
||||||
} else {
|
return
|
||||||
hooks = append(hooks, result.Data.([]*model.OutgoingWebhook)...)
|
} else {
|
||||||
|
hooks = append(hooks, result.Data.([]*model.OutgoingWebhook)...)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cchan := Srv.Store.Channel().Get(post.ChannelId)
|
cchan := Srv.Store.Channel().Get(post.ChannelId)
|
||||||
uchan := Srv.Store.User().Get(post.UserId)
|
uchan := Srv.Store.User().Get(post.UserId)
|
||||||
|
tchan := Srv.Store.Team().Get(c.Session.TeamId)
|
||||||
|
|
||||||
tchan := make(chan *model.Team)
|
var team *model.Team
|
||||||
isTeamBeingFetched := make(map[string]bool)
|
if result := <-tchan; result.Err != nil {
|
||||||
for _, hook := range hooks {
|
l4g.Error("Encountered error getting team, team_id=%s, err=%v", c.Session.TeamId, result.Err)
|
||||||
if !isTeamBeingFetched[hook.TeamId] {
|
} else {
|
||||||
isTeamBeingFetched[hook.TeamId] = true
|
team = result.Data.(*model.Team)
|
||||||
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 channel *model.Channel
|
var channel *model.Channel
|
||||||
@@ -220,7 +210,7 @@ func fireAndForgetWebhookEvent(c *Context, post *model.Post) {
|
|||||||
p.Set("token", hook.Token)
|
p.Set("token", hook.Token)
|
||||||
p.Set("team_id", hook.TeamId)
|
p.Set("team_id", hook.TeamId)
|
||||||
|
|
||||||
if team, ok := teams[hook.TeamId]; ok {
|
if team != nil {
|
||||||
p.Set("team_domain", team.Name)
|
p.Set("team_domain", team.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user