aboutsummaryrefslogtreecommitdiffstats
path: root/data.go
diff options
context:
space:
mode:
authorGuillaume Horel <guillaume.horel@gmail.com>2017-06-25 18:41:45 -0400
committerGuillaume Horel <guillaume.horel@gmail.com>2017-06-25 18:41:45 -0400
commit696c3dce5b184ae8c6effec4e7024cf56bf1b1ae (patch)
tree2b0765cae87e7594fd18d763408f906a91ee297d /data.go
parent0f836c3c0a0ad3addf943282199a73f1e92d9be9 (diff)
downloadlastfm-api-696c3dce5b184ae8c6effec4e7024cf56bf1b1ae.tar.gz
add tracking of clients
Diffstat (limited to 'data.go')
-rw-r--r--data.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/data.go b/data.go
index 4897665..ba3157b 100644
--- a/data.go
+++ b/data.go
@@ -61,9 +61,16 @@ type LoveImport struct {
Count int
}
+type Client struct {
+ Key string
+ Secret string
+ Name string
+}
+
type DataStore interface {
PutSession(*Session) error
GetSession(key string) (*Session, error)
+ GetClient(key string) (*Client, error)
PutScrobbles([]Scrobble) error
PutNowPlaying(s Scrobble) error
NowPlaying(userId int) *Scrobble
@@ -114,6 +121,14 @@ func (store *SqlStore) GetSession(key string) (*Session, error) {
return s, err
}
+func (store *SqlStore) GetClient(key string) (*Client, error) {
+ query := `SELECT secret, name FROM clients WHERE key = $1`
+ row := store.QueryRow(query, key)
+ c := &Client{Key: key}
+ err := row.Scan(&c.Secret, &c.Name)
+ return c, err
+}
+
func (store *SqlStore) GetScrobblingUser(lfmName string) (int, string, error) {
var password string
var userId int