Making WordPress.org

Changeset 11974


Ignore:
Timestamp:
07/18/2022 08:08:41 PM (4 years ago)
Author:
iandunn
Message:

GP Profiles: Send notifications for single reviews.

See https://github.com/WordPress/five-for-the-future/issues/196

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-profiles/profiles.php

    r11971 r11974  
    4949                $new_translation->translation_set_id
    5050        );
     51
     52        $activities            = array();
     53        $review_status         = gp_post( 'status' );
     54        $valid_review_statuses = array( 'current', 'rejected', 'fuzzy' );
     55        $is_reviewing          = $current_user_is_editor && get_current_user_id() !== $new_translation->user_id &&
     56                                 $review_status && in_array( $review_status, $valid_review_statuses, true );
    5157
    5258        /*
     
    5864         */
    5965        if ( 'waiting' === $new_translation->status && ! $current_user_is_editor ) {
    60                 $type = 'glotpress_translation_suggested';
     66                $activities[] = array(
     67                        'component' => 'glotpress',
     68                        'type'      => 'glotpress_translation_suggested',
     69                        'user_id'   => $new_translation->user_id,
     70                );
    6171
    6272        // Editor is approving a suggested string.
    6373        // Avoid sending a notification when a `current` post is re-saved, like when dismissing warnings.
    6474        } elseif ( 'current' === $new_translation->status && isset( $previous_translation->status ) && 'current' !== $previous_translation->status ) {
    65                 $type = 'glotpress_translation_approved';
    66 
    67         } else {
     75                $activities[] = array(
     76                        'component' => 'glotpress',
     77                        'type'      => 'glotpress_translation_approved',
     78                        'user_id'   => $new_translation->user_id,
     79                );
     80        }
     81
     82        if ( $is_reviewing ) {
     83                $activities[] = array(
     84                        'component' => 'glotpress',
     85                        'type'      => 'glotpress_translation_reviewed',
     86                        'user_id'   => get_current_user_id(),
     87                );
     88        }
     89
     90        if ( empty( $activities ) ) {
    6891                return;
    6992        }
     
    7295                'action'    => 'wporg_handle_activity',
    7396                'component' => 'glotpress',
    74                 'type'      => $type,
    75                 'user_id'   => $new_translation->user_id,
     97                'activities' => $activities,
    7698        );
    7799
Note: See TracChangeset for help on using the changeset viewer.