]> git.mxchange.org Git - friendica.git/commitdiff
Now using only a single array
authorMichael <heluecht@pirati.ca>
Sun, 5 Jan 2020 13:13:36 +0000 (13:13 +0000)
committerMichael <heluecht@pirati.ca>
Sun, 5 Jan 2020 13:13:36 +0000 (13:13 +0000)
src/Model/UserItem.php

index fb89a9bc503e04f08d94a126bbaf314db434d58d..03e7f51f644fac3b23d4fdc304ed00327280b3b4 100644 (file)
@@ -125,38 +125,37 @@ class UserItem
                $notification_data = ['uid' => $uid, 'profiles' => []];
                Hook::callAll('check_item_notification', $notification_data);
 
-               $raw_profiles = $notification_data['profiles'];
+               $profiles = $notification_data['profiles'];
 
                $user = DBA::selectFirst('user', ['nickname'], ['uid' => $uid]);
                if (!DBA::isResult($user)) {
                        return [];
                }
 
-               $owner = DBA::selectFirst('contact', ['url'], ['self' => true, 'uid' => $uid]);
+               $owner = DBA::selectFirst('contact', ['url', 'alias'], ['self' => true, 'uid' => $uid]);
                if (!DBA::isResult($owner)) {
                        return [];
                }
 
                // This is our regular URL format
-               $raw_profiles[] = $owner['url'];
+               $profiles[] = $owner['url'];
 
-               // Notifications from Diaspora are often with an URL in the Diaspora format
-               $raw_profiles[] = DI::baseUrl() . '/u/' . $user['nickname'];
+               // Now the alias
+               $profiles[] = $owner['alias'];
 
-               $profiles = [];
+               // Notifications from Diaspora are often with an URL in the Diaspora format
+               $profiles[] = DI::baseUrl() . '/u/' . $user['nickname'];
 
                // Validate and add profile links
-               foreach ($raw_profiles AS $profile) {
+               foreach ($profiles AS $key => $profile) {
                        // Check for invalid profile urls. 13 should be the shortest possible profile length:
                        // http://a.bc/d
                        // Additionally check for invalid urls that would return the normalised value "http:"
                        if ((strlen($profile) < 13) || (Strings::normaliseLink($profile) == 'http:')) {
+                               unset($profiles[$key]);
                                continue;
                        }
 
-                       // Add the profile
-                       $profiles[] = $profile;
-
                        // Add the normalized form
                        $profile = Strings::normaliseLink($profile);
                        $profiles[] = $profile;