ElkArte Community

Elk Development => Bug Reports => Exterminated Bugs => Topic started by: radu81 on April 20, 2018, 01:32:24 pm

Title: {REALNAME} not interpreted in notification emails
Post by: radu81 on April 20, 2018, 01:32:24 pm
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.
Title: Re: {REALNAME} not interpreted in notification emails
Post by: emanuele on April 21, 2018, 08:05:09 am
/me 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);
Title: Re: {REALNAME} not interpreted in notification emails
Post by: radu81 on April 22, 2018, 06:14:52 pm
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.
Title: Re: {REALNAME} not interpreted in notification emails
Post by: radu81 on April 23, 2018, 03:50:00 am
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
Title: Re: {REALNAME} not interpreted in notification emails
Post by: emanuele on April 23, 2018, 02:53:14 pm
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.
Title: Re: {REALNAME} not interpreted in notification emails
Post by: radu81 on April 23, 2018, 04:53:59 pm
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.
Title: Re: {REALNAME} not interpreted in notification emails
Post by: emanuele on April 27, 2018, 04:05:47 pm
Ouch!
I guess I hit ctrl+backspace by mistake... :-[
Sorry.

hmm... is the quote the only one where the name doesn't appear?
Title: Re: {REALNAME} not interpreted in notification emails
Post by: radu81 on April 27, 2018, 04:54:01 pm
The other mails seemed fine, but I'll do another test just to be sure. 
Title: Re: {REALNAME} not interpreted in notification emails
Post by: emanuele on April 29, 2018, 01:16:01 pm
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
Title: Re: {REALNAME} not interpreted in notification emails
Post by: radu81 on April 29, 2018, 06:54:53 pm
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 ;)
Title: Re: {REALNAME} not interpreted in notification emails
Post by: emanuele on April 30, 2018, 03:51:29 am
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
Title: Re: {REALNAME} not interpreted in notification emails
Post by: radu81 on April 30, 2018, 05:51:16 am
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.