Skip to content

Commit

Permalink
Abstract transparency_report & through_wpcs_pbc logic for wcor_send_b…
Browse files Browse the repository at this point in the history
…efore.
  • Loading branch information
renintw committed May 28, 2024
1 parent db6adc4 commit 7c70fdb
Showing 1 changed file with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,15 @@ protected function timed_email_is_ready_to_send( $wordcamp, $email, $sent_email_
return $ready;
}

/**
* Do not send emails if it's for transparency report and the camp is running money through WPCS PBC.
*/
$transparency_report = get_post_meta( $email->ID, 'wcor_transparency_report', true );
$through_wpcs_pbc = get_post_meta( $wordcamp->ID, 'Running money through WPCS PBC', true );
if ( $transparency_report && $through_wpcs_pbc ) {
return $ready;
}

$send_when = get_post_meta( $email->ID, 'wcor_send_when', true );
$start_date = get_post_meta( $wordcamp->ID, 'Start Date (YYYY-mm-dd)', true );
$end_date = get_post_meta( $wordcamp->ID, 'End Date (YYYY-mm-dd)', true );
Expand Down Expand Up @@ -622,19 +631,12 @@ protected function timed_email_is_ready_to_send( $wordcamp, $email, $sent_email_
return $ready;
}

$transparency_report = get_post_meta( $email->ID, 'wcor_transparency_report', true );
$days_after = absint( get_post_meta( $email->ID, 'wcor_send_days_after', true ) );
if ( $transparency_report ) {
$through_wpcs_pbc = get_post_meta( $wordcamp->ID, 'Running money through WPCS PBC', true );

/**
* Do not send emails with "send X days after the camp ends" trigger if the camp is running money through WPCS PBC.
*/
if ( $through_wpcs_pbc ) {
return $ready;
}
$transparency_report = get_post_meta( $email->ID, 'wcor_transparency_report', true );

if ( $transparency_report ) {
$report_received = get_post_meta( $wordcamp->ID, 'Transparency Report Received', true );

if ( $end_date && $days_after && ! $report_received ) {
$execution_timestamp = $end_date + ( $days_after * DAY_IN_SECONDS );

Expand Down

0 comments on commit 7c70fdb

Please sign in to comment.