sieveService->getActiveScript($account->getUserId(), $account->getId()); return $this->filterParser->parseFilterState($script->getScript()); } /** * @throws CouldNotConnectException * @throws JsonException * @throws ClientException * @throws OutOfOfficeParserException * @throws ManageSieveException * @throws FilterParserException */ public function update(MailAccount $account, array $filters): void { $script = $this->sieveService->getActiveScript($account->getUserId(), $account->getId()); $oooResult = $this->outOfOfficeParser->parseOutOfOfficeState($script->getScript()); $filterResult = $this->filterParser->parseFilterState($oooResult->getUntouchedSieveScript()); $newScript = $this->filterBuilder->buildSieveScript( $filters, $filterResult->getUntouchedSieveScript() ); $oooState = $oooResult->getState(); if ($oooState instanceof OutOfOfficeState) { $newScript = $this->outOfOfficeParser->buildSieveScript( $oooState, $newScript, $this->allowedRecipientsService->get($account), ); } try { $this->sieveService->updateActiveScript($account->getUserId(), $account->getId(), $newScript); } catch (ManageSieveException $e) { $this->logger->error('Failed to save sieve script: ' . $e->getMessage(), [ 'exception' => $e, 'script' => $newScript, ]); throw $e; } } }