Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Jay Mehta
/
strapi-setup-file
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Registry
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit a0e1c3b4
authored
2022-11-28 12:36:39 +0530
by
jay
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
email bugs fixed;
1 parent
5034144b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
17 deletions
src/api/end-user/controllers/end-user.js
src/api/end-user/services/end-user.js
src/api/end-user/controllers/end-user.js
View file @
a0e1c3b
...
@@ -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,14 +97,18 @@ module.exports = factories.createCoreController(
...
@@ -93,14 +97,18 @@ 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
,
},
},
});
});
// TODO: at this point we might have to invoke a Hiranandani API to send the newly registered user there.
// TODO: at this point we might have to invoke a Hiranandani API to send the newly registered user there.
ctx
.
send
({
ok
:
true
,
message
:
"user registered"
});
ctx
.
send
({
ok
:
true
,
message
:
"user registered"
});
},
},
...
@@ -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
;
}
}
...
...
src/api/end-user/services/end-user.js
View file @
a0e1c3b
...
@@ -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 ;
},
},
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment