mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Mm 55298 generic integration action (#25320)
This commit is contained in:
parent
f8f50ca882
commit
9596c46115
@ -70,24 +70,24 @@ func (a *App) DoPostActionWithCookie(c request.CTX, postID, actionId, userID, se
|
|||||||
|
|
||||||
// See if the post exists in the DB, if so ignore the cookie.
|
// See if the post exists in the DB, if so ignore the cookie.
|
||||||
// Start all queries here for parallel execution
|
// Start all queries here for parallel execution
|
||||||
pchan := make(chan store.StoreResult, 1)
|
pchan := make(chan store.GenericStoreResult[*model.Post], 1)
|
||||||
go func() {
|
go func() {
|
||||||
post, err := a.Srv().Store().Post().GetSingle(postID, false)
|
post, err := a.Srv().Store().Post().GetSingle(postID, false)
|
||||||
pchan <- store.StoreResult{Data: post, NErr: err}
|
pchan <- store.GenericStoreResult[*model.Post]{Data: post, NErr: err}
|
||||||
close(pchan)
|
close(pchan)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
cchan := make(chan store.StoreResult, 1)
|
cchan := make(chan store.GenericStoreResult[*model.Channel], 1)
|
||||||
go func() {
|
go func() {
|
||||||
channel, err := a.Srv().Store().Channel().GetForPost(postID)
|
channel, err := a.Srv().Store().Channel().GetForPost(postID)
|
||||||
cchan <- store.StoreResult{Data: channel, NErr: err}
|
cchan <- store.GenericStoreResult[*model.Channel]{Data: channel, NErr: err}
|
||||||
close(cchan)
|
close(cchan)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
userChan := make(chan store.StoreResult, 1)
|
userChan := make(chan store.GenericStoreResult[*model.User], 1)
|
||||||
go func() {
|
go func() {
|
||||||
user, err := a.Srv().Store().User().Get(context.Background(), upstreamRequest.UserId)
|
user, err := a.Srv().Store().User().Get(context.Background(), upstreamRequest.UserId)
|
||||||
userChan <- store.StoreResult{Data: user, NErr: err}
|
userChan <- store.GenericStoreResult[*model.User]{Data: user, NErr: err}
|
||||||
close(userChan)
|
close(userChan)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
@ -133,12 +133,12 @@ func (a *App) DoPostActionWithCookie(c request.CTX, postID, actionId, userID, se
|
|||||||
rootPostId = cookie.RootPostId
|
rootPostId = cookie.RootPostId
|
||||||
upstreamURL = cookie.Integration.URL
|
upstreamURL = cookie.Integration.URL
|
||||||
} else {
|
} else {
|
||||||
post := result.Data.(*model.Post)
|
post := result.Data
|
||||||
result = <-cchan
|
chResult := <-cchan
|
||||||
if result.NErr != nil {
|
if chResult.NErr != nil {
|
||||||
return "", model.NewAppError("DoPostActionWithCookie", "app.channel.get_for_post.app_error", nil, "", http.StatusInternalServerError).Wrap(result.NErr)
|
return "", model.NewAppError("DoPostActionWithCookie", "app.channel.get_for_post.app_error", nil, "", http.StatusInternalServerError).Wrap(result.NErr)
|
||||||
}
|
}
|
||||||
channel := result.Data.(*model.Channel)
|
channel := chResult.Data
|
||||||
|
|
||||||
action := post.GetAction(actionId)
|
action := post.GetAction(actionId)
|
||||||
if action == nil || action.Integration == nil {
|
if action == nil || action.Integration == nil {
|
||||||
@ -175,7 +175,7 @@ func (a *App) DoPostActionWithCookie(c request.CTX, postID, actionId, userID, se
|
|||||||
upstreamURL = action.Integration.URL
|
upstreamURL = action.Integration.URL
|
||||||
}
|
}
|
||||||
|
|
||||||
teamChan := make(chan store.StoreResult, 1)
|
teamChan := make(chan store.GenericStoreResult[*model.Team], 1)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
defer close(teamChan)
|
defer close(teamChan)
|
||||||
@ -186,7 +186,7 @@ func (a *App) DoPostActionWithCookie(c request.CTX, postID, actionId, userID, se
|
|||||||
}
|
}
|
||||||
|
|
||||||
team, err := a.Srv().Store().Team().Get(upstreamRequest.TeamId)
|
team, err := a.Srv().Store().Team().Get(upstreamRequest.TeamId)
|
||||||
teamChan <- store.StoreResult{Data: team, NErr: err}
|
teamChan <- store.GenericStoreResult[*model.Team]{Data: team, NErr: err}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
ur := <-userChan
|
ur := <-userChan
|
||||||
@ -199,7 +199,7 @@ func (a *App) DoPostActionWithCookie(c request.CTX, postID, actionId, userID, se
|
|||||||
return "", model.NewAppError("DoPostActionWithCookie", "app.user.get.app_error", nil, "", http.StatusInternalServerError).Wrap(ur.NErr)
|
return "", model.NewAppError("DoPostActionWithCookie", "app.user.get.app_error", nil, "", http.StatusInternalServerError).Wrap(ur.NErr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
user := ur.Data.(*model.User)
|
user := ur.Data
|
||||||
upstreamRequest.UserName = user.Username
|
upstreamRequest.UserName = user.Username
|
||||||
|
|
||||||
tr, ok := <-teamChan
|
tr, ok := <-teamChan
|
||||||
@ -214,7 +214,7 @@ func (a *App) DoPostActionWithCookie(c request.CTX, postID, actionId, userID, se
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
team := tr.Data.(*model.Team)
|
team := tr.Data
|
||||||
upstreamRequest.TeamName = team.Name
|
upstreamRequest.TeamName = team.Name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user