Fix response for malformed command execute request (#5498)
Этот коммит содержится в:
коммит произвёл
Corey Hulen
родитель
ad61a63ad2
Коммит
9f65284ba1
@@ -219,6 +219,10 @@ func executeCommand(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func handleResponse(c *Context, w http.ResponseWriter, response *model.CommandResponse, commandArgs *model.CommandArgs, cmd *model.Command, builtIn bool) {
|
func handleResponse(c *Context, w http.ResponseWriter, response *model.CommandResponse, commandArgs *model.CommandArgs, cmd *model.Command, builtIn bool) {
|
||||||
|
if c.Err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
post := &model.Post{}
|
post := &model.Post{}
|
||||||
post.ChannelId = commandArgs.ChannelId
|
post.ChannelId = commandArgs.ChannelId
|
||||||
post.RootId = commandArgs.RootId
|
post.RootId = commandArgs.RootId
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ package api
|
|||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
l4g "github.com/alecthomas/log4go"
|
||||||
"github.com/mattermost/platform/app"
|
"github.com/mattermost/platform/app"
|
||||||
"github.com/mattermost/platform/model"
|
"github.com/mattermost/platform/model"
|
||||||
"github.com/mattermost/platform/utils"
|
"github.com/mattermost/platform/utils"
|
||||||
@@ -55,7 +56,7 @@ func (me *InvitePeopleProvider) DoCommand(c *Context, args *model.CommandArgs, m
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := app.InviteNewUsersToTeam(emailList, c.TeamId, c.Session.UserId, c.GetSiteURL()); err != nil {
|
if err := app.InviteNewUsersToTeam(emailList, c.TeamId, c.Session.UserId, c.GetSiteURL()); err != nil {
|
||||||
c.Err = err
|
l4g.Error(err.Error())
|
||||||
return &model.CommandResponse{ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL, Text: c.T("api.command.invite_people.fail")}
|
return &model.CommandResponse{ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL, Text: c.T("api.command.invite_people.fail")}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ package api
|
|||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
l4g "github.com/alecthomas/log4go"
|
||||||
"github.com/mattermost/platform/app"
|
"github.com/mattermost/platform/app"
|
||||||
"github.com/mattermost/platform/model"
|
"github.com/mattermost/platform/model"
|
||||||
)
|
)
|
||||||
@@ -50,7 +51,7 @@ func (me *msgProvider) DoCommand(c *Context, args *model.CommandArgs, message st
|
|||||||
|
|
||||||
var userProfile *model.User
|
var userProfile *model.User
|
||||||
if result := <-app.Srv.Store.User().GetByUsername(targetUsername); result.Err != nil {
|
if result := <-app.Srv.Store.User().GetByUsername(targetUsername); result.Err != nil {
|
||||||
c.Err = result.Err
|
l4g.Error(result.Err.Error())
|
||||||
return &model.CommandResponse{Text: c.T("api.command_msg.missing.app_error"), ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL}
|
return &model.CommandResponse{Text: c.T("api.command_msg.missing.app_error"), ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL}
|
||||||
} else {
|
} else {
|
||||||
userProfile = result.Data.(*model.User)
|
userProfile = result.Data.(*model.User)
|
||||||
@@ -67,13 +68,13 @@ func (me *msgProvider) DoCommand(c *Context, args *model.CommandArgs, message st
|
|||||||
if channel := <-app.Srv.Store.Channel().GetByName(c.TeamId, channelName, true); channel.Err != nil {
|
if channel := <-app.Srv.Store.Channel().GetByName(c.TeamId, channelName, true); channel.Err != nil {
|
||||||
if channel.Err.Id == "store.sql_channel.get_by_name.missing.app_error" {
|
if channel.Err.Id == "store.sql_channel.get_by_name.missing.app_error" {
|
||||||
if directChannel, err := app.CreateDirectChannel(c.Session.UserId, userProfile.Id); err != nil {
|
if directChannel, err := app.CreateDirectChannel(c.Session.UserId, userProfile.Id); err != nil {
|
||||||
c.Err = err
|
l4g.Error(err.Error())
|
||||||
return &model.CommandResponse{Text: c.T("api.command_msg.dm_fail.app_error"), ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL}
|
return &model.CommandResponse{Text: c.T("api.command_msg.dm_fail.app_error"), ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL}
|
||||||
} else {
|
} else {
|
||||||
targetChannelId = directChannel.Id
|
targetChannelId = directChannel.Id
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
c.Err = channel.Err
|
l4g.Error(channel.Err.Error())
|
||||||
return &model.CommandResponse{Text: c.T("api.command_msg.dm_fail.app_error"), ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL}
|
return &model.CommandResponse{Text: c.T("api.command_msg.dm_fail.app_error"), ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user