Project

General

Profile

Actions

Bug #11513

closed

Extra group notification

Added by Gina Cherry almost 5 years ago. Updated almost 5 years ago.

Status:
Resolved
Priority name:
Normal
Assignee:
Category name:
Email Notifications
Target version:
Start date:
2019-06-03
Due date:
% Done:

0%

Estimated time:
Deployment actions:

Description

I was looking at a blog post that I published on May 31 and I received a group email notification that a new blog post had been published: https://screencast.com/t/DmqhY62u4cB. I don't think I even made any changes or updated the blog post. I did switch to the HTML view in the block editor. Not sure about the details that preceded the email since this was an unexpected event.

Actions #1

Updated by Boone Gorges almost 5 years ago

Was a notification sent when it was initially published?

Actions #2

Updated by Gina Cherry almost 5 years ago

Yes, it was.

Actions #3

Updated by Boone Gorges almost 5 years ago

  • Status changed from New to Reporter Feedback

Here are the specifics of the bug report:

group is https://commons.gc.cuny.edu/groups/bmcc-open-pedagogy-seminar/
site is https://bmccopenpedagogy.commons.gc.cuny.edu/
post triggering the notification is https://bmccopenpedagogy.commons.gc.cuny.edu/2019/05/31/what-is-open-pedagogy/

Gina, when you say "I was looking at a blog post", can you please clarify the following:
1. Was "a blog post" the specific blog post linked above, or was it some other post on the site?
2. Were you looking at it on the front end https://bmccopenpedagogy.commons.gc.cuny.edu/2019/05/31/what-is-open-pedagogy/ or in the Dashboard https://bmccopenpedagogy.commons.gc.cuny.edu/wp-admin/post.php?post=9&action=edit ?

Oddly, I don't see any entries in the group activity stream https://commons.gc.cuny.edu/groups/bmcc-open-pedagogy-seminar/ that correspond to the blog post itself - I see a couple of items related to comments, but none linked to the publication of the post. (They're not in the database either.) Gina, is there a chance they were manually deleted, by you or by another group admin? These activity items are responsible for triggering email notifications, so it's important that I have a sense of this in order to piece together a story of what's happened.

Actions #4

Updated by Gina Cherry almost 5 years ago

I was looking at the post that triggered the notification in the Dashboard. I was trying to figure out why the links weren't opening in a new tab (as reported in a separate bug report), so I switched to HTML mode. I was using the block editor.

I did manually delete some activity items in the group stream. I do not recall deleting an item for this particular notification, but I'm not 100% sure.

I checked with another group member/admin and she also received the email notification yesterday.

Actions #5

Updated by Boone Gorges almost 5 years ago

  • Assignee set to Raymond Hoh

Based on this, my guess is that the following happened:

1. When you were looking at the item in the Dashboard, WP saved a version of the post (a draft or something like that)
2. This triggered BP's activity creation routine
3. Because you'd deleted the old activity item, BP thought it needed to create a new one https://buddypress.trac.wordpress.org/browser/tags/4.3.0/src/bp-activity/bp-activity-functions.php?marks=3938,3940,3943-3945#L3921

I think that the behavior in 3 (and in BP itself) is probably OK. The problem here is that the activity creation routine should not have been triggered by an autosave, or indeed anytime that a user action is not involved. Ray, could you please take a few minutes to think this over, and to try reproducing? Note that this could be a Gutenberg thing.

I should note that deleting post-related activity items causes BP to think that the item has never been recorded in the stream. As such, when you delete the activity item, it'll be recreated the next time you save the edited post. It's not currently technically possible for BP to distinguish between an activity item that has been manually deleted by the user ("I don't want to see this in the activity stream") vs one that was not created for some other inadvertent reason. As such, I don't recommend deleting these activity items, as it's likely that they'll crop up again in the future in unexpected ways.

Actions #6

Updated by Gina Cherry almost 5 years ago

Update on this. I needed to edit that particular blog post and when I updated, yet another email notification was sent to the group saying that I had written a new blog post. I haven't deleted any activity items from the group stream since sometime before yesterday (and will not do so going forward).

