Commit a0e1c3b4 by jay

email bugs fixed;

1 parent 5034144b
...@@ -55,18 +55,20 @@ module.exports = factories.createCoreController( ...@@ -55,18 +55,20 @@ module.exports = factories.createCoreController(
} }
try { try {
console.log("inside try",user.email); console.log("inside try", user.email);
const spretoLeadData = await strapi const spretoLeadData = await strapi
.service("api::end-user.end-user") .service("api::end-user.end-user")
.sendLeadToSperto({...endUser, email: user.email}, 'Y'); .sendLeadToSperto({ ...endUser, email: user.email }, "Y");
// console.log("spretoLeadData.data", spretoLeadData.data); // console.log("spretoLeadData.data", spretoLeadData.data);
ctx.request.body.httpRequestIsVerifiedHeaders = JSON.stringify( ctx.request.body.httpRequestIsVerifiedHeaders = JSON.stringify(
spretoLeadData.headers spretoLeadData.headers
); );
ctx.request.body.httpRequestIsVerifiedMethod = spretoLeadData.config.method; ctx.request.body.httpRequestIsVerifiedMethod =
spretoLeadData.config.method;
ctx.request.body.httpRequestIsVerifiedUrl = spretoLeadData.config.url; ctx.request.body.httpRequestIsVerifiedUrl = spretoLeadData.config.url;
ctx.request.body.httpsRequestIsVerifiedBody = spretoLeadData.config.data; ctx.request.body.httpsRequestIsVerifiedBody =
spretoLeadData.config.data;
ctx.request.body.httpResposneIsVerifiedBody = JSON.stringify( ctx.request.body.httpResposneIsVerifiedBody = JSON.stringify(
spretoLeadData.data spretoLeadData.data
); );
...@@ -79,7 +81,9 @@ module.exports = factories.createCoreController( ...@@ -79,7 +81,9 @@ module.exports = factories.createCoreController(
ctx.request.body.httpRequestIsVerifiedMethod = error.config.method; ctx.request.body.httpRequestIsVerifiedMethod = error.config.method;
ctx.request.body.httpRequestIsVerifiedUrl = error.config.url; ctx.request.body.httpRequestIsVerifiedUrl = error.config.url;
ctx.request.body.httpsRequestIsVerifiedBody = error.config.data; ctx.request.body.httpsRequestIsVerifiedBody = error.config.data;
ctx.request.body.httpResposneIsVerifiedBody = JSON.stringify(error.message); ctx.request.body.httpResposneIsVerifiedBody = JSON.stringify(
error.message
);
ctx.request.body.thirdPartyApiError = true; ctx.request.body.thirdPartyApiError = true;
} }
...@@ -93,11 +97,15 @@ module.exports = factories.createCoreController( ...@@ -93,11 +97,15 @@ module.exports = factories.createCoreController(
await strapi.entityService.update("api::end-user.end-user", endUser.id, { await strapi.entityService.update("api::end-user.end-user", endUser.id, {
data: { data: {
publishedAt: new Date(), publishedAt: new Date(),
httpRequestIsVerifiedHeaders: ctx.request.body.httpRequestIsVerifiedHeaders, httpRequestIsVerifiedHeaders:
httpsRequestIsVerifiedBody: ctx.request.body.httpsRequestIsVerifiedBody, ctx.request.body.httpRequestIsVerifiedHeaders,
httpsRequestIsVerifiedBody:
ctx.request.body.httpsRequestIsVerifiedBody,
httpRequestIsVerifiedUrl: ctx.request.body.httpRequestIsVerifiedUrl, httpRequestIsVerifiedUrl: ctx.request.body.httpRequestIsVerifiedUrl,
httpRequestIsVerifiedMethod: ctx.request.body.httpRequestIsVerifiedMethod, httpRequestIsVerifiedMethod:
httpResposneIsVerifiedBody: ctx.request.body.httpResposneIsVerifiedBody ctx.request.body.httpRequestIsVerifiedMethod,
httpResposneIsVerifiedBody:
ctx.request.body.httpResposneIsVerifiedBody,
}, },
}); });
...@@ -111,7 +119,7 @@ module.exports = factories.createCoreController( ...@@ -111,7 +119,7 @@ module.exports = factories.createCoreController(
try { try {
const spretoLeadData = await strapi const spretoLeadData = await strapi
.service("api::end-user.end-user") .service("api::end-user.end-user")
.sendLeadToSperto(ctx.request.body.data, 'N'); .sendLeadToSperto(ctx.request.body.data, "N");
// console.log("spretoLeadData.data", spretoLeadData.data); // console.log("spretoLeadData.data", spretoLeadData.data);
ctx.request.body.data.httpRequestHeaders = JSON.stringify( ctx.request.body.data.httpRequestHeaders = JSON.stringify(
spretoLeadData.headers spretoLeadData.headers
...@@ -172,21 +180,37 @@ module.exports = factories.createCoreController( ...@@ -172,21 +180,37 @@ module.exports = factories.createCoreController(
} }
); );
ctx.request.body.data = { ...ctx.request.body.data, emailToSend }; ctx.request.body.data = { ...ctx.request.body.data, emailToSend };
console.log("ctx.request.body.data", ctx.request.body.data);
// Send an email to the user. // Send an email to the user.
// await strapi.plugin("email").service("email").send(emailToSend).sendOTPToSpreto({...ctx.request.body.data,body: emailToSend }); // await strapi.plugin("email").service("email").send(emailToSend).sendOTPToSpreto({...ctx.request.body.data,body: emailToSend });
try { try {
const spretoOTP = await strapi const spretoOTP = await strapi
.service("api::end-user.end-user") .service("api::end-user.end-user")
.sendOTPToSpreto(ctx.request.body.data); .sendOTPToSpreto(ctx.request.body.data);
console.log("spretoOTP>>>>>>>>", spretoOTP);
ctx.request.body.data.httpRequestEmailHeaders = JSON.stringify( ctx.request.body.data.httpRequestEmailHeaders = JSON.stringify(
spretoOTP.headers spretoOTP.spertoEmailResponse.headers
); );
ctx.request.body.data.httpRequestEmailMethod = spretoOTP.config.method; ctx.request.body.data.httpRequestEmailMethod = spretoOTP.spertoEmailResponse.config.method;
ctx.request.body.data.httpRequestEmailUrl = spretoOTP.config.url; ctx.request.body.data.httpRequestEmailUrl = spretoOTP.spertoEmailResponse.config.url;
ctx.request.body.data.httpsRequestEmailBody = spretoOTP.config.data; ctx.request.body.data.httpsRequestEmailBody = spretoOTP.spertoEmailResponse.config.data;
ctx.request.body.data.httpResposneEmailBody = JSON.stringify( ctx.request.body.data.httpResposneEmailBody = JSON.stringify(
spretoOTP.data spretoOTP.spertoEmailResponse.data
); );
ctx.request.body.data.httpSMSRequestHeaders = JSON.stringify(
spretoOTP.spertoEmailResponse.headers
);
ctx.request.body.data.httpSMSRequestMethod = spretoOTP.spertoEmailResponse.config.method;
ctx.request.body.data.httpSMSRequestUrl = spretoOTP.spertoEmailResponse.config.url;
ctx.request.body.data.httpsSMSRequestBody
= spretoOTP.spertoEmailResponse.config.data;
ctx.request.body.data.httpSMSResposneBody = JSON.stringify(
spretoOTP.spertoEmailResponse.data
);
ctx.request.body.data.thirdPartyApiError = false; ctx.request.body.data.thirdPartyApiError = false;
} catch (error) { } catch (error) {
ctx.request.body.data.httpRequestEmailHeaders = JSON.stringify( ctx.request.body.data.httpRequestEmailHeaders = JSON.stringify(
...@@ -198,6 +222,16 @@ module.exports = factories.createCoreController( ...@@ -198,6 +222,16 @@ module.exports = factories.createCoreController(
ctx.request.body.data.httpResposneEmailBody = JSON.stringify( ctx.request.body.data.httpResposneEmailBody = JSON.stringify(
error.message error.message
); );
ctx.request.body.data.httpSMSRequestHeaders = JSON.stringify(
error.config.headers
);
ctx.request.body.data.httpSMSRequestMethod = error.config.method;
ctx.request.body.data.httpSMSRequestUrl = error.config.url;
ctx.request.body.data.httpsSMSRequestBody = error.config.data;
ctx.request.body.data.httpSMSResposneBody = JSON.stringify(
error.message
);
ctx.request.body.data.thirdPartyApiError = true; ctx.request.body.data.thirdPartyApiError = true;
} }
......
...@@ -73,7 +73,7 @@ module.exports = createCoreService( ...@@ -73,7 +73,7 @@ module.exports = createCoreService(
{ headers: headers } { headers: headers }
); );
// const finalReturn = {} // const finalReturn = {}
console.log("spertoSMSResponse", spertoSMSResponse); // console.log("spertoSMSResponse", spertoSMSResponse);
return {spertoSMSResponse, spertoEmailResponse} ; return {spertoSMSResponse, spertoEmailResponse} ;
// return ; // return ;
}, },
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!