Erroneous social paper notifications
Hi Boone -- I just received a bunch of notifications that social papers I'm not following have been updated. First, I doubt whether they have truly been updated, and Second, I know I'm not following them. Here is a sample notification:
The paper "Rhetorical Analysis of Mother Tongue" has been updated [CUNY Academic Commons]
CUNY Academic Commons
11:52 AM (1 minute ago)
The paper "Rhetorical Analysis of Mother Tongue" has been updated
Editor: Sajan Chokar (He/Him/His)
Visit the paper: https://commons.gc.cuny.edu/papers/rhetorical-analysis-of-mother-tongue/
You receieved this notification because you are following the paper "Rhetorical Analysis of Mother Tongue". To unfollow, visit https://commons.gc.cuny.edu/papers/rhetorical-analysis-of-mother-tongue/ and click the Unfollow button.
#4 Updated by Boone Gorges about 2 months ago
- Category name set to Social Paper
- Assignee changed from Boone Gorges to Raymond Hoh
I've spent a few minutes looking into this.
- The papers in question are indeed being edited.
- This is triggering https://github.com/cuny-academic-commons/social-paper/blob/master/includes/hooks-buddypress-notifications.php#L405
- social-paper is fetching the "leader_id" of the paper in order to determine followers https://github.com/cuny-academic-commons/social-paper/blob/master/includes/hooks-buddypress-notifications.php#L416
- This checks the 'cacsp_activity_id' postmeta, but it's empty in the case of these paper objects, and the function doesn't appear to be able to create the activity item https://github.com/cuny-academic-commons/social-paper/blob/c6461a16713fe2956549552ea52ee45d814efe67/includes/hooks-buddypress-follow.php#L1047 As such, a NULL value is stored in the wp_1_postmeta table, and the 'leader_id' is null as well.
- The behavior of bp_follow_get_followers() is difficult to predict when leader_id is empty. In this case, it's pulling up ~975 users, which explains why so many got the email.
For the moment, I've commented out the call to wp_mail() in social-paper: https://github.com/cuny-academic-commons/social-paper/blob/master/includes/hooks-buddypress-notifications.php#L146
Ray, could you please investigate? At the very least, buddypress-followers should have a failsafe, such that when no leader_id is passed, no followers are returned. It may also be helpful to see why social-paper isn't properly generating the 'cacsp_activity_id' postmeta value, though given the status of social-paper, it's not worth sticking a lot of time into it.
#6 Updated by Raymond Hoh about 2 months ago
- Status changed from Assigned to Resolved
- Target version set to 1.18.24
I've added a hotfix for buddypress-followers when passing a null value to either
follower_id during the fetch routine: https://github.com/cuny-academic-commons/cac/commit/f13b41a49484faa85ea9df863c5b860e83b15432. This is live on production.
As to why social-paper is saving the activity ID as a null value, the issue is the author added a password to the paper and bp_activity_post_type_publish() doesn't support activity recording for posts with passwords: https://github.com/buddypress/buddypress/blob/f71f78ae681068f932b7856ffe59c97ccaacb7bd/src/bp-activity/bp-activity-functions.php#L2157-L2159.
The hotfix I added should address this.