Actions #7

Updated by Raymond Hoh almost 5 years ago

It's not currently technically possible for BP to distinguish between an activity item that has been manually deleted by the user ("I don't want to see this in the activity stream") vs one that was not created for some other inadvertent reason.

Maybe we can change the "Send to Group" checkbox to save a marker into postmeta. Then, it might be possible to bail out of BP's activity recording routine with some custom code. Hopefully, Gutenberg's code doesn't make this too problematic. I'm guessing Gutenberg might save the postmeta after the post is published, which would complicate things.

I'll look into this.

Actions #8

Updated by Boone Gorges almost 5 years ago

Thanks, Ray. The postmeta approach is, in fact, what already happens - this was a recent change. https://github.com/cuny-academic-commons/cac/blob/87dc1f6a6a9055b4053c01a44e31903d7e377afc/wp-content/plugins/cac-bp-custom-includes/groupblog.php#L735

Gina indicated that she received a notification for the original item, so I wonder whether this doesn't, in fact, have anything to do with the 'Send to group' toggle.

Actions #9

Updated by Boone Gorges almost 5 years ago

  • Category name set to Email Notifications
  • Target version set to 1.15.4
Actions #10

Updated by Raymond Hoh almost 5 years ago

Boone, I think the issue is we do not enqueue the assets/send-to-group.js file for posts that are already published:
https://github.com/cuny-academic-commons/cac/blob/87dc1f6a6a9055b4053c01a44e31903d7e377afc/wp-content/plugins/cac-bp-custom-includes/groupblog.php#L716
https://github.com/cuny-academic-commons/cac/blob/87dc1f6a6a9055b4053c01a44e31903d7e377afc/wp-content/plugins/cac-bp-custom-includes/groupblog.php#L668

Since that file is tied to the metabox and is only enqueued for unpublished posts, our send_to_groupblog postmeta marker is never set when editing a published post. Thus, the regular BP activity recording would take place due to:
https://github.com/cuny-academic-commons/cac/blob/87dc1f6a6a9055b4053c01a44e31903d7e377afc/wp-content/plugins/cac-bp-custom-includes/groupblog.php#L748

Perhaps, the easiest way to address this is to enqueue the assets/send-to-group.js file all the time if the blog is connected to a group. The existing metabox display logic can stay the same.

What do you think, Boone?

Actions #11

Updated by Boone Gorges almost 5 years ago

Whoa, good find, Ray. Enqueuing the JS all the time seems fine to me. Could you please make that change?

Actions #12

Updated by Raymond Hoh almost 5 years ago

  • Status changed from Reporter Feedback to Staged for Production Release

Done. See https://github.com/cuny-academic-commons/cac/commit/ac4c159de966df064a13d6dca9adafb2beb511a1

I tested the following situations:
- "Send to Group" checked for a new post -- this sent a group email as expected
- "Send to Group" unchecked for a new post -- this did not send a group email as expected
- Editing an older post that doesn't already have an activity item recorded for it -- this did not send a group email as expected

I think we should be good now.


I had to make changes to our 'send_to_group_blog' meta marker so it is saved as an integer instead of a boolean. The reason I had to do this was to make sure that our marker is always saved into the database when the "Send to Group" checkbox is unchecked.

I also had to make a change to the JS file to set the 'send_to_group_blog' to 0 when a user is editing a post:
https://github.com/cuny-academic-commons/cac/commit/ac4c159de966df064a13d6dca9adafb2beb511a1#diff-d53d8a78e5a310be3e5840e42a99bcfeL9

This is to ensure that when editing a post that the group email notification is not sent. This also means that we lose a little fidelity for our 'send_to_group_blog' marker anytime when a post is edited. If that is a concern, we could look into creating another postmeta marker just for post edits, but that might be overkill.

Actions #13

Updated by Boone Gorges almost 5 years ago

  • Status changed from Staged for Production Release to Resolved
Actions

Also available in: Atom PDF