-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SHARE-533 Email templates & preview #3779
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #3779 +/- ##
==============================================
+ Coverage 30.85% 49.89% +19.03%
- Complexity 5713 5730 +17
==============================================
Files 654 654
Lines 20474 20530 +56
==============================================
+ Hits 6318 10243 +3925
+ Misses 14156 10287 -3869
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 232 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I have noticed during testing
- in the case of the preview - the user name should be optional
All in all the feature looks good :)
assets/js/custom/AdminMail.js
Outdated
@@ -2,14 +2,15 @@ | |||
|
|||
// eslint-disable-next-line no-unused-vars | |||
function AdminMail () { | |||
$('.btn').click(function () { | |||
$('.btn-send').click(function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be great to refactor this code without jquery, since it is already touched in this MR - (should be do-able by chatgpt in a few seconds ;)
$resetToken = $this->resetPasswordHelper->generateFakeResetToken(); | ||
|
||
$signature = 'https:://example.url'; | ||
|
||
$template = (string) $request->query->get('template'); | ||
|
||
$user = $this->user_manager->findUserByUsername((string) $request->query->get('username')); | ||
if (!$user) { | ||
return new Response('User does not exist'); | ||
} | ||
|
||
$subject = (string) $request->query->get('subject'); | ||
if ('' === $subject && '2' === $template) { | ||
return new Response('Empty subject!'); | ||
} | ||
|
||
$titel = (string) $request->query->get('titel'); | ||
|
||
$messageText = (string) $request->query->get('message'); | ||
if ('' === $messageText && '2' === $template) { | ||
return new Response('Empty message!'); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be nice to execute each snippet only if it is necessary - think of this previewAction as delegator
switch $template:
case A: load fake data for A - render
case B: load fake data for B - render
Feel free to create multiple classes or at least methods in a way that each class/method only has one job
<option value="0">Confirmation Email</option> | ||
<option value="1">Reset Email</option> | ||
<option value="2">Simple Message</option> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using names instead of numbers makes the code more readable
<option value="0">Confirmation Email</option> | |
<option value="1">Reset Email</option> | |
<option value="2">Simple Message</option> | |
<option value="confirmation">Confirmation Email</option> | |
<option value="reset">Reset Email</option> | |
<option value="basic">Simple Message</option> |
const subject = subjectInput.value | ||
const titel = titelInput.value | ||
const message = messageInput.value | ||
const url = `send?username=${username}&subject=${subject}&titel=${titel}&message=${message}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will break on specific inputs. For example, let's consider you have the following example:
username = "user1"
subject = "Password Reset"
title = "...
....
Then you will get the following URL:
URL = "send?username=user1&subject=Password Reset&title=...
Since the parameters are not url-encoded, characters such as the space character will break your URL resulting into just fetching "send?username=user1&subject=Password"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
window.open() encodes the url parameter by itself
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want i could also use a json body to pass the parameters. I guess this would be more convenient
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this still an issue? I didnt see any problem during testing, is it resolved @dmetzner ?
} | ||
}) | ||
.then(data => { | ||
if (data && data.length >= 2 && data.substring(0, 2) === 'OK') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should just check if the status code is 200, not check for the message content
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The status code gets already checked above. If you dont like this code i can come up with a new structure that does the same.
return $this->renderBasic($request); | ||
} | ||
|
||
return new Response('404'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The second param is the status code:
return new Response('Not Found', Response::HTTP_NOT_FOUND);
{ | ||
$user = $this->user_manager->findUserByUsername((string) $request->query->get('username')); | ||
if (!$user) { | ||
return new Response('User does not exist'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
404
|
||
$subject = (string) $request->query->get('subject'); | ||
if ('' === $subject) { | ||
return new Response('Empty subject!'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
422 or 400
|
||
$messageText = (string) $request->query->get('message'); | ||
if ('' === $messageText) { | ||
return new Response('Empty message!'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
422 or 400
const titel = titelInput.value | ||
const message = messageInput.value | ||
const template = templateSelect.value | ||
const url = `preview?username=${username}&subject=${subject}&titel=${titel}&message=${message}&template=${template}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same url encoding issue
Would it make sense to disable certain fields in the reset and confirmation mail form like Content and Subject/Title, as they arent used in those to mails right? |
This PR is more like a setup for SHARE-525 New E-Mail design. |
Ah ok, then it looks fine for me! :) |
Your checklist for this pull request
Please review the contributing guidelines and wiki pages of this repository.
SHARE-666 The devils ticket
Code Review
section in JiraAdditional Description
TODO: Add additional information that is not in your commit-message here
Tests - additional information
TODO: add additional information about testruns here