@@ -107,9 +107,7 @@ public function prepare(INotification $notification, string $languageCode): INot
107107 );
108108
109109 $ initiator = $ params [0 ];
110- $ initiatorDisplay = isset ($ params [3 ]) ? $ params [3 ] : null ;
111110 $ owner = $ params [1 ];
112- $ ownerDisplay = isset ($ params [4 ]) ? $ params [4 ] : null ;
113111
114112 $ notification ->setRichSubject (
115113 $ l ->t ('You received {share} as a remote share from {user} (on behalf of {behalf}) ' ),
@@ -119,8 +117,8 @@ public function prepare(INotification $notification, string $languageCode): INot
119117 'id ' => $ notification ->getObjectId (),
120118 'name ' => $ params [2 ],
121119 ],
122- 'user ' => $ this ->createRemoteUser ($ initiator, $ initiatorDisplay ),
123- 'behalf ' => $ this ->createRemoteUser ($ owner, $ ownerDisplay ),
120+ 'user ' => $ this ->createRemoteUser ($ initiator ),
121+ 'behalf ' => $ this ->createRemoteUser ($ owner ),
124122 ]
125123 );
126124 } else {
@@ -129,7 +127,6 @@ public function prepare(INotification $notification, string $languageCode): INot
129127 );
130128
131129 $ owner = $ params [0 ];
132- $ ownerDisplay = isset ($ params [3 ]) ? $ params [3 ] : null ;
133130
134131 $ notification ->setRichSubject (
135132 $ l ->t ('You received {share} as a remote share from {user} ' ),
@@ -139,7 +136,7 @@ public function prepare(INotification $notification, string $languageCode): INot
139136 'id ' => $ notification ->getObjectId (),
140137 'name ' => $ params [2 ],
141138 ],
142- 'user ' => $ this ->createRemoteUser ($ owner, $ ownerDisplay ),
139+ 'user ' => $ this ->createRemoteUser ($ owner ),
143140 ]
144141 );
145142 }
@@ -203,7 +200,7 @@ protected function createRemoteUser($cloudId, $displayName = null) {
203200 * @param ICloudId $cloudId
204201 * @return string
205202 */
206- protected function getDisplayName (ICloudId $ cloudId ) {
203+ protected function getDisplayName (ICloudId $ cloudId ): string {
207204 $ server = $ cloudId ->getRemote ();
208205 $ user = $ cloudId ->getUser ();
209206 if (strpos ($ server , 'http:// ' ) === 0 ) {
@@ -213,17 +210,24 @@ protected function getDisplayName(ICloudId $cloudId) {
213210 }
214211
215212 try {
213+ // contains protocol in the ID
216214 return $ this ->getDisplayNameFromContact ($ cloudId ->getId ());
217215 } catch (\OutOfBoundsException $ e ) {
218216 }
219217
220218 try {
221- $ this ->getDisplayNameFromContact ($ user . '@http:// ' . $ server );
219+ // does not include protocol, as stored in addressbooks
220+ return $ this ->getDisplayNameFromContact ($ cloudId ->getDisplayId ());
222221 } catch (\OutOfBoundsException $ e ) {
223222 }
224223
225224 try {
226- $ this ->getDisplayNameFromContact ($ user . '@https:// ' . $ server );
225+ return $ this ->getDisplayNameFromContact ($ user . '@http:// ' . $ server );
226+ } catch (\OutOfBoundsException $ e ) {
227+ }
228+
229+ try {
230+ return $ this ->getDisplayNameFromContact ($ user . '@https:// ' . $ server );
227231 } catch (\OutOfBoundsException $ e ) {
228232 }
229233
0 commit comments