Project

General

Profile

Bug #11513

Extra group notification

Added by Gina Cherry 15 days ago. Updated about 14 hours ago.

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

0%

Estimated time:

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.

History

#1 Updated by Boone Gorges 15 days ago

Was a notification sent when it was initially published?

#2 Updated by Gina Cherry 15 days ago

Yes, it was.

#3 Updated by Boone Gorges 15 days 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.

#4 Updated by Gina Cherry 15 days 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.

#5 Updated by Boone Gorges 15 days 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.

#6 Updated by Gina Cherry 14 days 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).

#7 Updated by Raymond Hoh 14 days 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.

#8 Updated by Boone Gorges 14 days 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.

#9 Updated by Boone Gorges 8 days ago

  • Category name set to Email Notifications
  • Target version set to 1.15.4

#10 Updated by Raymond Hoh about 14 hours 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?

#11 Updated by Boone Gorges about 14 hours ago

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

Also available in: Atom PDF