mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
adding second elopage webhook
This commit is contained in:
parent
7e4759b33e
commit
15a08227e6
@ -93,8 +93,7 @@ bool KeyPair::generateFromPassphrase(const char* passphrase, const Mnemonic* wor
|
|||||||
sha512_final(&state, hash);
|
sha512_final(&state, hash);
|
||||||
//crypto_auth_hmacsha512_final(&state, hash);
|
//crypto_auth_hmacsha512_final(&state, hash);
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
// debug passphrase
|
// debug passphrase
|
||||||
printf("\passsphrase: <%s>\n", passphrase);
|
printf("\passsphrase: <%s>\n", passphrase);
|
||||||
printf("size word indices: %u\n", word_indices->size());
|
printf("size word indices: %u\n", word_indices->size());
|
||||||
|
|||||||
@ -109,7 +109,7 @@ void ElopageWebhook::handleRequest(Poco::Net::HTTPServerRequest& request, Poco::
|
|||||||
|
|
||||||
// write stream result also to file
|
// write stream result also to file
|
||||||
static Poco::Mutex mutex;
|
static Poco::Mutex mutex;
|
||||||
|
Profiler timeUsed;
|
||||||
mutex.lock();
|
mutex.lock();
|
||||||
|
|
||||||
Poco::FileOutputStream file("elopage_webhook_requests.txt", std::ios::out | std::ios::app);
|
Poco::FileOutputStream file("elopage_webhook_requests.txt", std::ios::out | std::ios::app);
|
||||||
@ -129,6 +129,8 @@ void ElopageWebhook::handleRequest(Poco::Net::HTTPServerRequest& request, Poco::
|
|||||||
file << completeRequest << std::endl;
|
file << completeRequest << std::endl;
|
||||||
file << std::endl;
|
file << std::endl;
|
||||||
file.close();
|
file.close();
|
||||||
|
std::string timeUsedStr = timeUsed.string();
|
||||||
|
printf("[%s] time for elopage request write to file and maybe wait on lock: %s\n", dateTimeStr.data(), timeUsedStr.data());
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
63
src/cpp/HTTPInterface/ElopageWebhookLight.cpp
Normal file
63
src/cpp/HTTPInterface/ElopageWebhookLight.cpp
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
#include "ElopageWebhookLight.h"
|
||||||
|
#include "Poco/Net/HTTPServerRequest.h"
|
||||||
|
#include "Poco/Net/HTTPServerResponse.h"
|
||||||
|
#include "Poco/URI.h"
|
||||||
|
#include "Poco/Logger.h"
|
||||||
|
#include "Poco/Data/Binding.h"
|
||||||
|
#include "Poco/FileStream.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void ElopageWebhookLight::handleRequest(Poco::Net::HTTPServerRequest& request, Poco::Net::HTTPServerResponse& response)
|
||||||
|
{
|
||||||
|
// simply write request to file for later lookup
|
||||||
|
//ServerConfig::writeToFile(request.stream(), "elopage_webhook_requests.txt");
|
||||||
|
|
||||||
|
// empty response, we didn't need to set anything
|
||||||
|
//response.setStatus(Poco::Net::HTTPResponse::HTTP_NO_CONTENT);
|
||||||
|
std::ostream& _responseStream = response.send();
|
||||||
|
_responseStream << "200 OK";
|
||||||
|
|
||||||
|
std::istream& stream = request.stream();
|
||||||
|
std::string completeRequest;
|
||||||
|
Poco::Net::NameValueCollection elopageRequestData;
|
||||||
|
int breakCount = 100;
|
||||||
|
while (stream.good() && breakCount > 0) {
|
||||||
|
// char dummy;
|
||||||
|
std::string line;
|
||||||
|
std::getline(stream, line);
|
||||||
|
completeRequest += line;
|
||||||
|
|
||||||
|
stream.good();
|
||||||
|
breakCount--;
|
||||||
|
}
|
||||||
|
|
||||||
|
// write stream result also to file
|
||||||
|
static Poco::Mutex mutex;
|
||||||
|
Profiler timeUsed;
|
||||||
|
mutex.lock();
|
||||||
|
|
||||||
|
Poco::FileOutputStream file("elopage_webhook_requests_2.txt", std::ios::out | std::ios::app);
|
||||||
|
|
||||||
|
if (!file.good()) {
|
||||||
|
Poco::Logger& logging(Poco::Logger::get("errorLog"));
|
||||||
|
logging.error("[ElopageWebhookLight::handleRequest] error creating file with name: elopage_webhook_requests_2.txt");
|
||||||
|
//printf("[ElopageWebhook::handleRequest] error creating file with name: elopage_webhook_requests.txt\n");
|
||||||
|
mutex.unlock();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Poco::LocalDateTime now;
|
||||||
|
|
||||||
|
std::string dateTimeStr = Poco::DateTimeFormatter::format(now, Poco::DateTimeFormat::ISO8601_FORMAT);
|
||||||
|
file << dateTimeStr << std::endl;
|
||||||
|
file << completeRequest << std::endl;
|
||||||
|
file << std::endl;
|
||||||
|
file.close();
|
||||||
|
std::string timeUsedStr = timeUsed.string();
|
||||||
|
printf("[%s] time for elopage request light write to file and maybe wait on lock: %s\n", dateTimeStr.data(), timeUsedStr.data());
|
||||||
|
mutex.unlock();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
16
src/cpp/HTTPInterface/ElopageWebhookLight.h
Normal file
16
src/cpp/HTTPInterface/ElopageWebhookLight.h
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#ifndef Elopage_Webhook_LIGHT_INCLUDED
|
||||||
|
#define Elopage_Webhook_LIGHT_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
|
#include "PageRequestMessagedHandler.h"
|
||||||
|
|
||||||
|
|
||||||
|
class ElopageWebhookLight : public PageRequestMessagedHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void handleRequest(Poco::Net::HTTPServerRequest& request, Poco::Net::HTTPServerResponse& response);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // Elopage_Webhook_LIGHT_INCLUDED
|
||||||
@ -14,6 +14,7 @@
|
|||||||
#include "PassphrasePage.h"
|
#include "PassphrasePage.h"
|
||||||
#include "SaveKeysPage.h"
|
#include "SaveKeysPage.h"
|
||||||
#include "ElopageWebhook.h"
|
#include "ElopageWebhook.h"
|
||||||
|
#include "ElopageWebhookLight.h"
|
||||||
#include "UpdateUserPasswordPage.h"
|
#include "UpdateUserPasswordPage.h"
|
||||||
#include "Error500Page.h"
|
#include "Error500Page.h"
|
||||||
#include "CheckTransactionPage.h"
|
#include "CheckTransactionPage.h"
|
||||||
@ -70,6 +71,13 @@ Poco::Net::HTTPRequestHandler* PageRequestHandlerFactory::createRequestHandler(c
|
|||||||
return pageRequestHandler;
|
return pageRequestHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (url_first_part == "/elopage_webhook_211") {
|
||||||
|
mLogging.information(dateTimeString + " call from elopage light");
|
||||||
|
auto pageRequestHandler = new ElopageWebhookLight;
|
||||||
|
pageRequestHandler->setProfiler(timeUsed);
|
||||||
|
return pageRequestHandler;
|
||||||
|
}
|
||||||
|
|
||||||
// check if user has valid session
|
// check if user has valid session
|
||||||
Poco::Net::NameValueCollection cookies;
|
Poco::Net::NameValueCollection cookies;
|
||||||
request.getCookies(cookies);
|
request.getCookies(cookies);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user