a8cteam51 / safety-net

Scrub options, deactivate denylisted plugins, and delete user data on development sites.
17 stars 1 forks source link

Block JP post notifications #106

Closed NickGreen closed 5 months ago

NickGreen commented 11 months ago

Slack convo here: p1696364332610579-slack-C018UMRUN3V

I think we have a filter at jetpack to block email sending, in case that's helpful for staging sites

I believe Mikael’s referring to apply_filters ( 'jetpack_is_post_mailable', bool true )

https://developer.jetpack.com/hooks/jetpack_is_post_mailable/

katiebethbrown commented 11 months ago

Was thinking more on this and maybe just turning off the Subscriptions module would be fine.

That would ensure that no visitor accidentally landed on the staging site and subscribed, and then never got any of the actual post notifications.

NickGreen commented 11 months ago

We are in the process of coming up with a "Safety Net Lite" version which will include all of the blocking features, but not delete any data, for use of prod and pre-prod sites.

In that case, I think there would be value to setting the filter add_filter( 'jetpack_is_post_mailable', '__return_false' ); so that no post emails get sent out. Thoughts?

katiebethbrown commented 11 months ago

In that case, I think there would be value to setting the filter add_filter( 'jetpack_is_post_mailable', '__return_false' ); so that no post emails get sent out. Thoughts?

Offhand, yes I think that's a good idea.

I was trying to think of any situation where we'd want post notifications to go out. The only thing I could think of was wanting to be able to send preview emails (peKye1-6z-p2) when we're building a site we know will use newsletters with a specific template. I'm not sure if the filter blocks those or not though. I'll ask.

Edit: Pinged Mikael here to ask: p1696449877971029-slack-C053A0D3WGK

NickGreen commented 11 months ago

I went ahead and deactivated post mailing and the subscriptions module, since the general MO with Safety Net is to block all the things, and developers can turn individual things back on if they need to test them specifically.

NickGreen commented 11 months ago

Looks like I got too impatient with this one.. oops!

This is the filter that has been suggested is this one:

/**
 * Subscriptions will only be sent for posts in the "non-existing" category.
 */
add_filter(
    'jetpack_subscriptions_exclude_all_categories_except',
    function () {
        return array( 'non-existing' ); 
    }
);

Reopening for further discussion.

NickGreen commented 5 months ago

Merged here: https://github.com/a8cteam51/safety-net/pull/118