Currently, the Privatemsg Email Notification Module uses old-style tokens (!username, !site, and !author). These tokens don't currently work in the D7 port.
Since we're now close to finalizing full D7 core token integration (when sending Private Messages), we need to switch over to these new-style tokens in the Email Notification Module, too. This includes support for the token browser that is part of the D7 Token contrib module.
So I've created this issue so that we don't forget. We'll be able to proceed with this as soon as http://drupal.org/node/511796 is committed.
--Ben
Comments
Comment #1
BenK commentedComment #2
BenK commentedOne more thought: We'll probably need to add a token for the message body itself. This way, the actual message could be included in the e-mail notification.
--Ben
Comment #3
berdirJust changing the title and component. One question, though... why do you always write issue titles capitalized? ;)
Comment #4
BenK commentedI'm bumping this issue to the top of the queue since D7 token integration is now committed... :-)
Comment #5
BenK commentedWondering if we should work on this before the 7.x-alpha release?
Comment #6
berdirFinally, here is a first attempt, requires the patch at #946812: Proper entity loading, uri callback and more tokens.
Tokens have been changed, default values updated, token browser integrated and there is an update function that should convert the old tokens to the new ones.
Comment #8
BenK commentedHey Berdir,
The patch looks really good. I tested all of the Private Message tokens and they seem to work well. Here are a couple of issues I noticed:
1. Tokens placed in the e-mail subject line do not appear to be escaped properly. For instance, my test site name is "Ben's Site" (using the [site:name] token). But it is displaying in the email subject line like this:
"Ben's Site"The apostrophe is not being escaped. Note that it appears fine in the message body, so this is just an issue with the e-mail subject line.
2. I'm getting some weird line breaks when using the body field token. There are line breaks, but it's at random places... not at the paragraphs. Per our discussion in IRC, we should look at how other notification modules are doing this in d7 (comment_notify for example).
--Ben
Comment #9
BenK commentedI also noticed this:
3. In my PM message itself (not the email notify template), I used tokens and included the subject token ([privatemsg_message:subject]) in my body text. The tokens used in my PM new message subject line were as follows: "Hey [privatemsg_message:recipient] I've got some info for you... [privatemsg_message:url]"
In my e-mail notification, the subject token (in the body text) appeared like this:
--Ben
Comment #10
BenK commentedSo there appears to be an issue with token handling if tokens were also included in the original PM message. For instance, I sent the following message to a user. Here is how the message displayed in the sender's sent mail (who has permission to use tokens):
However, it appeared in the recipient's e-mail notification (using the message body token) like this:
As you can see, the recipient shouldn't be seeing the "< Token" format and some tokens are not being replaced.
--Ben
Comment #11
dave reidWhy are you using
< Token [privatemsg_message:author] >rather than just[privatemsg_message:author]?Comment #12
BenK commented@Dave Reid: One feature of the token implementation in PM is token validation: If a token is correct, it prints it as "< Token [tokenname]" for the sender during message preview and in sent messages. If a token is invalid, it prints an invalid message and does some CSS styling to highlight it for the sender.
So in this issue, the recipient is incorrectly seeing this formatting (in an e-mail notification) when it should only be displaying to the sender.
--Ben
Comment #13
berdir1. Fixed. Tokens aren't sanitized anymore.
2. How did you test this? It's working fine for me. If you used the debug output to verify, note that you need to look at the sourcecode and not what's displayed.
Example I used to test:
----
Hi Fred Editor,
This is an automatic reminder from the site Berdir's Drupal 7 Testsite. You have received a new private message from Berdir.
The message:
This is a multi-line message.
This is a new line.
This also. This not.
These are tokens: editor - asdf
Bla bla
To read your message, follow this link:
http://d7/messages/view/152
If you don't want to receive these emails again, change your preferences here:
http://d7/user/144/edit
-----
3. This should be fixed.
Also removed the dpm() statement.
Comment #14
BenK commentedHey Berdir,
#1 and #3 are fixed. Here are the issues that remain:
#2: This seems to be an issue only if you're using full paragraphs of text (not just short lines). The code looks fine except that the line just ends instead of being a continuous paragraph. It's not a huge deal, but I think that e-mail text in a paragraph is just supposed to continue indefinitely and wrap at the full width of the browser area. Instead, the paragraph just stops at predetermined lines, some shorter than others.
Here's the paragraph I used for testing:
If there's no easy way to solve this, it's not a major issue and we could let it slide.
#4 (NEW): When I'm sending a message to a role, individual users in that role are not receiving e-mail notifications. If I address an e-mail individually to a user in the role, they will receive an email notification. But once I send a message to a role itself, the individual e-mail notifications are not being sent out. I'm not sure if this is related to this patch or a separate issue.
--Ben
Comment #15
berdir2. Tried with your text and still can't reproduce. I haven't actually check the sent mail but in the generated mail body, the whole thing was on a single line. And after that, it must be either Drupal core or maybe even your mail client that does something strange. Not something that we can solve IMHO.
4. We already have an issue for this, two actually: #967164: E-mails not sent if message was sent to role members. Someone even provided a patch but didn't update yet.
Setting back to needs review, since there are no code changes.
Comment #16
berdirActually, there is a change. I fixed a typo in a comment :)
Comment #17
BenK commentedOkay, let's not worry about #2 and we can take care of #4 on the other thread.
So just to be thorough, I tested the new patch in #16 and everything is working great. This is RTBC! :-)
--Ben
Comment #19
berdir#16: notifiy_tokens3.patch queued for re-testing.
Comment #20
BenK commentedComment #21
berdirCommited!