From 6ffa020c5f6d3fae4862abecb0a1e0f040497515 Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Wed, 3 Nov 2021 09:43:47 -0700 Subject: [PATCH] Updated linter threw new warnings. Fixed. --- core/chat/persistence.go | 2 +- core/data/webhooks.go | 10 +++------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/core/chat/persistence.go b/core/chat/persistence.go index fad9ce43f..716b71e5c 100644 --- a/core/chat/persistence.go +++ b/core/chat/persistence.go @@ -74,7 +74,7 @@ func saveEvent(id string, userID string, body string, eventType string, hidden * func getChat(query string) []events.UserMessageEvent { history := make([]events.UserMessageEvent, 0) rows, err := _datastore.DB.Query(query) - if err != nil { + if err != nil || rows.Err() != nil { log.Errorln("error fetching chat history", err) return history } diff --git a/core/data/webhooks.go b/core/data/webhooks.go index fa2177b1f..53a2fc9e0 100644 --- a/core/data/webhooks.go +++ b/core/data/webhooks.go @@ -42,7 +42,6 @@ func InsertWebhook(url string, events []models.EventType) (int, error) { return 0, err } stmt, err := tx.Prepare("INSERT INTO webhooks(url, events) values(?, ?)") - if err != nil { return 0, err } @@ -74,7 +73,6 @@ func DeleteWebhook(id int) error { return err } stmt, err := tx.Prepare("DELETE FROM webhooks WHERE id = ?") - if err != nil { return err } @@ -101,7 +99,7 @@ func DeleteWebhook(id int) error { func GetWebhooksForEvent(event models.EventType) []models.Webhook { webhooks := make([]models.Webhook, 0) - var query = `SELECT * FROM ( + query := `SELECT * FROM ( WITH RECURSIVE split(id, url, event, rest) AS ( SELECT id, url, '', events || ',' FROM webhooks UNION ALL @@ -116,8 +114,7 @@ func GetWebhooksForEvent(event models.EventType) []models.Webhook { ) AS webhook WHERE event IS "` + event + `"` rows, err := _db.Query(query) - - if err != nil { + if err != nil || rows.Err() != nil { log.Fatal(err) } defer rows.Close() @@ -146,7 +143,7 @@ func GetWebhooksForEvent(event models.EventType) []models.Webhook { func GetWebhooks() ([]models.Webhook, error) { //nolint webhooks := make([]models.Webhook, 0) - var query = "SELECT * FROM webhooks" + query := "SELECT * FROM webhooks" rows, err := _db.Query(query) if err != nil { @@ -202,7 +199,6 @@ func SetWebhookAsUsed(webhook models.Webhook) error { return err } stmt, err := tx.Prepare("UPDATE webhooks SET last_used = CURRENT_TIMESTAMP WHERE id = ?") - if err != nil { return err }