3232use OCA \Circles \Tools \Traits \TStringTools ;
3333use OCP \EventDispatcher \Event ;
3434use OCP \EventDispatcher \IEventListener ;
35+ use OCP \IUserManager ;
3536
3637/** @template-implements IEventListener<FileShareCreatedEvent|Event> */
3738class ShareCreatedSendMail implements IEventListener {
@@ -56,6 +57,8 @@ class ShareCreatedSendMail implements IEventListener {
5657
5758 /** @var ContactService */
5859 private $ contactService ;
60+ /** @var IUserManager */
61+ private $ userManager ;
5962
6063 public function __construct (
6164 ShareWrapperService $ shareWrapperService ,
@@ -64,13 +67,15 @@ public function __construct(
6467 SendMailService $ sendMailService ,
6568 ContactService $ contactService ,
6669 ConfigService $ configService ,
70+ IUserManager $ userManager ,
6771 ) {
6872 $ this ->shareWrapperService = $ shareWrapperService ;
6973 $ this ->shareTokenService = $ shareTokenService ;
7074 $ this ->remoteStreamService = $ remoteStreamService ;
7175 $ this ->sendMailService = $ sendMailService ;
7276 $ this ->contactService = $ contactService ;
7377 $ this ->configService = $ configService ;
78+ $ this ->userManager = $ userManager ;
7479
7580 $ this ->setup ('app ' , Application::APP_ID );
7681 }
@@ -127,6 +132,8 @@ public function handle(Event $event): void {
127132 if (!is_null ($ share )) {
128133 if ($ share ->hasInitiator ()) {
129134 $ author = $ share ->getInitiator ()->getDisplayName ();
135+ } elseif ($ user = $ this ->userManager ->get ($ share ->getSharedBy ())) {
136+ $ author = $ user ->getDisplayName ();
130137 } else {
131138 $ author = 'someone ' ;
132139 }
0 commit comments