From 9dd1407e5ca06655ecd8547fc9050a11490cc662 Mon Sep 17 00:00:00 2001
From: Andrey Kuzmin
Date: Sat, 11 Nov 2023 01:41:07 +0300
Subject: [PATCH] Support for send message to all chats.
---
CHANGELOG.md | 3 +++
model/queries/group.sql.go | 27 +++++++++++++++++++++++++++
model/queries_src/group.sql | 3 +++
3 files changed, 33 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2e34d5f..a469182 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,6 @@
+2023-11-11 v1.6.6
+ - Support for send message to all chats.
+
2023-11-11 v1.6.5
- Corrrect ban count.
diff --git a/model/queries/group.sql.go b/model/queries/group.sql.go
index 68ce83d..e8c55bd 100644
--- a/model/queries/group.sql.go
+++ b/model/queries/group.sql.go
@@ -88,3 +88,30 @@ func (q *Queries) GetGroup(ctx context.Context, id int64) (GetGroupRow, error) {
)
return i, err
}
+
+const getGroups = `-- name: GetGroups :many
+SELECT id FROM public.groups
+`
+
+func (q *Queries) GetGroups(ctx context.Context) ([]int64, error) {
+ rows, err := q.db.QueryContext(ctx, getGroups)
+ if err != nil {
+ return nil, err
+ }
+ defer rows.Close()
+ var items []int64
+ for rows.Next() {
+ var id int64
+ if err := rows.Scan(&id); err != nil {
+ return nil, err
+ }
+ items = append(items, id)
+ }
+ if err := rows.Close(); err != nil {
+ return nil, err
+ }
+ if err := rows.Err(); err != nil {
+ return nil, err
+ }
+ return items, nil
+}
diff --git a/model/queries_src/group.sql b/model/queries_src/group.sql
index 79db44f..2fba22c 100644
--- a/model/queries_src/group.sql
+++ b/model/queries_src/group.sql
@@ -21,3 +21,6 @@ ON CONFLICT (id) DO UPDATE SET
EXCLUDED.ban_question, EXCLUDED.ban_timeout, EXCLUDED.ignore_domain,
EXCLUDED.ban_emojii_count
);
+
+-- name: GetGroups :many
+SELECT id FROM public.groups;