Refactoring namespace for OpenWifi.

This commit is contained in:
stephb9959
2021-09-02 23:33:42 -07:00
committed by oblom0v
parent ce216400b7
commit d7033d29dc
2 changed files with 5 additions and 4 deletions

View File

@@ -18,11 +18,9 @@ namespace OpenWifi {
if (!ContinueProcessing(Request, Response))
return;
std::cout << __LINE__ << std::endl;
if (!IsAuthorized(Request, Response))
return;
std::cout << __LINE__ << std::endl;
if (Request.getMethod() == Poco::Net::HTTPRequest::HTTP_POST)
DoPost(Request, Response);
else
@@ -31,11 +29,9 @@ namespace OpenWifi {
void RESTAPI_email_handler::DoPost(Poco::Net::HTTPServerRequest &Request, Poco::Net::HTTPServerResponse &Response) {
try {
std::cout << __LINE__ << std::endl;
Poco::JSON::Parser parser;
auto Obj = parser.parse(Request.stream()).extract<Poco::JSON::Object::Ptr>();
std::cout << __LINE__ << std::endl;
if (Obj->has("subject") &&
Obj->has("from") &&
Obj->has("text") &&
@@ -45,6 +41,10 @@ namespace OpenWifi {
MessageAttributes Attrs;
std::cout << "Recipient: " << Recipients->get(0).toString() << std::endl;
std::cout << "Text: " << Obj->get("text").toString() << std::endl;
std::cout << "subject: " << Obj->get("subject").toString() << std::endl;
Attrs[RECIPIENT_EMAIL] = Recipients->get(0).toString();
Attrs[SUBJECT] = Obj->get("subject").toString();
Attrs[TEXT] = Obj->get("text").toString();

View File

@@ -258,6 +258,7 @@ sendemail() {
payload="{ \"recipients\" : [ \"stephane.bourque@gmail.com\" ] , \"subject\" : \"test1\" , \"from\" : \"no-reply@arilia.com\" , \"text\" : \"This is a test from SES.\" }"
curl ${FLAGS} -X POST "https://${OWSEC}/api/v1/email" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${token}" \
-d "$payload" > ${result_file}
jq < ${result_file}
}