In hook_user_presave how to check if account is being activated and account is new? Currently in Drupal 7 I have two conditions in hook_user_presave,
1. Is account is being activated
2. Is account new



function hook_user_presave(&$edit, $account, $category) {
    if (isset($account->is_new) && !empty($account->is_new)) {
        //If account is new then execute my code here
    }

    if ((isset($account->uid)) && (isset($account->status)) && ($account->status == 0) && ($edit['status'] == 1)) {
        //If account is being activated for the first time then execute my code here
    }
}



I want to convert this code to Drupal 8, What should be the conditions?



function hook_user_presave($account) {

    //Condition 1

    //Condition 2
}



Is there any other way to achieve this?
Any help would be appreciated. Thanks.
To check if the user is new:

$account-&gt;isNew()


To check if the user is active:

$account-&gt;isActive()


See User API isNew or User API isActive for more information.