Project

General

Profile

Actions

Feature #18637

closed

Design/UX #17385: Profile CV & Account Settings

Design/UX #18150: Inbox tab

Invites do not create a BP notification

Added by Raymond Hoh 8 months ago. Updated 6 months ago.

Status:
Resolved
Priority name:
Normal
Assignee:
Category name:
Design
Target version:
Start date:
2023-08-21
Due date:
% Done:

0%

Estimated time:
Deployment actions:

- git submodule update cac-onboarding

- run notifications-backfill.php script via WP-CLI

- modify last line of invitations email template (https://commons.gc.cuny.edu/wp-admin/post.php?post=64345&action=edit) to use the following:

<span style="font-weight:bold;">Accept pending invitations by visiting your <a href="https://commons.gc.cuny.edu/members/me/notifications/action-center/">Action Center</a> page.</span>


Description

When we created the 'cac-onboarding' plugin to handle onboarding and group / site invitations (#8641), for our initial release, we made the decision to not create a BuddyPress notification when an invite is sent. See https://github.com/cuny-academic-commons/cac-onboarding/issues/30 .

As part of the new "Notifications" page, we will want to create a BP notification whenever an invite is sent so users are able to handle invitation requests from within the "Notifications" page. See https://www.figma.com/proto/c3v5FHId3eUAjZ2ennkN83/CUNY-Design---Summer-2023?page-id=3461%3A53191&type=design&node-id=3461-55432&viewport=8484%2C13384%2C0.25&t=sqKGsUW2nW5ZDQbn-1&scaling=min-zoom .

This will require the following:
1. Record a BP notification whenever a new invite is sent to an existing user.
2. Write a routine to backfill all current, pending invites so they will have a BP notification.
3. Modify the invite email to change the "Click on this link to manage your invitations" link from commons.gc.cuny.edu/members/me/invites/ to the new "Notifications > Action Center" page for existing users.


Files

notifications-backfill.php (735 Bytes) notifications-backfill.php Raymond Hoh, 2023-10-13 12:09 AM
Actions #1

Updated by Raymond Hoh 8 months ago

Boone, I've added a new branch for the cac-onboarding plugin -- bp-notifications -- that adds three new BP notifications:
1. When an invite is sent to an existing user, a BP notification is also created for the existing user
2. When an invite is accepted, a BP notification is sent to the inviter to let them know about the update
3. When an invite is rejected, a BP notification is sent to the inviter to let them know about the update

When an invite is accepted or rejected, the first notification is also deleted.

Some other commits were added to re-use the existing invite action logic and so invite action redirection can be done when accepting or declining an invite from the new "Notifications > All" and "Notifications > Action Center" pages.

This is available for testing on cdev.

Actions #2

Updated by Raymond Hoh 8 months ago

  • Deployment actions updated (diff)
Actions #4

Updated by Raymond Hoh 7 months ago

Boone, I'm working through a WP-CLI script to backfill notifications for invites created by the cac-onboarding plugin.

Here's what I have so far:

<?php

global $wpdb;

$invites = $wpdb->get_results( "select id,invitee_id,inviter_id,date_created from wp_1_cac_invites where status = 'pending' and invitee_id != 0" );

$progress = \WP_CLI\Utils\make_progress_bar( 'Generating notifications', count( $invites ) );

foreach ( $invites as $invite ) {
    $progress->tick();

    bp_notifications_add_notification( array(
        'user_id'           => $invite->invitee_id,
        'item_id'           => $invite->id,
        'secondary_item_id' => $invite->inviter_id,
        'date_notified'     => $invite->date_created,
        'component_name'    => 'caco',
        'component_action'  => 'new_invitation',
    ) );
}

$progress->finish();

The script works but when I do a query to see how many pending invites there are on the production database, that number is quite large:

mysql> select count(*) from wp_1_cac_invites where status = 'pending' and invitee_id != 0;
+----------+
| count(*) |
+----------+
|     4280 |
+----------+
1 row in set (0.08 sec)                                                          

I'm wondering why we have a ton of pending invites when inviting an existing user.

Do you think we should limit creating notifications if the date_created for the invite is older than January 1, 2023 or a more, recent date? If using January 1st as the cut-off date, the notifications to create would be 656 instead.

Actions #5

Updated by Boone Gorges 7 months ago

I'm wondering why we have a ton of pending invites when inviting an existing user.

Yeah, that's strange. There could be a bug in cac-onboarding preventing them from being marked as accepted, but it's obviously not totally broken:

> select count(*) from wp_1_cac_invites where status != 'pending' and invitee_id != 0;
+----------+
| count(*) |
+----------+
|    26279 |
+----------+
1 row in set (0.04 sec)

Anyway, I agree that we don't need to backfill for all or even most of these. Jan 1 2023 seems OK to me if it does to you.

Actions #6

Updated by Raymond Hoh 7 months ago

Boone, I've attached the notifications-backfill.php script you should run with WP-CLI after pulling 2.2.x branch to production. In the script, I used January 1st, 2023 as the cut-off date.

I also modified the "Deployment Actions" field of this ticket to note a change to the invitations email template.

Actions #7

Updated by Boone Gorges 6 months ago

  • Status changed from New to Staged for Production Release
Actions #8

Updated by Boone Gorges 6 months ago

  • Status changed from Staged for Production Release to Resolved

I've completed the deployment actions.

Actions

Also available in: Atom PDF