Code Duplication    Length = 13-14 lines in 2 locations

settings/Controller/UsersController.php 1 location

@@ 450-462 (lines=13) @@
447
			/**
448
			 * Send new user mail only if a mail is set
449
			 */
450
			if ($email !== '') {
451
				$user->setEMailAddress($email);
452
				try {
453
					$emailTemplate = $this->newUserMailHelper->generateTemplate($user, $generatePasswordResetToken);
454
					$this->newUserMailHelper->sendMail($user, $emailTemplate);
455
				} catch (\Exception $e) {
456
					$this->log->logException($e, [
457
						'message' => "Can't send new user mail to $email",
458
						'level' => \OCP\Util::ERROR,
459
						'app' => 'settings',
460
					]);
461
				}
462
			}
463
			// fetch users groups
464
			$userGroups = $this->groupManager->getUserGroupNames($user);
465

apps/provisioning_api/lib/Controller/UsersController.php 1 location

@@ 260-273 (lines=14) @@
257
			}
258
259
			// Send new user mail only if a mail is set
260
			if ($email !== '') {
261
				$newUser->setEMailAddress($email);
262
				try {
263
					$emailTemplate = $this->newUserMailHelper->generateTemplate($newUser, $generatePasswordResetToken);
264
					$this->newUserMailHelper->sendMail($newUser, $emailTemplate);
265
				} catch (\Exception $e) {
266
					$this->logger->logException($e, [
267
						'message' => "Can't send new user mail to $email",
268
						'level' => \OCP\Util::ERROR,
269
						'app' => 'ocs_api',
270
					]);
271
					throw new OCSException('Unable to send the invitation mail', 109);
272
				}
273
			}
274
275
			return new DataResponse();
276