Committing updates.
This commit is contained in:
@@ -546,23 +546,23 @@ namespace Apostol {
|
|||||||
}
|
}
|
||||||
//--------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
CString CCustomModule::GetAddress(const CHTTPRequest &Request) {
|
CString CCustomModule::GetParam(const CHTTPRequest &Request, const CString &Key) {
|
||||||
CString Result;
|
CString Result;
|
||||||
|
|
||||||
Result = Request.Params["address"];
|
Result = Request.Params[Key];
|
||||||
|
|
||||||
if (Result.IsEmpty() && !Request.Content.IsEmpty()) {
|
if (Result.IsEmpty() && !Request.Content.IsEmpty()) {
|
||||||
const auto &contentType = Request.Headers.Values(_T("content-type"));
|
const auto &contentType = Request.Headers.Values(_T("content-type"));
|
||||||
if (contentType.Find("application/x-www-form-urlencoded") == 0) {
|
if (contentType.Find("application/x-www-form-urlencoded") == 0) {
|
||||||
const CStringList &FormData = Request.FormData;
|
const CStringList &FormData = Request.FormData;
|
||||||
Result = FormData["address"];
|
Result = FormData[Key];
|
||||||
} else if (contentType.Find("multipart/form-data") == 0) {
|
} else if (contentType.Find("multipart/form-data") == 0) {
|
||||||
CFormData FormData;
|
CFormData FormData;
|
||||||
CHTTPRequestParser::ParseFormData(Request, FormData);
|
CHTTPRequestParser::ParseFormData(Request, FormData);
|
||||||
Result = FormData.Data("address");
|
Result = FormData.Data(Key);
|
||||||
} else if (contentType.Find("application/json") == 0) {
|
} else if (contentType.Find("application/json") == 0) {
|
||||||
const CJSON contextJson(Request.Content);
|
const CJSON contextJson(Request.Content);
|
||||||
Result = contextJson["address"].AsString();
|
Result = contextJson[Key].AsString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -634,7 +634,7 @@ namespace Apostol {
|
|||||||
try {
|
try {
|
||||||
if (caCommand == "account" && (caAction == "status" || caAction == "new" || caAction == "add" || caAction == "update" || caAction == "delete")) {
|
if (caCommand == "account" && (caAction == "status" || caAction == "new" || caAction == "add" || caAction == "update" || caAction == "delete")) {
|
||||||
DoAccount(AConnection, "POST", sRoute);
|
DoAccount(AConnection, "POST", sRoute);
|
||||||
} else if (caCommand == "deal" && (caAction.IsEmpty() || caAction == "status" || caAction == "create" || caAction == "pay" || caAction == "complete" || caAction == "cancel" || caAction == "feedback")) {
|
} else if (caCommand == "deal" && slRouts.Count() == 4 && (caAction.IsEmpty() || caAction == "status" || caAction == "create" || caAction == "pay" || caAction == "complete" || caAction == "cancel" || caAction == "feedback")) {
|
||||||
DoDeal(AConnection, "POST", sRoute, caAction);
|
DoDeal(AConnection, "POST", sRoute, caAction);
|
||||||
} else if (caCommand == "signature") {
|
} else if (caCommand == "signature") {
|
||||||
DoSignature(AConnection);
|
DoSignature(AConnection);
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ namespace Apostol {
|
|||||||
void ModuleNew(CContext &Context);
|
void ModuleNew(CContext &Context);
|
||||||
void ModuleAuthorize(CContext &Context);
|
void ModuleAuthorize(CContext &Context);
|
||||||
|
|
||||||
static CString GetAddress(const CHTTPRequest &Request);
|
static CString GetParam(const CHTTPRequest &Request, const CString &Key);
|
||||||
|
|
||||||
void DoGet(CHTTPServerConnection *AConnection) override;
|
void DoGet(CHTTPServerConnection *AConnection) override;
|
||||||
|
|
||||||
|
|||||||
@@ -253,10 +253,10 @@ namespace Apostol {
|
|||||||
const auto &caModuleAddress = m_Module["address"];
|
const auto &caModuleAddress = m_Module["address"];
|
||||||
const auto &caHost = caServerRequest.Headers["host"];
|
const auto &caHost = caServerRequest.Headers["host"];
|
||||||
const auto &caOrigin = caServerRequest.Headers["origin"];
|
const auto &caOrigin = caServerRequest.Headers["origin"];
|
||||||
const auto &caUserAddress = GetAddress(caServerRequest);
|
|
||||||
|
|
||||||
const auto &pgpValue = caServerRequest.Params["pgp"];
|
const auto &caUserAddress = GetParam(caServerRequest, "address");
|
||||||
const auto &caServerParam = caServerRequest.Params["server"];
|
const auto &pgpValue = GetParam(caServerRequest, "pgp");
|
||||||
|
const auto &caServerParam = GetParam(caServerRequest, "server");
|
||||||
|
|
||||||
const auto index = CurrentContextIndex(caServerParam);
|
const auto index = CurrentContextIndex(caServerParam);
|
||||||
|
|
||||||
@@ -491,15 +491,14 @@ namespace Apostol {
|
|||||||
const auto &caHost = caServerRequest.Headers["host"];
|
const auto &caHost = caServerRequest.Headers["host"];
|
||||||
const auto &caOrigin = caServerRequest.Headers["origin"];
|
const auto &caOrigin = caServerRequest.Headers["origin"];
|
||||||
|
|
||||||
const auto &address = GetAddress(caServerRequest);
|
const auto &code = GetParam(caServerRequest, "code");
|
||||||
const auto &code = caServerRequest.Params["code"];
|
const auto &address = GetParam(caServerRequest, "address");
|
||||||
|
const auto &pgpValue = GetParam(caServerRequest, "pgp");
|
||||||
|
const auto &caServerParam = GetParam(caServerRequest, "server");
|
||||||
|
|
||||||
const auto &caUserAddress = address.length() == 40 ? CString() : address;
|
const auto &caUserAddress = address.length() == 40 ? CString() : address;
|
||||||
const auto &caDealCode = !code.empty() ? code : address.length() == 40 ? address : CString();
|
const auto &caDealCode = !code.empty() ? code : address.length() == 40 ? address : CString();
|
||||||
|
|
||||||
const auto &pgpValue = caServerRequest.Params["pgp"];
|
|
||||||
const auto &caServerParam = caServerRequest.Params["server"];
|
|
||||||
|
|
||||||
const auto index = CurrentContextIndex(caServerParam);
|
const auto index = CurrentContextIndex(caServerParam);
|
||||||
|
|
||||||
const auto &caContext = index == -1 ? m_CurrentServer : m_Servers[index].Value();
|
const auto &caContext = index == -1 ? m_CurrentServer : m_Servers[index].Value();
|
||||||
@@ -861,12 +860,13 @@ namespace Apostol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Json.Object().AddPair("module", Module);
|
Json.Object().AddPair("module", Module);
|
||||||
Json.Object().AddPair("address", caUserAddress.IsEmpty() ? caModuleAddress : caUserAddress);
|
|
||||||
|
|
||||||
if (!caDealCode.IsEmpty()) {
|
if (!caDealCode.IsEmpty()) {
|
||||||
CJSONValue Deal(jvtObject);
|
CJSONValue Deal(jvtObject);
|
||||||
Deal.Object().AddPair("code", caDealCode);
|
Deal.Object().AddPair("code", caDealCode);
|
||||||
Json.Object().AddPair("deal", Deal);
|
Json.Object().AddPair("deal", Deal);
|
||||||
|
} else {
|
||||||
|
Json.Object().AddPair("address", caUserAddress.IsEmpty() ? caModuleAddress : caUserAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sPayload.IsEmpty())
|
if (!sPayload.IsEmpty())
|
||||||
@@ -927,14 +927,7 @@ namespace Apostol {
|
|||||||
const auto &caOrigin = caServerRequest.Headers["origin"];
|
const auto &caOrigin = caServerRequest.Headers["origin"];
|
||||||
const auto &caContentType = caServerRequest.Headers["content-type"].Lower();
|
const auto &caContentType = caServerRequest.Headers["content-type"].Lower();
|
||||||
|
|
||||||
const auto &address = GetAddress(caServerRequest);
|
const auto &caServerParam = GetParam(caServerRequest, "server");
|
||||||
const auto &code = caServerRequest.Params["code"];
|
|
||||||
|
|
||||||
const auto &caUserAddress = address.length() == 40 ? CString() : address;
|
|
||||||
const auto &caDealCode = !code.empty() ? code : address.length() == 40 ? address : CString();
|
|
||||||
|
|
||||||
const auto &pgpValue = caServerRequest.Params["pgp"];
|
|
||||||
const auto &caServerParam = caServerRequest.Params["server"];
|
|
||||||
|
|
||||||
const auto index = CurrentContextIndex(caServerParam);
|
const auto index = CurrentContextIndex(caServerParam);
|
||||||
|
|
||||||
|
|||||||
@@ -357,26 +357,26 @@ namespace Apostol {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto &ServerRequest = AConnection->Request();
|
const auto &caServerRequest = AConnection->Request();
|
||||||
|
|
||||||
const auto &caModuleAddress = m_Module["address"];
|
const auto &caModuleAddress = m_Module["address"];
|
||||||
const auto &caHost = ServerRequest.Headers["host"];
|
const auto &caHost = caServerRequest.Headers["host"];
|
||||||
const auto &caOrigin = ServerRequest.Headers["origin"];
|
const auto &caOrigin = caServerRequest.Headers["origin"];
|
||||||
const auto &caUserAddress = GetAddress(ServerRequest);
|
|
||||||
|
|
||||||
const auto &pgpValue = ServerRequest.Params["pgp"];
|
const auto &caUserAddress = GetParam(caServerRequest, "address");
|
||||||
const auto &caServerParam = ServerRequest.Params["server"];
|
const auto &pgpValue = GetParam(caServerRequest, "pgp");
|
||||||
|
const auto &caServerParam = GetParam(caServerRequest, "server");
|
||||||
|
|
||||||
CStringList caClearText;
|
CStringList caClearText;
|
||||||
CString sPayload;
|
CString sPayload;
|
||||||
|
|
||||||
if (!ServerRequest.Content.IsEmpty()) {
|
if (!caServerRequest.Content.IsEmpty()) {
|
||||||
|
|
||||||
const auto &ContentType = ServerRequest.Headers.Values(_T("content-type"));
|
const auto &ContentType = caServerRequest.Headers.Values(_T("content-type"));
|
||||||
|
|
||||||
if (ContentType.Find("application/x-www-form-urlencoded") == 0) {
|
if (ContentType.Find("application/x-www-form-urlencoded") == 0) {
|
||||||
|
|
||||||
const CStringList &FormData = ServerRequest.FormData;
|
const CStringList &FormData = caServerRequest.FormData;
|
||||||
|
|
||||||
const auto &formDate = FormData["date"];
|
const auto &formDate = FormData["date"];
|
||||||
const auto &formAddress = FormData["address"];
|
const auto &formAddress = FormData["address"];
|
||||||
@@ -422,7 +422,7 @@ namespace Apostol {
|
|||||||
} else if (ContentType.Find("multipart/form-data") == 0) {
|
} else if (ContentType.Find("multipart/form-data") == 0) {
|
||||||
|
|
||||||
CFormData FormData;
|
CFormData FormData;
|
||||||
CHTTPRequestParser::ParseFormData(ServerRequest, FormData);
|
CHTTPRequestParser::ParseFormData(caServerRequest, FormData);
|
||||||
|
|
||||||
const auto &formDate = FormData.Data("date");
|
const auto &formDate = FormData.Data("date");
|
||||||
const auto &formAddress = FormData.Data("address");
|
const auto &formAddress = FormData.Data("address");
|
||||||
@@ -467,7 +467,7 @@ namespace Apostol {
|
|||||||
|
|
||||||
} else if (ContentType.Find("application/json") == 0) {
|
} else if (ContentType.Find("application/json") == 0) {
|
||||||
|
|
||||||
const CJSON contextJson(ServerRequest.Content);
|
const CJSON contextJson(caServerRequest.Content);
|
||||||
|
|
||||||
const auto &jsonDate = contextJson["date"].AsString();
|
const auto &jsonDate = contextJson["date"].AsString();
|
||||||
const auto &jsonAddress = contextJson["address"].AsString();
|
const auto &jsonAddress = contextJson["address"].AsString();
|
||||||
@@ -514,7 +514,7 @@ namespace Apostol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
caClearText = ServerRequest.Content;
|
caClearText = caServerRequest.Content;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pgpValue == "off" || pgpValue == "false") {
|
if (pgpValue == "off" || pgpValue == "false") {
|
||||||
@@ -571,7 +571,7 @@ namespace Apostol {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto &ServerRequest = AConnection->Request();
|
const auto &caServerRequest = AConnection->Request();
|
||||||
|
|
||||||
const auto &caModuleAddress = m_Module["address"];
|
const auto &caModuleAddress = m_Module["address"];
|
||||||
const auto &caModuleFee = m_Module["fee"];
|
const auto &caModuleFee = m_Module["fee"];
|
||||||
@@ -580,18 +580,17 @@ namespace Apostol {
|
|||||||
if (checkFee == -1)
|
if (checkFee == -1)
|
||||||
throw ExceptionFrm("Invalid module fee value: %s", caModuleFee.c_str());
|
throw ExceptionFrm("Invalid module fee value: %s", caModuleFee.c_str());
|
||||||
|
|
||||||
const auto &caHost = ServerRequest.Headers["host"];
|
const auto &caHost = caServerRequest.Headers["host"];
|
||||||
const auto &caOrigin = ServerRequest.Headers["origin"];
|
const auto &caOrigin = caServerRequest.Headers["origin"];
|
||||||
|
|
||||||
|
const auto &code = GetParam(caServerRequest, "code");
|
||||||
|
const auto &address = GetParam(caServerRequest, "address");
|
||||||
|
const auto &pgpValue = GetParam(caServerRequest, "pgp");
|
||||||
|
const auto &caServerParam = GetParam(caServerRequest, "server");
|
||||||
|
|
||||||
const auto &address = GetAddress(ServerRequest);
|
|
||||||
const auto &code = ServerRequest.Params["code"];
|
|
||||||
|
|
||||||
const auto &caUserAddress = address.length() == 40 ? CString() : address;
|
const auto &caUserAddress = address.length() == 40 ? CString() : address;
|
||||||
const auto &caDealCode = !code.empty() ? code : address.length() == 40 ? address : CString();
|
const auto &caDealCode = !code.empty() ? code : address.length() == 40 ? address : CString();
|
||||||
|
|
||||||
const auto &pgpValue = ServerRequest.Params["pgp"];
|
|
||||||
const auto &caServerParam = ServerRequest.Params["server"];
|
|
||||||
|
|
||||||
const auto index = CurrentContextIndex(caServerParam);
|
const auto index = CurrentContextIndex(caServerParam);
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
throw Delphi::Exception::Exception(NOT_FOUND_ACTIVE_CONNECTION);
|
throw Delphi::Exception::Exception(NOT_FOUND_ACTIVE_CONNECTION);
|
||||||
@@ -603,14 +602,14 @@ namespace Apostol {
|
|||||||
|
|
||||||
CString sPayload;
|
CString sPayload;
|
||||||
|
|
||||||
if (!ServerRequest.Content.IsEmpty() && Action != "status") {
|
if (!caServerRequest.Content.IsEmpty() && Action != "status") {
|
||||||
|
|
||||||
const auto utc = UTC();
|
const auto utc = UTC();
|
||||||
const auto &ContentType = ServerRequest.Headers.Values(_T("content-type"));
|
const auto &ContentType = caServerRequest.Headers.Values(_T("content-type"));
|
||||||
|
|
||||||
if (ContentType.Find("application/x-www-form-urlencoded") == 0) {
|
if (ContentType.Find("application/x-www-form-urlencoded") == 0) {
|
||||||
|
|
||||||
const CStringList &FormData = ServerRequest.FormData;
|
const CStringList &FormData = caServerRequest.FormData;
|
||||||
|
|
||||||
const auto &formType = FormData["type"];
|
const auto &formType = FormData["type"];
|
||||||
const auto &formAt = FormData["at"];
|
const auto &formAt = FormData["at"];
|
||||||
@@ -697,7 +696,7 @@ namespace Apostol {
|
|||||||
} else if (ContentType.Find("multipart/form-data") == 0) {
|
} else if (ContentType.Find("multipart/form-data") == 0) {
|
||||||
|
|
||||||
CFormData FormData;
|
CFormData FormData;
|
||||||
CHTTPRequestParser::ParseFormData(ServerRequest, FormData);
|
CHTTPRequestParser::ParseFormData(caServerRequest, FormData);
|
||||||
|
|
||||||
const auto &formType = FormData.Data("type");
|
const auto &formType = FormData.Data("type");
|
||||||
const auto &formAt = FormData.Data("at");
|
const auto &formAt = FormData.Data("at");
|
||||||
@@ -783,7 +782,7 @@ namespace Apostol {
|
|||||||
|
|
||||||
} else if (ContentType.Find("application/json") == 0) {
|
} else if (ContentType.Find("application/json") == 0) {
|
||||||
|
|
||||||
const CJSON jsonData(ServerRequest.Content);
|
const CJSON jsonData(caServerRequest.Content);
|
||||||
|
|
||||||
const auto &formOrder = jsonData["order"].AsString().Lower();
|
const auto &formOrder = jsonData["order"].AsString().Lower();
|
||||||
const auto &formType = jsonData["type"].AsString();
|
const auto &formType = jsonData["type"].AsString();
|
||||||
@@ -878,7 +877,7 @@ namespace Apostol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Node = YAML::Load(ServerRequest.Content.c_str());
|
Node = YAML::Load(caServerRequest.Content.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto &BTCKeys = caContext.BTCKeys();
|
const auto &BTCKeys = caContext.BTCKeys();
|
||||||
@@ -944,12 +943,13 @@ namespace Apostol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Json.Object().AddPair("module", Module);
|
Json.Object().AddPair("module", Module);
|
||||||
Json.Object().AddPair("address", caUserAddress.IsEmpty() ? caModuleAddress : caUserAddress);
|
|
||||||
|
|
||||||
if (!caDealCode.IsEmpty()) {
|
if (!caDealCode.IsEmpty()) {
|
||||||
CJSONValue Deal(jvtObject);
|
CJSONValue Deal(jvtObject);
|
||||||
Deal.Object().AddPair("code", caDealCode);
|
Deal.Object().AddPair("code", caDealCode);
|
||||||
Json.Object().AddPair("deal", Deal);
|
Json.Object().AddPair("deal", Deal);
|
||||||
|
} else {
|
||||||
|
Json.Object().AddPair("address", caUserAddress.IsEmpty() ? caModuleAddress : caUserAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sPayload.IsEmpty())
|
if (!sPayload.IsEmpty())
|
||||||
@@ -979,7 +979,7 @@ namespace Apostol {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto &ServerRequest = AConnection->Request();
|
const auto &caServerRequest = AConnection->Request();
|
||||||
|
|
||||||
const auto &caModuleAddress = m_Module["address"];
|
const auto &caModuleAddress = m_Module["address"];
|
||||||
const auto &caModuleFee = m_Module["fee"];
|
const auto &caModuleFee = m_Module["fee"];
|
||||||
@@ -988,17 +988,17 @@ namespace Apostol {
|
|||||||
if (checkFee == -1)
|
if (checkFee == -1)
|
||||||
throw ExceptionFrm("Invalid module fee value: %s", caModuleFee.c_str());
|
throw ExceptionFrm("Invalid module fee value: %s", caModuleFee.c_str());
|
||||||
|
|
||||||
const auto &caHost = ServerRequest.Headers["host"];
|
const auto &caHost = caServerRequest.Headers["host"];
|
||||||
const auto &caOrigin = ServerRequest.Headers["origin"];
|
const auto &caOrigin = caServerRequest.Headers["origin"];
|
||||||
|
|
||||||
const auto &address = ServerRequest.Params["address"];
|
const auto &address = caServerRequest.Params["address"];
|
||||||
const auto &code = ServerRequest.Params["code"];
|
const auto &code = caServerRequest.Params["code"];
|
||||||
|
|
||||||
const auto &caUserAddress = address.length() == 40 ? CString() : address;
|
const auto &caUserAddress = address.length() == 40 ? CString() : address;
|
||||||
const auto &caDealCode = !code.empty() ? code : address.length() == 40 ? address : CString();
|
const auto &caDealCode = !code.empty() ? code : address.length() == 40 ? address : CString();
|
||||||
|
|
||||||
const auto &pgpValue = ServerRequest.Params["pgp"];
|
const auto &pgpValue = caServerRequest.Params["pgp"];
|
||||||
const auto &caServerParam = ServerRequest.Params["server"];
|
const auto &caServerParam = caServerRequest.Params["server"];
|
||||||
|
|
||||||
const auto index = CurrentContextIndex(caServerParam);
|
const auto index = CurrentContextIndex(caServerParam);
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
@@ -1013,7 +1013,7 @@ namespace Apostol {
|
|||||||
throw Delphi::Exception::Exception(NOT_FOUND_ACTIVE_CONNECTION);
|
throw Delphi::Exception::Exception(NOT_FOUND_ACTIVE_CONNECTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
const CJSON Json(ServerRequest.Content);
|
const CJSON Json(caServerRequest.Content);
|
||||||
|
|
||||||
pClient->Send(URI, Json, OnRequest);
|
pClient->Send(URI, Json, OnRequest);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user