Fix empty string comparison issues in the codebase (#16686)
Automatic Merge
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
200a56fa5a
Коммит
94c24eea20
@@ -79,7 +79,7 @@ func (*HeaderProvider) DoCommand(a *app.App, args *model.CommandArgs, message st
|
||||
}
|
||||
}
|
||||
|
||||
if len(message) == 0 {
|
||||
if message == "" {
|
||||
return &model.CommandResponse{
|
||||
Text: args.T("api.command_channel_header.message.app_error"),
|
||||
ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL,
|
||||
|
||||
@@ -66,7 +66,7 @@ func (*PurposeProvider) DoCommand(a *app.App, args *model.CommandArgs, message s
|
||||
}
|
||||
}
|
||||
|
||||
if len(message) == 0 {
|
||||
if message == "" {
|
||||
return &model.CommandResponse{
|
||||
Text: args.T("api.command_channel_purpose.message.app_error"),
|
||||
ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL,
|
||||
|
||||
@@ -66,7 +66,7 @@ func (*RenameProvider) DoCommand(a *app.App, args *model.CommandArgs, message st
|
||||
return &model.CommandResponse{Text: args.T("api.command_channel_rename.direct_group.app_error"), ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL}
|
||||
}
|
||||
|
||||
if len(message) == 0 {
|
||||
if message == "" {
|
||||
return &model.CommandResponse{
|
||||
Text: args.T("api.command_channel_rename.message.app_error"),
|
||||
ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL,
|
||||
|
||||
@@ -38,7 +38,7 @@ func (*CodeProvider) GetCommand(a *app.App, T goi18n.TranslateFunc) *model.Comma
|
||||
}
|
||||
|
||||
func (*CodeProvider) DoCommand(a *app.App, args *model.CommandArgs, message string) *model.CommandResponse {
|
||||
if len(message) == 0 {
|
||||
if message == "" {
|
||||
return &model.CommandResponse{Text: args.T("api.command_code.message.app_error"), ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL}
|
||||
}
|
||||
rmsg := " " + strings.Join(strings.Split(message, "\n"), "\n ")
|
||||
|
||||
@@ -43,7 +43,7 @@ func (*EchoProvider) GetCommand(a *app.App, T goi18n.TranslateFunc) *model.Comma
|
||||
}
|
||||
|
||||
func (*EchoProvider) DoCommand(a *app.App, args *model.CommandArgs, message string) *model.CommandResponse {
|
||||
if len(message) == 0 {
|
||||
if message == "" {
|
||||
return &model.CommandResponse{Text: args.T("api.command_echo.message.app_error"), ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL}
|
||||
}
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ func (*groupmsgProvider) DoCommand(a *app.App, args *model.CommandArgs, message
|
||||
}
|
||||
}
|
||||
|
||||
if len(parsedMessage) > 0 {
|
||||
if parsedMessage != "" {
|
||||
post := &model.Post{}
|
||||
post.Message = parsedMessage
|
||||
post.ChannelId = groupChannel.Id
|
||||
|
||||
@@ -459,7 +459,7 @@ func (*LoadTestProvider) PostCommand(a *app.App, args *model.CommandArgs, messag
|
||||
|
||||
func (*LoadTestProvider) UrlCommand(a *app.App, args *model.CommandArgs, message string) (*model.CommandResponse, error) {
|
||||
url := strings.TrimSpace(strings.TrimPrefix(message, "url"))
|
||||
if len(url) == 0 {
|
||||
if url == "" {
|
||||
return &model.CommandResponse{Text: "Command must contain a url", ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL}, nil
|
||||
}
|
||||
|
||||
@@ -513,7 +513,7 @@ func (*LoadTestProvider) UrlCommand(a *app.App, args *model.CommandArgs, message
|
||||
|
||||
func (*LoadTestProvider) JsonCommand(a *app.App, args *model.CommandArgs, message string) (*model.CommandResponse, error) {
|
||||
url := strings.TrimSpace(strings.TrimPrefix(message, "json"))
|
||||
if len(url) == 0 {
|
||||
if url == "" {
|
||||
return &model.CommandResponse{Text: "Command must contain a url", ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL}, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ func (*msgProvider) DoCommand(a *app.App, args *model.CommandArgs, message strin
|
||||
targetChannelId = channel.Id
|
||||
}
|
||||
|
||||
if len(parsedMessage) > 0 {
|
||||
if parsedMessage != "" {
|
||||
post := &model.Post{}
|
||||
post.Message = parsedMessage
|
||||
post.ChannelId = targetChannelId
|
||||
|
||||
@@ -54,7 +54,7 @@ func (*MuteProvider) DoCommand(a *app.App, args *model.CommandArgs, message stri
|
||||
channelName = splitMessage[0]
|
||||
}
|
||||
|
||||
if len(channelName) > 0 && len(message) > 0 {
|
||||
if channelName != "" && message != "" {
|
||||
channel, _ = a.Srv().Store.Channel().GetByName(channel.TeamId, channelName, true)
|
||||
|
||||
if channel == nil {
|
||||
|
||||
@@ -96,7 +96,7 @@ func doCommand(a *app.App, args *model.CommandArgs, message string) *model.Comma
|
||||
}
|
||||
}
|
||||
|
||||
if len(message) == 0 {
|
||||
if message == "" {
|
||||
return &model.CommandResponse{
|
||||
Text: args.T("api.command_remove.message.app_error"),
|
||||
ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL,
|
||||
|
||||
@@ -37,7 +37,7 @@ func (*ShrugProvider) GetCommand(a *app.App, T goi18n.TranslateFunc) *model.Comm
|
||||
|
||||
func (*ShrugProvider) DoCommand(a *app.App, args *model.CommandArgs, message string) *model.CommandResponse {
|
||||
rmsg := `¯\\\_(ツ)\_/¯`
|
||||
if len(message) > 0 {
|
||||
if message != "" {
|
||||
rmsg = message + " " + rmsg
|
||||
}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user