Skip to content

Commit

Permalink
Fix query
Browse files Browse the repository at this point in the history
  • Loading branch information
otiai10 committed Aug 28, 2023
1 parent f5ae9bf commit d25b94a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions server/slackbot/slashcommands.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ func (bot Bot) SlashCommands(w http.ResponseWriter, req *http.Request) {
req.ParseForm()
defer req.Body.Close()
text := req.Form.Get("text")
names := []string{}
names := []any{}
idx := mentionExp.SubexpIndex("name")
for _, m := range mentionExp.FindAllStringSubmatch(text, -1) {
fmt.Println(m[idx])
names = append(names, m[idx])
}
if len(names) == 0 {
Expand All @@ -52,7 +51,7 @@ func (bot Bot) SlashCommands(w http.ResponseWriter, req *http.Request) {
defer client.Close()

users := []models.Member{}
query := datastore.NewQuery(models.KindMember).FilterField("Slack.Name", "in", strings.Join(names, ","))
query := datastore.NewQuery(models.KindMember).FilterField("Slack.Name", "in", names)
if _, err := client.GetAll(ctx, query, &users); err != nil {
b, err := json.Marshal(map[string]string{
"text": fmt.Sprintf("データストアからのデータ取得に失敗しました。 @ten までご連絡ください。\n```%s```", err.Error()),
Expand All @@ -65,11 +64,12 @@ func (bot Bot) SlashCommands(w http.ResponseWriter, req *http.Request) {
http.Post(req.Form.Get("response_url"), "application/json", bytes.NewReader(b))

Check failure

Code scanning / CodeQL

Uncontrolled data used in network request Critical

The
URL
of this request depends on a
user-provided value
.
return
}
w.WriteHeader(http.StatusOK)

t := "ありがとう!を "
for _, u := range users {
fmt.Printf("%+v\n", u)
t += fmt.Sprintf("<@%s> さん ", u.Slack.ID)
}

fmt.Println(names)
w.WriteHeader(http.StatusOK)
t += "に伝えました。"
http.Post(req.Form.Get("response_url"), "application/json", strings.NewReader(`{"text":"`+t+`"}`))

Check failure

Code scanning / CodeQL

Uncontrolled data used in network request Critical

The
URL
of this request depends on a
user-provided value
.
}

0 comments on commit d25b94a

Please sign in to comment.