summaryrefslogtreecommitdiffstats
path: root/storage/storage.go
diff options
context:
space:
mode:
authorbt <bt@rctt.net>2026-05-24 19:41:57 +0200
committerbt <bt@rctt.net>2026-05-24 19:41:57 +0200
commit509bfdbcfc483240f31f9ecd0b4f97dbba96f6f7 (patch)
treea22a488d079175f75129e81fd2d32ba4d21d3996 /storage/storage.go
parentbd2ebe456996a51ad4230ea9c69f2d7c0879cf9d (diff)
downloadsolec-509bfdbcfc483240f31f9ecd0b4f97dbba96f6f7.tar.gz
solec-509bfdbcfc483240f31f9ecd0b4f97dbba96f6f7.zip
[daemon] Use database to check history read permissions
Diffstat (limited to 'storage/storage.go')
-rw-r--r--storage/storage.go22
1 files changed, 16 insertions, 6 deletions
diff --git a/storage/storage.go b/storage/storage.go
index 28f2564..510b587 100644
--- a/storage/storage.go
+++ b/storage/storage.go
@@ -109,16 +109,26 @@ func (db *Database) SetPermission(perm core.PermissionData) error {
}
func (db *Database) GetPermission(user, channel string) (core.PermissionData, error) {
- var perm core.PermissionData
+ var read, write int
err := db.QueryRow(
- "SELECT (read, write) FROM permissions WHERE user = ? AND channel = ?", user, channel).
- Scan(&perm.Read, &perm.Write)
+ "SELECT read, write FROM permissions WHERE user = ? AND channel = ?", user, channel).
+ Scan(&read, &write)
if err != nil {
return core.PermissionData{}, err
}
- perm.User = user
- perm.Channel = channel
- return perm, nil
+ return core.PermissionData{
+ User: user,
+ Channel: channel,
+ Read: itob(read),
+ Write: itob(write),
+ }, nil
+}
+
+func itob(v int) bool {
+ if v == 1 {
+ return true
+ }
+ return false
}