From b0cd2003f5f0397c650c6488d3238ad6b4ece1ce Mon Sep 17 00:00:00 2001 From: Denis Zheleztsov Date: Tue, 6 Nov 2018 13:57:27 +0300 Subject: [PATCH] IDEC API answers --- node/api.go | 6 +++--- node/elastic.go | 4 +++- node/helpers.go | 9 +++++++++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/node/api.go b/node/api.go index bbbfd8d..5a0f33c 100644 --- a/node/api.go +++ b/node/api.go @@ -173,14 +173,14 @@ func (es ESConf) UPointHandler(w http.ResponseWriter, r *http.Request) { if pauth == "" { w.WriteHeader(403) - w.Write([]byte("error: authstring cannot be empty")) + w.Write([]byte("auth error")) return } // Authorization check user, ok := es.checkAuth(req) if !ok { w.WriteHeader(403) - w.Write([]byte("error: permission denied")) + w.Write([]byte("auth error")) return } @@ -193,7 +193,7 @@ func (es ESConf) UPointHandler(w http.ResponseWriter, r *http.Request) { } w.WriteHeader(200) - w.Write([]byte("ok: added")) + w.Write([]byte("msg ok")) } // Serve ... diff --git a/node/elastic.go b/node/elastic.go index b24b845..e9e2ca1 100644 --- a/node/elastic.go +++ b/node/elastic.go @@ -234,7 +234,9 @@ func (es ESConf) GetUMMessages(msgs string) []string { } for _, hit := range esr.Hits.Hits { - m := fmt.Sprintf("%s:%s", hit.Source.MsgID, base64.StdEncoding.EncodeToString(MakePlainTextMessage(hit.Source))) + m := fmt.Sprintf("%s:%s", + hit.Source.MsgID, + base64.StdEncoding.EncodeToString(MakePlainTextMessage(hit.Source))) encodedMessages = append(encodedMessages, m) } diff --git a/node/helpers.go b/node/helpers.go index 46a3d85..c3f547d 100644 --- a/node/helpers.go +++ b/node/helpers.go @@ -52,3 +52,12 @@ func parsePointBody(content string) (string, string) { return pauth, tmsg } + +// b64replace +,/,-,_ with A and Z +func b64replace(s string) string { + s = strings.Replace(s, "+", "A", -1) + s = strings.Replace(s, "-", "A", -1) + s = strings.Replace(s, "/", "Z", -1) + s = strings.Replace(s, "_", "Z", -1) + return s +}