How to remove Message text in Email notifications for Private Messages?

Started by RGMears, May 16, 2019, 06:44:30 AM

Previous topic - Next topic

RGMears

I have "Don't allow post text in notifications" checked in Features and Options.
When sending notifications about new posts the post text does not display.
However, when receiving notifications of new Private Messages the message text displays in the email.
I am using SMF 2.0.15.
I had eNotify installed but have removed it. It was causing redirection problems after logging in.
This is a private forum. I do not want message text in notifications to members.
Please advise.
Thanks.

Kindred

Please start your own topic,  especially since your question is different from the original thread.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."


a10

2.0.19, php 8.0.23, MariaDB 10.5.15. Mods: Contact Page, Like Posts, Responsive Curve, Search Focus Dropdown, Add Join Date to Post.

RGMears

I have searched this Topic extensively. And I came across the thread you linked to. It seemed somewhat unresolved which is why I started this.

Illori

the below message from that topic has the steps you need to follow. what you want done, cannot be completed without a code edit.

Quote from: Sir Osis of Liver on June 27, 2018, 11:27:32 PM
PersonalMessage.english.php

Find this -



// Don't translate SENDER or MESSAGE in this language string; they are replaced with the corresponding text - use numeric entities too.
$txt['pm_email'] = 'You have just been sent a personal message by SENDER on ' . $context['forum_name'] . '.' . "\n\n" . 'IMPORTANT: Remember, this is just a notification. Please do not reply to this email.' . "\n\n" . 'The message they sent you was:' . "\n\n" . 'MESSAGE';
$txt['pm_multiple'] = '(multiple recipients: \'name1, name2\')';



Change to this -



// Don't translate SENDER or MESSAGE in this language string; they are replaced with the corresponding text - use numeric entities too.
$txt['pm_email'] = 'You have just been sent a personal message by SENDER on ' . $context['forum_name'] . '.' . "\n\n" . 'IMPORTANT: Remember, this is just a notification. Please do not reply to this email.';
$txt['pm_multiple'] = '(multiple recipients: \'name1, name2\')';




RGMears

It also goes on to say this:
Quote from: SychO on July 20, 2018, 06:51:26 AM
guess you'd have to change
$mailmessage = str_replace(array('SUBJECT', 'MESSAGE', 'SENDER'), array($subject, $message, un_htmlspecialchars($from['name'])), $txt['pm_email']);
to$mailmessage = str_replace(array('SUBJECT', 'SENDER'), array($subject, un_htmlspecialchars($from['name'])), $txt['pm_email']);

in Subs-Post.php, correct?
and this:
Quote from: Arantor on July 20, 2018, 06:55:30 AM
So you need to splice in new language strings that don't have that problem, and conveniently leave out the MESSAGE part to not be replaced in while you're at it.
Is all of this required?

Illori


Arantor

Because the part you quoted sums up what I suggested, and the other stuff isn't needed :)

RGMears

There's my confusion Illori.
You and Arantor appear to be saying different things are needed.
Which of the quoted bits of code do i use?
Or do I use both?

Arantor

Go with what Illori says because it's how to do what I said.


RGMears

I spoke too soon.
Now I get a link in the notification that says this:
https://website/index.php?action=pm;sa=send;f=inbox;pmsg=40;quote;u=14
Obviously the wrong place to send someone.

Sir Osis of Liver

Did you change anything other than PersonalMessage.english.php?
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

RGMears

No. I simply copied and pasted the code which Illori posted in PersonalMessage.english.php.
However, looking back at some earlier PM notices, which contained the message, the link is the same. It also goes to the New Message page with the editor pane and the PM from the other member is wrapped in quote tags.
In my view the link should be to the PM from the sender.
Should I start a new Topic?

a10

Was a pain many years ago, after evaluating what to do, chose to keep the text in the notif email, while adding a much clearer 'do not reply' warning. Did cut down the problem by 99% :O)

PersonalMessage.english.php

$txt['pm_email'] = 'You have just been sent a Personal Message by SENDER on ' . $context['forum_name'] . '.' . "\n\n" . '***** DO NOT REPLY TO THIS EMAIL ***** - THIS IS ONLY A NOTIFICATION ABOUT A NEW PM -' . "\n\n" . 'The message they sent you was:' . "\n\n" . 'MESSAGE';
$txt['pm_multiple'] = '(multiple recipients: \'name1, name2\')';
// Use numeric entities in the below string.
$txt['instant_reply'] = 'REPLY TO THE PERSONAL MESSAGE HERE:';
2.0.19, php 8.0.23, MariaDB 10.5.15. Mods: Contact Page, Like Posts, Responsive Curve, Search Focus Dropdown, Add Join Date to Post.

Sir Osis of Liver

Unless you changed something else, the link in the email should take you to reply editor with pm quoted.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

RGMears

That is what is happening.
My question is how to make it simply go to the message. The same as in most email clients.

Illori

depending on what view of PM's are set as the link is different. I think the way it is set is the best way to get the user directly to the message that was sent.

