summaryrefslogtreecommitdiffstats
path: root/storage/storage.go
diff options
context:
space:
mode:
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)
}