Loading lib/Controller/AccountController.php +1 −15 Original line number Diff line number Diff line Loading @@ -137,21 +137,7 @@ class AccountController extends Controller { $this->userService->createNewDomainAlias($username, $userEmail); $this->userService->setTOS($username, true); $this->userService->setUserLanguage($username, $language); if ($newsletterEos || $newsletterProduct) { $list_ids = []; $newsletterListIds = $this->config->getSystemValue('newsletter_list_ids'); if ($newsletterEos) { $list_ids[] = $newsletterListIds['eos']; } if ($newsletterProduct) { $list_ids[] = $newsletterListIds['product']; } if (!empty($list_ids)) { $this->userService->newsletterSignup($userEmail, $list_ids, $language); } } $this->userService->setNewsletterSignup($newsletterEos, $newsletterProduct, $userEmail, $language); if($recoveryEmail !== '') { $this->userService->setUnverifiedRecoveryEmail($username, $recoveryEmail); Loading lib/Service/CurlService.php +3 −0 Original line number Diff line number Diff line Loading @@ -85,6 +85,9 @@ class CurlService { $jsonContent = in_array('Content-Type: application/json', $headers); if ($jsonContent) { $params = json_encode($params); if (json_last_error() !== JSON_ERROR_NONE) { throw new Exception('JSON encoding failed: ' . json_last_error_msg()); } } $options[CURLOPT_POSTFIELDS] = $params; break; Loading lib/Service/UserService.php +36 −6 Original line number Diff line number Diff line Loading @@ -448,17 +448,47 @@ class UserService { throw new Exception('Error adding username ' . $username . ' to common data store'); } } /** * Newsletter signup, * perform call to newsletter app api to signup the user * * @param $userEmail string * @param $listIds array * @param $userLanguage string * @param bool $newsletterEos * @param bool $newsletterProduct * @param string $userEmail * @param string $language * @return void */ public function setNewsletterSignup(bool $newsletterEos, bool $newsletterProduct, string $userEmail, string $language): void { if ($newsletterEos || $newsletterProduct) { $listIds = []; $newsletterListIds = $this->config->getSystemValue('newsletter_list_ids'); if ($newsletterEos) { $listIds[] = $newsletterListIds['eos']; } if ($newsletterProduct) { $listIds[] = $newsletterListIds['product']; } if (!empty($listIds)) { try { $this->signupForNewsletter($userEmail, $listIds, $language); } catch (Exception $e) { $this->logger->error('Signup for newsletter failed: ' . $e->getMessage()); } } } } /** * Signup for newsletter, * perform call to newsletter app api to signup the user * * @param string $userEmail * @param Array $listIds * @param string $userLanguage * @return mixed response of the external endpoint */ public function newsletterSignup(string $userEmail, array $listIds, string $userLanguage): void { public function signupForNewsletter(string $userEmail, array $listIds, string $userLanguage): void { $newsletterApiUrl = $this->config->getSystemValue('newsletter_base_url', ''); if (!isset($newsletterApiUrl) || empty($newsletterApiUrl)) { Loading @@ -481,7 +511,7 @@ class UserService { $this->curl->post($url, $params, $headers); if ($this->curl->getLastStatusCode() !== 200) { $this->logger->error('Error adding email ' . $userEmail . ' to newsletter app'); throw new Exception('Error adding email ' . $userEmail . ' to newsletter app'); } } } Loading
lib/Controller/AccountController.php +1 −15 Original line number Diff line number Diff line Loading @@ -137,21 +137,7 @@ class AccountController extends Controller { $this->userService->createNewDomainAlias($username, $userEmail); $this->userService->setTOS($username, true); $this->userService->setUserLanguage($username, $language); if ($newsletterEos || $newsletterProduct) { $list_ids = []; $newsletterListIds = $this->config->getSystemValue('newsletter_list_ids'); if ($newsletterEos) { $list_ids[] = $newsletterListIds['eos']; } if ($newsletterProduct) { $list_ids[] = $newsletterListIds['product']; } if (!empty($list_ids)) { $this->userService->newsletterSignup($userEmail, $list_ids, $language); } } $this->userService->setNewsletterSignup($newsletterEos, $newsletterProduct, $userEmail, $language); if($recoveryEmail !== '') { $this->userService->setUnverifiedRecoveryEmail($username, $recoveryEmail); Loading
lib/Service/CurlService.php +3 −0 Original line number Diff line number Diff line Loading @@ -85,6 +85,9 @@ class CurlService { $jsonContent = in_array('Content-Type: application/json', $headers); if ($jsonContent) { $params = json_encode($params); if (json_last_error() !== JSON_ERROR_NONE) { throw new Exception('JSON encoding failed: ' . json_last_error_msg()); } } $options[CURLOPT_POSTFIELDS] = $params; break; Loading
lib/Service/UserService.php +36 −6 Original line number Diff line number Diff line Loading @@ -448,17 +448,47 @@ class UserService { throw new Exception('Error adding username ' . $username . ' to common data store'); } } /** * Newsletter signup, * perform call to newsletter app api to signup the user * * @param $userEmail string * @param $listIds array * @param $userLanguage string * @param bool $newsletterEos * @param bool $newsletterProduct * @param string $userEmail * @param string $language * @return void */ public function setNewsletterSignup(bool $newsletterEos, bool $newsletterProduct, string $userEmail, string $language): void { if ($newsletterEos || $newsletterProduct) { $listIds = []; $newsletterListIds = $this->config->getSystemValue('newsletter_list_ids'); if ($newsletterEos) { $listIds[] = $newsletterListIds['eos']; } if ($newsletterProduct) { $listIds[] = $newsletterListIds['product']; } if (!empty($listIds)) { try { $this->signupForNewsletter($userEmail, $listIds, $language); } catch (Exception $e) { $this->logger->error('Signup for newsletter failed: ' . $e->getMessage()); } } } } /** * Signup for newsletter, * perform call to newsletter app api to signup the user * * @param string $userEmail * @param Array $listIds * @param string $userLanguage * @return mixed response of the external endpoint */ public function newsletterSignup(string $userEmail, array $listIds, string $userLanguage): void { public function signupForNewsletter(string $userEmail, array $listIds, string $userLanguage): void { $newsletterApiUrl = $this->config->getSystemValue('newsletter_base_url', ''); if (!isset($newsletterApiUrl) || empty($newsletterApiUrl)) { Loading @@ -481,7 +511,7 @@ class UserService { $this->curl->post($url, $params, $headers); if ($this->curl->getLastStatusCode() !== 200) { $this->logger->error('Error adding email ' . $userEmail . ' to newsletter app'); throw new Exception('Error adding email ' . $userEmail . ' to newsletter app'); } } }