Comment Notify Node Author module sends the email notification to the author of the node, when new comment is posted or the existing comment is updated on their content by the user.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | CNA_Configuration.png | 34.7 KB | gowthamrajkrishnasamy |
Comments
Comment #2
avpadernoThank you for applying!
Please read Review process for security advisory coverage: What to expect for more details and Security advisory coverage application checklist to understand what reviewers look for. Tips for ensuring a smooth review gives some hints for a smoother review.
The important notes are the following.
phpcs --standard=Drupal,>DrupalPracticeon the project, which alone fixes most of what reviewers would report.To the reviewers
Please read How to review security advisory coverage applications, Application workflow, What to cover in an application review, and Tools to use for reviews.
The important notes are the following.
For new reviewers, I would also suggest to first read In which way the issue queue for coverage applications is different from other project queues.
Comment #3
gowthamrajkrishnasamy commentedComment #4
vishal.kadam1. Fix phpcs issues.
2. FILE: cna.routing.yml
"administer cna configuration" permission is not defined in the module.
Comment #5
gowthamrajkrishnasamy commentedFixed PHPCS errors and added permissions. Please review it.
Comment #6
vishal.kadamWrong machine name of permission. It should be "administer cna configuration"
Comment #7
gowthamrajkrishnasamy commentedIssue permissions.yml file is fixed.
Comment #8
gowthamrajkrishnasamy commentedPlease review it
Comment #9
avpadernocna.module
$message['body'][] = t(':message', [':message' => $params['message']]);That code does not show the translation of
$params['message']; it shows it as it is because placeholders in translatable strings are the only part that are not translated. The only way to make the message translatable is to use code similar to the following one.The first argument passed to
notice()must be a literal string.That function is a
hook_ENTITY_TYPE_insert()implementation.There is no need to add a long description to hook implementations.
The long description is just repeating what the short description already said. The long description is not mandatory, but the parameters and the return value descriptions must be present, if the function has parameters or returns a value.
src/Form/CNAConfig.php
The parent method already shows a message. It is sufficient to call it.
There are other modules for sending notifications when a node or a comment is created, like the Notify module. At least the project page should give a list of similar modules and describe the difference with them. (A list of notification modules can be obtained by searching for Notify.)
Comment #10
gowthamrajkrishnasamy commentedComment #11
vishal.kadamI am changing priority as per Issue priorities.
Comment #12
vishal.kadamI am changing priority as per Issue priorities.
Comment #13
avpadernoWhat I reported in my previous comment has not been changed.
Furthermore, the following changes are also necessary.
cna.module
$message = "Comment has been posted on " . $node_title . ", by " . $name . ".";Everything that is shown in the user interface must be translatable.
$messageis not translatable, or it would not be a concatenation of strings.$message['body'][] = t('Link to the comment :linkToComment', [':linkToComment' => $params['url']]);The correct placeholder for URL starts with
:. It must also be wrapped on double quotation marks, as reported onFormattableMarkup::placeholderFormat().The channel ID is normally the module machine name. It is not a message title, nor does it contains spaces.
eMail is misspelled. Either it is email or e-mail.
Placeholders starting with
:are used when dangerous protocols needs to be filtered out, which is not the case of$subject. In the case of email addresses, see my previous note.cna.routing.yml
It does not seem the title is correct for a settings form.
Comment #14
avpadernoComment #15
gowthamrajkrishnasamy commentedAddressed issues reported in #9, #13. Please review it.
Comment #16
lostcarpark commentedI have reviewed the code and it looks like the reported issues have been fixed.
However, I've noticed a few small things.
In cna.module, line 10:
Usual convention is to remove the leading `\` in use statements, as you've done in the other use statements above it. However, it doesn't look like Markup type is used at all, so this use statement could be removed altogether.
Next, the if statement on line 18:
This hook is only called when a comment is inserted, with the comment as a parameter, so $comment should always have a value, so this if statement is unnecessary and will always evaluate TRUE.
Finally, you use
getCommentedEntity()to get the node being commented on. However, this returns aFieldableEntityInterface. However, as not all entities have owners, this interface does not include thegetOwner()method. This will cause most IDEs to be unhappy about the following lines (23 and 49):I think this could be clearer. First, it seems to assume a node, but doesn't explicitly check for this. Casting to a node type could be one way to resolve this. It could also be possible to make this module more generic by allowing for the possibility of other entity types.
I think it would be worth tweaking the code to make it clear what node types are supported, and make sure the variable is of a type that has the
getOwner()method.Comment #17
lostcarpark commentedComment #18
avpadernoComment #19
gowthamrajkrishnasamy commentedAddressed issues reported in #16. Please review it.
Comment #20
lostcarpark commentedI like the improvements in
cna.module, but I think there are still a couple of issues in both thecna_comment_insertandcna_comment_updatefunctions.You currently check if the type is a node, which is good, and set the
$node_titleand$to, if it is a node. However, there is no else condition, so it will continue to attempt the email sending with those variables unset.For the node title, you could use the
label()function instead of thetitleproperty. I believe this is recommended practice according to this change record (though it's rather old, so I'm not 100% sure it hasn't changed).label()is generic to all entities, whiletitleis specific to nodes, so you no longer need that in the if statement.Rather than checking if the entity type is a
node, I recommend checking if its anEntityOwnerInterface. That will mean the module will work for any entities with an owner.If it isn't, it means the entity doesn't have an owner, so there's no one to send an email to, so you should skip the email sending altogether.
You could use something like:
Comment #21
gowthamrajkrishnasamy commentedThanks for the input. Since the module works only on nodes not other entities, I'm checking for
Nodeentity type and added some additional checks to verify node owner's presence and if its valid or not. Please review it.Comment #22
rushikesh raval commentedI am changing priority as per Issue priorities.
Comment #23
gowthamrajkrishnasamy commentedChanging the priority as per Issue priotities
Comment #24
klausimanual review:
cna_comment_update(): $node_title can be undefined when the entity is not a node. Same for the insert hook.
Otherwise looks good to me!
Thanks for your contribution, Gowthamraj!
I updated your account so you can opt into security advisory coverage now.
Here are some recommended readings to help with excellent maintainership:
You can find lots more contributors chatting on Slack or IRC in #drupal-contribute. So, come hang out and stay involved!
Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.
Thanks to the dedicated reviewer(s) as well.