Sir Osis of Liver

If you want to link to the message -

Subs-Post.php

Find this -



$mailmessage .= "\n\n" . $txt['instant_reply'] . ' ' . $scripturl . '?action=pm;sa=send;f=inbox;pmsg=' . $id_pm . ';quote;u=' . $from['id'];



Change to this -



$mailmessage .= "\n\n" . $txt['instant_reply'] . ' ' . $scripturl . '?action=pm#msg' . $id_pm;



Shouldn't affect anything else.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Arantor

That also depends which view you're in - if you're not in 'all at once', you have limited chance of seeing the right message.

RGMears

Sir Osis's posted code change works:
    All at once > list displays on top message follows
    One at a time > message appears on top list follows
    As a conversation > list displays on top message follows

Arantor

Only if the message is from the most recent conversation, or the most recent message.

RGMears

The message link in the email is specific:
   ...forum/index.php?action=pm#msg44
Where else could someone be sent?

Arantor

That takes them to the front page of action=pm, which in one-at-a-time is the most recent message. In conversation mode, the most recent conversation.

The #msg is almost incidental at that point since it doesn't get sent to the server to tell it anything and is only usable in the browser to scroll down the page.

If you have two emails because you get two PMs, the link in the first email is probably wrong unless all your users only ever use all-at-once, because both emails would only show the most recent message, regardless of anything, because that's the point of conversation mode and one-at-a-time mode.

But I'm only speaking as the author of a mod specifically designed around fixing the PM mode to be sane, and making sure it was sane in 2.1 when actually on the development team, I'm probably wrong about everything in this thread, especially as Sir Osis seems to be fond of reminding me lately.

Sorry for trying to not let you believe you had a fix that you actually didn't.

Sir Osis of Liver

Quote from: Arantor on May 20, 2019, 07:02:56 PM
I'm probably wrong about everything in this thread, especially as Sir Osis seems to be fond of reminding me lately.

Getting touchy in your old age?  I don't often disagree with you, but I do entertain different points of view.  In this case, don't know why 2.0 personal messaging was designed the way it is.  Way too complicated, too many options.  At some point in development, someone should make a decision as to which of several options is best, and just do it that way.  Trying to incorporate all variations as user options just makes things complicated, and in some cases opaque, for the typical user.  Why are sent pms not saved by default?  Makes no sense.  Just because you can do something doesn't mean you should.

But yes, as for OP's request, the solution I posted is dependent on how user has ordered pms in profile, as Illori pointed out above.  Since most people don't know (or care) that they can change how pms are displayed, you can just set the option that works best for all users.

Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

RGMears

The plot thickens, as they say.
Arantor is correct. The id "#msg45" is removed from the address bar in the browser.
    When "One at a time" is selected, only the most recent PM displays. Not necessarily the PM in the link.
    When "All at once" is selected, all messages are displayed in the order they were sent.
    When "In a conversation" is selected, only the most recent PM displays. Again not necessarily the PM in the link.
This is remarkably screwy.
I recently convinced a group I am working with to use a private forum (built with SMF, of course) instead of multiple recipients in emails and using Google Docs for working on publishable material. That Private Messaging is available helped to "sell" them on the idea.
That it works so erratically doesn't help here.


And there is another hiccup which perhaps warrants a new Topic:
If a "Visual verification image to display" is selected (other than None) then every user (except administrators) has to type the characters in the "Visual verification image" (in the box below) in order to send a Private Message. The only option regarding verification is "Require verification on registration page". Registration and Private Messaging are not connected. Once registered, users should not have to pass a security check every time they want to PM someone.

Illori

Quote from: Sir Osis of Liver on May 20, 2019, 10:41:46 PM
Why are sent pms not saved by default? 

that has been corrected in SMF 2.1, we cannot fix it in SMF 2.0 at this point. you are more then welcome to create a mod to fix it if you want.

Quote from: Sir Osis of Liver on May 20, 2019, 10:41:46 PM
Since most people don't know (or care) that they can change how pms are displayed, you can just set the option that works best for all users.

that is not an option that can be set globally via the UI.

Quote from: RGMears on May 21, 2019, 05:06:43 AM
And there is another hiccup which perhaps warrants a new Topic:
If "Require verification on registration page" is selected then every user (except administrators) has to type the characters in the "Visual verification image" (in the box below) in order to send a Private Message. These two things are not connected. Once registered, users should not have to pass a security check every time they want to PM someone.

you can disable that feature admin -> security and moderation -> anti-spam change the post count under which users must pass verification when sending personal messages to 0 to disable it.

RGMears

Thanks for the heads up on requiring verification in relation to post count on personal messages, Illori.

Sir Osis of Liver

The pm system doesn't work erratically, it just isn't designed to do what you want it to do.  Basically you're trying to email a url that will link to a specific message, don't know if there's any way to do that.  Will take a look at the code soon as I get a chance.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

RGMears

