Add proper account querying

This commit is contained in:
Spotlight 2020-09-10 19:24:32 -05:00
parent 6620df7d27
commit 67df1d307c
No known key found for this signature in database
GPG Key ID: 874AA355B3209BDC
3 changed files with 14 additions and 1 deletions

2
ecs.go
View File

@ -52,7 +52,7 @@ func notifyETicketsSynced(e *Envelope) {
func listETickets(e *Envelope) {
fmt.Println("The request is valid! Responding...")
rows, err := ownedTitles.Query("todo, sorry")
rows, err := ownedTitles.Query(e.AccountId())
if err != nil {
e.Error(2, "that's all you've got for me? ;3", err)
return

View File

@ -140,6 +140,7 @@ func (route *Route) Handle() http.Handler {
w.WriteHeader(http.StatusInternalServerError)
}
w.Write([]byte(contents))
fmt.Println("Response:", contents)
})
}

View File

@ -107,6 +107,18 @@ func (e *Envelope) Language() string {
return e.language
}
// AccountId returns the account ID for this request. It should be only used in authenticated requests.
// If for whatever reason AccountId is not present, it will return an empty string. Please design in a way
// so that this is not an issue.
func (e *Envelope) AccountId() string {
accountId, err := getKey(e.doc, "AccountId")
if err != nil {
return ""
} else {
return accountId
}
}
// ObtainCommon interprets a given node, and updates the envelope with common key values.
func (e *Envelope) ObtainCommon() error {
var err error