Skip to main content
Topic: {REALNAME} not interpreted in notification emails  (Read 3134 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

{REALNAME} not interpreted in notification emails

A member just reported that from notification by email from mentions and likes REALNAME is displayed instead of the member name. I initially thought it was related to translations but everything seems translated fine. So in my profile I changed language from Italian to English and here is what I received :


Code: [Select]
{REALNAME},

this email is to to inform you that test1 has just has liked the message https://www.skodaclub.it/index.php?msg=147081 at Skoda Club Italia.

Saluti,
 Il team di Skoda Club Italia.

As you can see there is mixed content, in English and also Italian.
sorry for my bad english

Re: {REALNAME} not interpreted in notification emails

Reply #1

 emanuele blames... someone! O:-)

In /sources/subs/MentionType/MentionMessageAbstract.php, the following two lines:
Code: [Select]
				$langstrings = $this->_loadStringsByTemplate($template, $members, $members_data, $lang_files, $replacements);
$replacements['REALNAME'] = $members_data[$member]['real_name'];
should be:
Code: [Select]
				$replacements['REALNAME'] = $members_data[$member]['real_name'];
$langstrings = $this->_loadStringsByTemplate($template, $members, $members_data, $lang_files, $replacements);
Bugs creator.
Features destroyer.
Template killer.

Re: {REALNAME} not interpreted in notification emails

Reply #2

I get an error when mentioning a member if I do that edit:

Code: [Select]
Warning: Illegal offset type in /public/sources/subs/MentionType/MentionMessageAbstract.php on line 205

Warning: Illegal offset type in /public/sources/subs/MentionType/MentionMessageAbstract.php on line 205

and line 205 is
Code: [Select]
{
 $langs[$users_data[$user]['lngfile']] = $users_data[$user]['lngfile'];
 }

The email sent is empty, no subject and no text.
sorry for my bad english

Re: {REALNAME} not interpreted in notification emails

Reply #3

I also found these errors in elkarte log https://screenshots.firefox.com/3aUHkn25c9NJHPUc/www.skodaclub.it
test1 is the member I used to make the tests. With test1 I mentioned my account which has the notifications enabled by email for likes, mentions, etc
sorry for my bad english

Re: {REALNAME} not interpreted in notification emails

Reply #4

Quote from: radu81 – I get an error when mentioning a member if I do that edit:

Code: [Select]
Warning: Illegal offset type in /public/sources/subs/MentionType/MentionMessageAbstract.php on line 205

Warning: Illegal offset type in /public/sources/subs/MentionType/MentionMessageAbstract.php on line 205

and line 205 is
Code: [Select]
{
 $langs[$users_data[$user]['lngfile']] = $users_data[$user]['lngfile'];
 }

The email sent is empty, no subject and no text.

Seems strange that this is caused by the fix I proposed, at least I can't see any reason that the replacement I suggested could induce this error.

The other set of errors are interesting, but... I see something wrong, but needs investigation.
Bugs creator.
Features destroyer.
Template killer.

Re: {REALNAME} not interpreted in notification emails

Reply #5

Problem solved, or at least one problem was solved :)

The line code you mentioned does not exist:
Code: [Select]
				$langstrings = $this->_loadStringsByTemplate($template, $members, $members_data, $lang_files, $replacements);
is actually:
Code: [Select]
				$langstrings = $this->_loadStringsByTemplate($template, $keys, $members, $members_data, $lang_files, $replacements);
so it was enough to invert those 2 lines like you suggested and the notification for a liked message arrives correctly.

Now if someone @mention me I get this message by mail:
Code: [Select]
radu,

la presente email รจ per avvisarti chea  ha appena citato un tuo messaggio in https://www.skodaclub.it/index.php?msg=188466 su Skoda Club Italia.

Saluti,
 Il team di Skoda Club Italia.
My nick is correct, but is missing the author of the mention.
sorry for my bad english

Re: {REALNAME} not interpreted in notification emails

Reply #6

Ouch!
I guess I hit ctrl+backspace by mistake... :-[
Sorry.

hmm... is the quote the only one where the name doesn't appear?
Bugs creator.
Features destroyer.
Template killer.

Re: {REALNAME} not interpreted in notification emails

Reply #7

The other mails seemed fine, but I'll do another test just to be sure. 
sorry for my bad english

Re: {REALNAME} not interpreted in notification emails

Reply #8

Found, yes, this and the mention were affected.
In both case:
Code: [Select]
'ACTIONNAME' => $this->_task['notifier_data']['name'],
should become:
Code: [Select]
'ACTIONNAME' => $this->_task['source_data']['notifier_data']['name'],
files affected:
sources/subs/MentionType/QuotedmemMention.php
sources/subs/MentionType/MentionmemMention.php
Bugs creator.
Features destroyer.
Template killer.

Re: {REALNAME} not interpreted in notification emails

Reply #9

Ok, I just tested:
- Likes - works fine with the edit suggested
- Mention - works fine with the edit suggested
- Quote - works fine with the edit suggested
- Add buddy - works fine

- UnLike (like removed) - no email received even if immediate notification is active on my profile and also available in ACP
There is also this notification "Notify when email notifications are disabled (mention only)" which I don't know what exactly does and how to test it.

Edit: while you are looking at QuotedmemMention.php you may want to clean the code by removing the lines 115-136 ;)
Last Edit: April 29, 2018, 07:22:54 pm by radu81
sorry for my bad english

Re: {REALNAME} not interpreted in notification emails

Reply #10

Quote from: radu81 – - UnLike (like removed) - no email received even if immediate notification is active on my profile and also available in ACP
There is also this notification "Notify when email notifications are disabled (mention only)" which I don't know what exactly does and how to test it.
I think this was left without email on purpose... I'm not sure about the rationale.

Quote from: radu81 – Edit: while you are looking at QuotedmemMention.php you may want to clean the code by removing the lines 115-136 ;)
Not really, there is no test yet. :P
Bugs creator.
Features destroyer.
Template killer.

Re: {REALNAME} not interpreted in notification emails

Reply #11

Quote I think this was left without email on purpose... I'm not sure about the rationale.
At this point should be better to remove this option from Acp and notifications in user profile.
sorry for my bad english