Skip to content
This repository has been archived by the owner on Dec 27, 2023. It is now read-only.

Commit

Permalink
fix(Felamimail/Json): deactive vacation script if end date expired
Browse files Browse the repository at this point in the history
  • Loading branch information
ccheng-dev committed Jan 10, 2023
1 parent 1540cbc commit 9c8902a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
17 changes: 17 additions & 0 deletions tests/tine20/Felamimail/Frontend/JsonTest.php
Expand Up @@ -200,6 +200,23 @@ public function testSearchAccounts()
}
}

/**
* test search accounts and deactive sieve script if end date expired
*/
public function testSearchAccountsCheckSieveEndDate()
{
$vacationData = self::getVacationData($this->_account);
$vacationData['start_date'] = '2012-04-18';
$vacationData['end_date'] = '2012-04-20';
$this->_sieveTestHelper($vacationData);

// check if script was deactivated
$results = $this->_json->searchAccounts(array());
$vacation = Felamimail_Controller_Sieve::getInstance()->getVacation($results['results'][0]['id']);
$this->assertFalse((bool)$results['results'][0]['sieve_vacation_active']);
$this->assertFalse((bool)$vacation['enabled']);
}

/**
* get system account
*
Expand Down
10 changes: 8 additions & 2 deletions tine20/Felamimail/Frontend/Json.php
Expand Up @@ -641,8 +641,14 @@ protected function _initAccounts(array $accounts): array
Felamimail_Controller_Account::getInstance()->autoCreateMoveNotifications($account);
}

// TODO auto-deactivate sieve vacation notifications if over due date

// auto-deactivate sieve vacation notifications if over due date
$vacation = Felamimail_Controller_Sieve::getInstance()->getVacation($account['id']);
if ($vacation['end_date'] instanceof Tinebase_DateTime && Tinebase_DateTime::now()->compare($vacation['end_date']) === 1) {
$vacation->enabled = false;
Felamimail_Controller_Sieve::getInstance()->setSieveScript($account['id'], $vacation, null);
$account = Felamimail_Controller_Account::getInstance()->get($account['id']);
}

$accounts[$idx] = $this->_recordToJson($account);
}
}
Expand Down

0 comments on commit 9c8902a

Please sign in to comment.