Contributors: Modularize activity detection for reuse.

This commit is contained in:
Ian Dunn 2022-08-17 10:49:30 -07:00
parent 44e9daccd9
commit ccad917c00
2 changed files with 49 additions and 2 deletions

View file

@ -760,7 +760,7 @@ function prune_unnotifiable_users( array $contributors ) : array {
$inactivity_threshold = strtotime( INACTIVITY_THRESHOLD_MONTHS . ' months ago' );
foreach ( $contributors as $index => $contributor ) {
if ( $contributor['last_logged_in'] > $inactivity_threshold ) {
if ( is_active( $contributor['last_logged_in'] ) ) {
unset( $contributors[ $index ] );
}
@ -772,6 +772,18 @@ function prune_unnotifiable_users( array $contributors ) : array {
return $contributors;
}
/**
* Determine if a contributor is active or not.
*
* Currently this only tracks the last login, but in the future it will be expanded to be more granular.
* @link https://github.com/WordPress/five-for-the-future/issues/210
*/
function is_active( int $last_login ) : bool {
$inactivity_threshold = strtotime( INACTIVITY_THRESHOLD_MONTHS . ' months ago' );
return $last_login > $inactivity_threshold;
}
/**
* Notify an inactive contributor.
*/