2222namespace OCA \FirstRunWizard \Notification ;
2323
2424
25+ use OCP \IConfig ;
2526use OCP \IURLGenerator ;
2627use OCP \IUserManager ;
2728use OCP \L10N \IFactory ;
2829use OCP \Notification \IManager as INotificationManager ;
2930use OCP \Notification \INotification ;
3031use OCP \Notification \INotifier ;
32+ use OCP \User \Backend \ISetPasswordBackend ;
3133
3234class Notifier implements INotifier {
3335
@@ -43,17 +45,19 @@ class Notifier implements INotifier {
4345 /** @var IURLGenerator */
4446 protected $ url ;
4547
46- /**
47- * @param IFactory $factory
48- * @param IUserManager $userManager
49- * @param INotificationManager $notificationManager
50- * @param IURLGenerator $urlGenerator
51- */
52- public function __construct (IFactory $ factory , IUserManager $ userManager , INotificationManager $ notificationManager , IURLGenerator $ urlGenerator ) {
48+ /** @var IConfig */
49+ protected $ config ;
50+
51+ public function __construct (IFactory $ factory ,
52+ IUserManager $ userManager ,
53+ INotificationManager $ notificationManager ,
54+ IURLGenerator $ urlGenerator ,
55+ IConfig $ config ) {
5356 $ this ->factory = $ factory ;
5457 $ this ->userManager = $ userManager ;
5558 $ this ->notificationManager = $ notificationManager ;
5659 $ this ->url = $ urlGenerator ;
60+ $ this ->config = $ config ;
5761 }
5862
5963 /**
@@ -123,13 +127,16 @@ public function prepare(INotification $notification, string $languageCode): INot
123127 * @param string $languageCode
124128 * @return string
125129 */
126- protected function getSubject (INotification $ notification , $ languageCode ) {
130+ protected function getSubject (INotification $ notification , string $ languageCode ): string {
127131 $ l = $ this ->factory ->get ('firstrunwizard ' , $ languageCode );
128132 $ user = $ this ->userManager ->get ($ notification ->getUser ());
129133
130134 $ email = $ user ->getEMailAddress ();
131135 if ($ email === null || $ email === '' ) {
132- return $ l ->t ('Add your profile information! For example your email is needed to reset your password. ' );
136+ if ($ this ->config ->getSystemValue ('lost_password_link ' , '' ) || !$ user ->getBackend () instanceof ISetPasswordBackend) {
137+ return $ l ->t ('Add your profile information! For example your email is needed to receive notifications. ' );
138+ }
139+ return $ l ->t ('Add your profile information! For example your email is needed to receive notifications and reset your password. ' );
133140 }
134141
135142 if ($ user ->canChangeDisplayName () && $ user ->getDisplayName () === $ user ->getUID ()) {
0 commit comments