Thanks Sir Osis.
A question, though. If the link in a notification for a post can take the user right there why can't the same thing happen with a PM?
And, if I copy and paste the link in the notification email in the address bar of the browser I am taken right to the message.

Sir Osis of Liver

Would have to link directly to id_pm, don't know if that can be done.  Taking a look now.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Arantor

Quote from: Sir Osis of Liver on May 20, 2019, 10:41:46 PM
Getting touchy in your old age?

No, just fed up by people who spout opinions that are objectively wrong and seem intent on wasting my time.

Why does SMF 2.0 have multiple choices? Well, 1.1 only had the one choice and it wasn't super well liked, and more choices were added, but at some point in time, people complained that 'it changed' and enough people complained about new things that the developers at the time decided to make it optional so people could opt into the new choices. Removing the older choices always seems to upset people even if the new choice is in every respect objectively better, but the developers of this project historically have been shouted at for not making every damn thing optional. (I am a strong advocate of not having many options, but having the right options, but this too has historically been a controversial opinion to hold.)

Sent PMs were not saved by default originally for performance reasons; back in 2003 when this started out, space was much more scarce, so it's a deliberate design decision that discourages people clogging up the server with too many messages (since once the recipient and the sender both delete a message, the actual message text is pruned from the database to converse space). 15+ years later, server space is cheap, and the decision was made to make saving sent PMs mandatory. A little bit of context goes a long way.

Quote
But yes, as for OP's request, the solution I posted is dependent on how user has ordered pms in profile, as Illori pointed out above.  Since most people don't know (or care) that they can change how pms are displayed, you can just set the option that works best for all users.

If only admins could actually configure those values for people. Requires a mod, but I have no inclination to re-provide the mod I wrote for this purpose.

Sir Osis of Liver

   

Quote from: Arantor on May 23, 2019, 05:13:30 PM
I am a strong advocate of not having many options, but having the right options, but this too has historically been a controversial opinion to hold.

That basically was my point, so we're actually in agreement.

Quote
If only admins could actually configure those values for people. Requires a mod, but I have no inclination to re-provide the mod I wrote for this purpose.

Admins can set 'Show most recent personal messages at top' for all members in theme settings, don't know if that helps OP.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

RGMears

Quote from: RGMears on May 21, 2019, 06:49:07 PM
... if I copy and paste the link in the notification email in the address bar of the browser I am taken right to the Message.
Seems to me, other discussions aside, that when clicking on the link in the email notification the user should end up on the page where the new Message is displayed, regardless of which option for how Messages are displayed.

Sir Osis of Liver

If you look at message headers in a topic, the title for each post is a link, so you can link directly to any post on the forum, like this.  The headers on pms are not links, you can only link to the top of each pm thread.  Depending on which display option is in effect, that can be the first (oldest) or last (newest) pm in the thread.  You want to link direrctly to the newest, but there's no simple way to do that if users have different display preferences.
 
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

RGMears

Yet each message has an "id" tag > <a id="msg45"></a>
It is positioned inside the "poster" information group of elements.
And the link to the message, within the list of messages in either inbox or sent items, is:
    website/index.php?action=pm;pmid=45;kstart;f=inbox;start=0;sort=date;#msg45


And viewing messages seems best in "As a conversation".


I am not sure what, if anything, can be done (I am a designer not a programmer). But it seems to me that the closer this can come to emulating the way email clients work the better. The way it works now is off putting to people.

Sir Osis of Liver

Every message has an id_pm, same as topic posts have id_msg, difference is they're not included in pm template as they are for messages, so you can't link to them directly.  Probably could be custom coded, never tried it.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

RGMears

You can link to each PM internally. Why can this not be case for notification links?

Sir Osis of Liver

Quote from: RGMears on May 24, 2019, 05:09:15 AM
And the link to the message, within the list of messages in either inbox or sent items, is:
    website/index.php?action=pm;pmid=45;kstart;f=inbox;start=0;sort=date;#msg45

Doesn't work on this forum.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Arantor


RGMears

So, I had received a notification of a new personal message.
I was already logged in when I noticed it. When I tapped on the link in my email client I was taken directly to the message:
   website/index.php?action=pm#msg54
I logged out and tried again. I was taken to the PM index page:
   website/index.php?action=pm
I also received a notification of a new reply to a topic.
Whether logged in or not I was taken directly to the new post when I tapped on the link.

Sir Osis of Liver

This is the link I get in pm notification -

https://www.simplemachines.org/community/index.php?action=pm;sa=send;f=inbox;pmsg=585123;quote;u=424443

It takes me to reply editor with pm quoted.

If I change it to this -

https://www.simplemachines.org/community/index.php?action=pm;f=inbox;pmsg=585123;u=424443

It takes me to top of the pm conversation with subject header above that.  Can't get it to go to specific pmsg. >:(

Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

RGMears

Yeah, tell me about it. :)
I tried using an older link to the PM (with the msg #) in the address bar of the browser and ended up on the most recent PM.

Advertisement: