IDEC API answers

This commit is contained in:
Denis Zheleztsov 2018-11-06 13:57:27 +03:00
parent 612fc8ac07
commit b0cd2003f5
3 changed files with 15 additions and 4 deletions

View File

@ -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 ...

View File

@ -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)
}

View File

@ -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
}