mirror of
https://gitlab.com/commento/commento.git
synced 2025-06-30 11:06:37 -04:00
api: Add go files
I know this is a huge commit, but I can't be bothered to check this in part by part.
This commit is contained in:
25
api/commenter_session_get.go
Normal file
25
api/commenter_session_get.go
Normal file
@ -0,0 +1,25 @@
|
||||
package main
|
||||
|
||||
import ()
|
||||
|
||||
func commenterSessionGet(session string) (commenterSession, error) {
|
||||
if session == "" {
|
||||
return commenterSession{}, errorMissingField
|
||||
}
|
||||
|
||||
statement := `
|
||||
SELECT commenterHex, creationDate
|
||||
FROM commenterSessions
|
||||
WHERE session=$1;
|
||||
`
|
||||
row := db.QueryRow(statement, session)
|
||||
|
||||
cs := commenterSession{}
|
||||
if err := row.Scan(&cs.CommenterHex, &cs.CreationDate); err != nil {
|
||||
return commenterSession{}, errorNoSuchSession
|
||||
}
|
||||
|
||||
cs.Session = session
|
||||
|
||||
return cs, nil
|
||||
}
|
Reference in New Issue
Block a user