main
Bel LaPointe 2024-04-17 17:28:48 -06:00
parent 04c574ffec
commit 1e43c2a14e
1 changed files with 12 additions and 2 deletions

14
main.go
View File

@ -220,9 +220,19 @@ func handlerPostAPIV1EventsSlackInitialize(cfg Config) http.HandlerFunc {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
cfg.driver.ExecContext(r.Context(), `
CREATE TABLE
IF NOT EXISTS
initialization (
label TEXT,
token TEXT,
updated TIMESTAMP
)
`)
if _, err := cfg.driver.ExecContext(r.Context(), `
CREATE TABLE IF NOT EXISTS initialization (label TEXT, token TEXT, updated TIMESTAMP);
INSERT INTO initialization (token, updated) VALUES ('slack_events_webhook_token', $1, $2);
INSERT
INTO initialization (token, updated)
VALUES ('slack_events_webhook_token', $1, $2)
`, challenge.Token, time.Now().UTC()); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return