summaryrefslogtreecommitdiffstats
path: root/storage/storage.go
diff options
context:
space:
mode:
authorbt <bt@rctt.net>2026-05-16 22:40:12 +0200
committerbt <bt@rctt.net>2026-05-16 22:46:48 +0200
commit4f6c84085795b32b07a42e47dff1a8b8956ecbb9 (patch)
treeba896ee49635843c51c08b6afb84a030b34a3c59 /storage/storage.go
parent82902e9dc3ad67c49e4f9381b83d38a659efa083 (diff)
downloadsolec-4f6c84085795b32b07a42e47dff1a8b8956ecbb9.tar.gz
solec-4f6c84085795b32b07a42e47dff1a8b8956ecbb9.zip
Return channel history only if user is connected to it
Diffstat (limited to 'storage/storage.go')
-rw-r--r--storage/storage.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/storage/storage.go b/storage/storage.go
index 0103370..1dcea40 100644
--- a/storage/storage.go
+++ b/storage/storage.go
@@ -41,10 +41,13 @@ func (db *Database) Write(msg core.Message) (err error) {
func (db *Database) Read(channel string, since time.Time, num int, offset int) (history []core.Message, err error) {
rows, err := db.Query(
- "SELECT source, target, timestamp, content FROM messages WHERE timestamp > ? LIMIT ? OFFSET ?",
- since.Unix(), num, offset,
+ `SELECT source, target, timestamp, content FROM messages WHERE target = ? AND timestamp > ? LIMIT ? OFFSET ?`,
+ channel, since.Unix(), num, offset,
)
defer func() {
+ if rows == nil {
+ return
+ }
if err := rows.Close(); err != nil {
log.Println("cannot close database row:", err)
}