From 67df1d307ce85447c7bd8307f71380c9dcb40860 Mon Sep 17 00:00:00 2001 From: Spotlight Date: Thu, 10 Sep 2020 19:24:32 -0500 Subject: [PATCH] Add proper account querying --- ecs.go | 2 +- route.go | 1 + utils.go | 12 ++++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/ecs.go b/ecs.go index ee3f7ad..c432fcf 100644 --- a/ecs.go +++ b/ecs.go @@ -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 diff --git a/route.go b/route.go index 89b2d9c..a7693d7 100644 --- a/route.go +++ b/route.go @@ -140,6 +140,7 @@ func (route *Route) Handle() http.Handler { w.WriteHeader(http.StatusInternalServerError) } w.Write([]byte(contents)) + fmt.Println("Response:", contents) }) } diff --git a/utils.go b/utils.go index 62d2dc8..255c237 100644 --- a/utils.go +++ b/utils.go @@ -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