Restore Mailing List Mode Daily Summary


(Joe Buhlig) #1

For a variety of reasons the option for mailing list mode users to receive a daily summary email was removed. It turns out there are a handful of communities that relied on this feature and as such it provoked a good discussion about the restoration of the feature. It was mentioned in that topic that I was working on this. Thanks to @lkramer and team for sponsoring this work! :tada:

This plugin adds an option to the email preferences for a user and allows them to enable the daily emails. It is NOT dependent on mailing list mode being turned on.

I should note that this essentially takes the code that was removed and wraps it up in plugin form. In the production scenario we’ve tested it in we even saw the email text/content customizations automatically pull in without extra work. The only change that was made was the addition of the standalone user preference.

Putting the code back in place is only part of the equation. It’s to be expected that admins will want to automatically turn this on for users that previously received the email. To do that you’ll need SSH access. Then you can follow these steps:

  1. Make sure you have a backup in place. Just to be safe.
  2. Enter the app and start a rails console.
    cd /var/discourse
    ./launcher enter app 
    rails c
    
  3. Run this command:
    UserOption.where(mailing_list_mode: 'f', email_digests: 't', digest_after_minutes: 1440).pluck(:user_id).each do |id| UserCustomField.find_or_create_by(user_id: id, name: "user_mlm_daily_summary_enabled").update(value: "true") end
    

EDIT:

It was brought to my attention that the Daily Activity email should probably be turned off for these users as well. To do that, you’ll need to run this command as well, but only after the previous one:

UserCustomField.where(name: "user_mlm_daily_summary_enabled", value: "true").pluck(:user_id).each do |id| UserOption.find_by(user_id: id).update(email_digests: 'f') end

Please restore email digests
"Daily updates" option for mailing list mode
Mailing list question
(Andrew Waugh) #2

@joebuhlig This started spitting errors since v1.9.0.beta15, see:


(Joe Buhlig) #3

Looks like an issue that likely started about a month ago and is due to this commit:

So as a result:


(Andrew Waugh) #4

Thanks Joe,

I have updated the Plugin on our sandbox, no more error messages there (I manually triggered the sidekiq job).


(Matthew Needham) #5

Is there any way I could change the words summaries and summary to digests and digest? Like many other interested in this, I’m migrating a mailing list, and my users are accustomed to “digest”. I think there’s too much potential for confusions with the builtin “actvity summary” and this plugin’s “daily summary”.

Thanks!


(Joe Buhlig) #6

You can! Go to Admin -> Customize -> Text Content. From there you can search for the strings you find in the locales and make changes to them from there.


(Matthew Needham) #7

Excellent, thanks! I had no idea plugin text could be changed in this way.

Discourse is surprisingly messy with the wordings here. Besides this, I noticed that "digest is still used in the bootstrap message, and in Admin -> Email -> Preview DIGEST. Makes me wonder how many orphaned artifacts are still floating around.


(Matthew Needham) #8

The discussion and screenshots I’ve seen of this feature when it was builtin was that the daily digest was a sub-option of mailing list mode, in the dropdown. Now it’s a separate options, visually at the same level as, and unrelated to mailing mist mode, but the name still says mailing list mode. Does the MLM checkbox and dropdown affect the daily digest? Yesterday I installed the plugin on my test instance and enabled digest mode for my account, but did not enable MLM. No digest has been received.

Out of curiosity, Was this a deliberate change, a side-effect of moving from builtin to plugin functionality, or something else?


(Matthew Needham) #9

I’m planning to create/activate accounts for me users, and enable daily summary for whomever mailman digest had been enabled. Since there are new accounts, I don’t have any prior values in Discourse to check, so I’m planning to set feed it a list of user_ids.

Edit: I’m not sure why I had problems earlier, but for the record, it appears that either of the following will work:

foo.custom_fields["user_mlm_daily_summary_enabled"] = true

UserCustomField.find_or_create_by(user_id: <USER_ID>, name: "user_mlm_daily_summary_enabled").update(value: "true")

The second one requires me to look up <USER_ID>, but besides this extra step, is there any advantage to using one over the other?

Thanks.


(Joe Buhlig) #10

It’s been a while, but I believe they are independent settings. I do know you would need to wait 24 hours as it checks every hour but only sends out to users who joined the site at that hour of the day. Does that make sense? It’s designed to prevent an overload of emails going out from the server at once.

Side effect. You could likely get it to work as a single setting but it would require consistent maintenance to make sure it doesn’t break with new versions of Discourse. And that’s the opposite of what I want in the plugins I build. I do a fair amount of extra work on these to make sure they’re as future proof as possible.


(Matthew Needham) #11

It makes sense, but it makes it a little hard to predict when the message should arrive.

After waiting another day, it seems clear that no digest messages are being sent. I have accounts with only MLM enabled, ones with MLM and digests enabled, and ones with only digest enabled. I am receiving activity summary emails, and MLM every-comment emails, but not “daily summary” emails. For some accounts the GUI was used, and for others the rails console. Any suggestions on how to troubleshoot where the problem might be?


(Joe Buhlig) #12

Do you have anything in the logs or is it simply not showing up? I’m getting these from a couple sites that are running the plugin currently.


(Matthew Needham) #13

I’m not finding anything in the logs, but maybe I’m not looking in the right place? Within the GUI (Admin -> Logs), I don’t see anything relevant. Same with viewing the contents of /var/discourse/shared/standalone/log/rails/production.log. Under Admin -> Email -> Sent, I do see messages with email type “digest”, but they appear to be the builtin activity summary, as they are sent to every inactive account and not exclusively to (or even inclusively to) accounts that have daily summaries enabled. We’re using Amazon SES for SMTP, and there haven’t been any notifications for bounces or complaints. I just enabled delivery notifications, so within a day I’ll be able to check for positive delivery.

Is there somewhere else I could be checking?


(Joe Buhlig) #14

I’m specifically referring to /logs. But I would expect to see some form of email log that shows them being sent.


(Matthew Needham) #15

Out of the six entries in /logs, only two aren’t about image optimization. One is Job exception: Validation failed: Badge has already been taken, and the other is Uncaught TypeError: Cannot read property 'show' of undefined Url: https://testforum.example.com/assets/plugin-third-party-7836e591aab88af977dd1de635258536ee999055ba534a632c4b2fe8983b90b7.js. Neither seems relevant to me, but I can add more details if that would be helpful.