mirror of
https://github.com/WordPress/five-for-the-future.git
synced 2025-07-04 10:05:43 +03:00
Contributors: Modularize activity detection for reuse.
This commit is contained in:
parent
44e9daccd9
commit
ccad917c00
2 changed files with 49 additions and 2 deletions
|
@ -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.
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue