]> git.mxchange.org Git - friendica.git/commitdiff
UserSession class [4] - Refactor src/Model/ files
authorPhilipp <admin@philipp.info>
Thu, 20 Oct 2022 20:14:50 +0000 (22:14 +0200)
committerPhilipp <admin@philipp.info>
Thu, 20 Oct 2022 20:14:50 +0000 (22:14 +0200)
src/Model/Contact.php
src/Model/Contact/Group.php
src/Model/Event.php
src/Model/Group.php
src/Model/Item.php
src/Model/Mail.php
src/Model/Photo.php
src/Model/Post.php
src/Model/Profile.php

index 0f960f1609e454436eb52f4b1b538468097f924b..c5b7017a391abe31e1e265908fbf55e543841697 100644 (file)
@@ -29,7 +29,6 @@ use Friendica\Core\Hook;
 use Friendica\Core\Logger;
 use Friendica\Core\Protocol;
 use Friendica\Core\Renderer;
-use Friendica\Core\Session;
 use Friendica\Core\System;
 use Friendica\Core\Worker;
 use Friendica\Database\Database;
@@ -1129,7 +1128,7 @@ class Contact
                $photos_link = '';
 
                if ($uid == 0) {
-                       $uid = Session::getLocalUser();
+                       $uid = DI::userSession()->getLocalUserId();
                }
 
                if (empty($contact['uid']) || ($contact['uid'] != $uid)) {
@@ -1532,10 +1531,10 @@ class Contact
 
                if ($thread_mode) {
                        $condition = ["((`$contact_field` = ? AND `gravity` = ?) OR (`author-id` = ? AND `gravity` = ? AND `vid` = ? AND `thr-parent-id` = `parent-uri-id`)) AND " . $sql,
-                               $cid, Item::GRAVITY_PARENT, $cid, Item::GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE), Session::getLocalUser()];
+                               $cid, Item::GRAVITY_PARENT, $cid, Item::GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE), DI::userSession()->getLocalUserId()];
                } else {
                        $condition = ["`$contact_field` = ? AND `gravity` IN (?, ?) AND " . $sql,
-                               $cid, Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT, Session::getLocalUser()];
+                               $cid, Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT, DI::userSession()->getLocalUserId()];
                }
 
                if (!empty($parent)) {
@@ -1553,10 +1552,10 @@ class Contact
                }
 
                if (DI::mode()->isMobile()) {
-                       $itemsPerPage = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_mobile_network',
+                       $itemsPerPage = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_mobile_network',
                                DI::config()->get('system', 'itemspage_network_mobile'));
                } else {
-                       $itemsPerPage = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_network',
+                       $itemsPerPage = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_network',
                                DI::config()->get('system', 'itemspage_network'));
                }
 
@@ -1564,7 +1563,7 @@ class Contact
 
                $params = ['order' => ['received' => true], 'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
 
-               if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'infinite_scroll')) {
+               if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'infinite_scroll')) {
                        $tpl = Renderer::getMarkupTemplate('infinite_scroll_head.tpl');
                        $o = Renderer::replaceMacros($tpl, ['$reload_uri' => DI::args()->getQueryString()]);
                } else {
@@ -1573,27 +1572,27 @@ class Contact
 
                if ($thread_mode) {
                        $fields = ['uri-id', 'thr-parent-id', 'gravity', 'author-id', 'commented'];
-                       $items = Post::toArray(Post::selectForUser(Session::getLocalUser(), $fields, $condition, $params));
+                       $items = Post::toArray(Post::selectForUser(DI::userSession()->getLocalUserId(), $fields, $condition, $params));
 
                        if ($pager->getStart() == 0) {
-                               $cdata = self::getPublicAndUserContactID($cid, Session::getLocalUser());
+                               $cdata = self::getPublicAndUserContactID($cid, DI::userSession()->getLocalUserId());
                                if (!empty($cdata['public'])) {
                                        $pinned = Post\Collection::selectToArrayForContact($cdata['public'], Post\Collection::FEATURED, $fields);
                                        $items = array_merge($items, $pinned);
                                }
                        }
 
-                       $o .= DI::conversation()->create($items, 'contacts', $update, false, 'pinned_commented', Session::getLocalUser());
+                       $o .= DI::conversation()->create($items, 'contacts', $update, false, 'pinned_commented', DI::userSession()->getLocalUserId());
                } else {
                        $fields = array_merge(Item::DISPLAY_FIELDLIST, ['featured']);
-                       $items = Post::toArray(Post::selectForUser(Session::getLocalUser(), $fields, $condition, $params));
+                       $items = Post::toArray(Post::selectForUser(DI::userSession()->getLocalUserId(), $fields, $condition, $params));
 
                        if ($pager->getStart() == 0) {
-                               $cdata = self::getPublicAndUserContactID($cid, Session::getLocalUser());
+                               $cdata = self::getPublicAndUserContactID($cid, DI::userSession()->getLocalUserId());
                                if (!empty($cdata['public'])) {
                                        $condition = ["`uri-id` IN (SELECT `uri-id` FROM `collection-view` WHERE `cid` = ? AND `type` = ?)",
                                                $cdata['public'], Post\Collection::FEATURED];
-                                       $pinned = Post::toArray(Post::selectForUser(Session::getLocalUser(), $fields, $condition, $params));
+                                       $pinned = Post::toArray(Post::selectForUser(DI::userSession()->getLocalUserId(), $fields, $condition, $params));
                                        $items = array_merge($pinned, $items);
                                }
                        }
@@ -1602,7 +1601,7 @@ class Contact
                }
 
                if (!$update) {
-                       if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'infinite_scroll')) {
+                       if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'infinite_scroll')) {
                                $o .= HTML::scrollLoader();
                        } else {
                                $o .= $pager->renderMinimal(count($items));
@@ -3257,7 +3256,7 @@ class Contact
         */
        public static function magicLink(string $contact_url, string $url = ''): string
        {
-               if (!Session::isAuthenticated()) {
+               if (!DI::userSession()->isAuthenticated()) {
                        return $url ?: $contact_url; // Equivalent to: ($url != '') ? $url : $contact_url;
                }
 
@@ -3303,7 +3302,7 @@ class Contact
        {
                $destination = $url ?: $contact['url']; // Equivalent to ($url != '') ? $url : $contact['url'];
 
-               if (!Session::isAuthenticated()) {
+               if (!DI::userSession()->isAuthenticated()) {
                        return $destination;
                }
 
@@ -3312,7 +3311,7 @@ class Contact
                        return $url;
                }
 
-               if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'stay_local') && ($url == '')) {
+               if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'stay_local') && ($url == '')) {
                        return 'contact/' . $contact['id'] . '/conversations';
                }
 
index 838af8a278c1df72781a817c6ad089ca314e90f5..f18e344d03fda4e59402cf0225fc68672862f929 100644 (file)
@@ -21,7 +21,6 @@
 
 namespace Friendica\Model\Contact;
 
-use Friendica\Core\Session;
 use Friendica\Database\DBA;
 use Friendica\Model\Contact;
 
@@ -54,7 +53,7 @@ class Group
                                AND NOT `contact`.`pending`
                                ORDER BY `contact`.`name` ASC',
                                $gid,
-                               Session::getLocalUser()
+                               DI::userSession()->getLocalUserId()
                        );
 
                        if (DBA::isResult($stmt)) {
index 7437137d05633f9a9527955269795bcff3c2331f..a738428eaab7071520a3e3900ff57279c9fe4943 100644 (file)
@@ -26,7 +26,6 @@ use Friendica\Core\Hook;
 use Friendica\Core\Logger;
 use Friendica\Core\Protocol;
 use Friendica\Core\Renderer;
-use Friendica\Core\Session;
 use Friendica\Core\System;
 use Friendica\Database\DBA;
 use Friendica\DI;
@@ -411,7 +410,7 @@ class Event
        public static function getStrings(): array
        {
                // First day of the week (0 = Sunday).
-               $firstDay = DI::pConfig()->get(Session::getLocalUser(), 'system', 'first_day_of_week', 0);
+               $firstDay = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'first_day_of_week', 0);
 
                $i18n = [
                        "firstDay" => $firstDay,
@@ -609,7 +608,7 @@ class Event
                        $edit = null;
                        $copy = null;
                        $drop = null;
-                       if (Session::getLocalUser() && Session::getLocalUser() == $event['uid'] && $event['type'] == 'event') {
+                       if (DI::userSession()->getLocalUserId() && DI::userSession()->getLocalUserId() == $event['uid'] && $event['type'] == 'event') {
                                $edit = !$event['cid'] ? [DI::baseUrl() . '/events/event/' . $event['id'], DI::l10n()->t('Edit event')     , '', ''] : null;
                                $copy = !$event['cid'] ? [DI::baseUrl() . '/events/copy/' . $event['id'] , DI::l10n()->t('Duplicate event'), '', ''] : null;
                                $drop =                  [DI::baseUrl() . '/events/drop/' . $event['id'] , DI::l10n()->t('Delete event')   , '', ''];
@@ -776,7 +775,7 @@ class Event
                // Does the user who requests happen to be the owner of the events
                // requested? then show all of your events, otherwise only those that
                // don't have limitations set in allow_cid and allow_gid.
-               if (Session::getLocalUser() != $uid) {
+               if (DI::userSession()->getLocalUserId() != $uid) {
                        $conditions += ['allow_cid' => '', 'allow_gid' => ''];
                }
 
index 52aa4bca67ebab0c8539cc3eaf7c0baf1dfc422d..c374125b69acf33313b2bac0619c60d40c6b81bc 100644 (file)
@@ -25,7 +25,6 @@ use Friendica\BaseModule;
 use Friendica\Core\Logger;
 use Friendica\Core\Protocol;
 use Friendica\Core\Renderer;
-use Friendica\Core\Session;
 use Friendica\Database\Database;
 use Friendica\Database\DBA;
 use Friendica\DI;
@@ -188,8 +187,8 @@ class Group
                                        ) AS `count`
                                FROM `group`
                                WHERE `group`.`uid` = ?;",
-                       Session::getLocalUser(),
-                       Session::getLocalUser()
+                       DI::userSession()->getLocalUserId(),
+                       DI::userSession()->getLocalUserId()
                );
 
                return DBA::toArray($stmt);
@@ -527,7 +526,7 @@ class Group
         */
        public static function sidebarWidget(string $every = 'contact', string $each = 'group', string $editmode = 'standard', $group_id = '', int $cid = 0)
        {
-               if (!Session::getLocalUser()) {
+               if (!DI::userSession()->getLocalUserId()) {
                        return '';
                }
 
@@ -545,7 +544,7 @@ class Group
                        $member_of = self::getIdsByContactId($cid);
                }
 
-               $stmt = DBA::select('group', [], ['deleted' => false, 'uid' => Session::getLocalUser(), 'cid' => null], ['order' => ['name']]);
+               $stmt = DBA::select('group', [], ['deleted' => false, 'uid' => DI::userSession()->getLocalUserId(), 'cid' => null], ['order' => ['name']]);
                while ($group = DBA::fetch($stmt)) {
                        $selected = (($group_id == $group['id']) ? ' group-selected' : '');
 
index e53d64d5e1985ccf81eeb22d875dbc1852d3367d..af682395165f2524743b03828810dda39fffd801 100644 (file)
@@ -27,7 +27,6 @@ use Friendica\Core\Hook;
 use Friendica\Core\Logger;
 use Friendica\Core\Protocol;
 use Friendica\Core\Renderer;
-use Friendica\Core\Session;
 use Friendica\Core\System;
 use Friendica\Model\Tag;
 use Friendica\Core\Worker;
@@ -1066,7 +1065,7 @@ class Item
                        }
 
                        // We have to tell the hooks who we are - this really should be improved
-                       if (!Session::getLocalUser()) {
+                       if (!DI::userSession()->getLocalUserId()) {
                                $_SESSION['authenticated'] = true;
                                $_SESSION['uid'] = $uid;
                                $dummy_session = true;
@@ -2775,8 +2774,8 @@ class Item
         */
        public static function getPermissionsConditionArrayByUserId(int $owner_id): array
        {
-               $local_user = Session::getLocalUser();
-               $remote_user = Session::getRemoteContactID($owner_id);
+               $local_user = DI::userSession()->getLocalUserId();
+               $remote_user = DI::userSession()->getRemoteContactID($owner_id);
 
                // default permissions - anonymous user
                $condition = ["`private` != ?", self::PRIVATE];
@@ -2807,8 +2806,8 @@ class Item
         */
        public static function getPermissionsSQLByUserId(int $owner_id, string $table = ''): string
        {
-               $local_user = Session::getLocalUser();
-               $remote_user = Session::getRemoteContactID($owner_id);
+               $local_user = DI::userSession()->getLocalUserId();
+               $remote_user = DI::userSession()->getRemoteContactID($owner_id);
 
                if (!empty($table)) {
                        $table = DBA::quoteIdentifier($table) . '.';
@@ -3006,8 +3005,8 @@ class Item
 
                // Compile eventual content filter reasons
                $filter_reasons = [];
-               if (!$is_preview && Session::getPublicContact() != $item['author-id']) {
-                       if (!empty($item['content-warning']) && (!Session::getLocalUser() || !DI::pConfig()->get(Session::getLocalUser(), 'system', 'disable_cw', false))) {
+               if (!$is_preview && DI::userSession()->getPublicContactId() != $item['author-id']) {
+                       if (!empty($item['content-warning']) && (!DI::userSession()->getLocalUserId() || !DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'disable_cw', false))) {
                                $filter_reasons[] = DI::l10n()->t('Content warning: %s', $item['content-warning']);
                        }
 
@@ -3443,7 +3442,7 @@ class Item
                        $plink = $item['uri'];
                }
 
-               if (Session::getLocalUser()) {
+               if (DI::userSession()->getLocalUserId()) {
                        $ret = [
                                'href' => "display/" . $item['guid'],
                                'orig' => "display/" . $item['guid'],
index 84e9ef6a4a088dba69d6e674e7a3c21c5b01555b..6ccce24ba7d93d7a6ff4e428da273385216efb87 100644 (file)
@@ -23,7 +23,6 @@ namespace Friendica\Model;
 
 use Friendica\Core\ACL;
 use Friendica\Core\Logger;
-use Friendica\Core\Session;
 use Friendica\Core\System;
 use Friendica\Core\Worker;
 use Friendica\Database\DBA;
@@ -138,12 +137,12 @@ class Mail
                        $subject = DI::l10n()->t('[no subject]');
                }
 
-               $me = DBA::selectFirst('contact', [], ['uid' => Session::getLocalUser(), 'self' => true]);
+               $me = DBA::selectFirst('contact', [], ['uid' => DI::userSession()->getLocalUserId(), 'self' => true]);
                if (!DBA::isResult($me)) {
                        return -2;
                }
 
-               $contacts = ACL::getValidMessageRecipientsForUser(Session::getLocalUser());
+               $contacts = ACL::getValidMessageRecipientsForUser(DI::userSession()->getLocalUserId());
 
                $contactIndex = array_search($recipient, array_column($contacts, 'id'));
                if ($contactIndex === false) {
@@ -152,7 +151,7 @@ class Mail
 
                $contact = $contacts[$contactIndex];
 
-               Photo::setPermissionFromBody($body, Session::getLocalUser(), $me['id'],  '<' . $contact['id'] . '>', '', '', '');
+               Photo::setPermissionFromBody($body, DI::userSession()->getLocalUserId(), $me['id'],  '<' . $contact['id'] . '>', '', '', '');
 
                $guid = System::createUUID();
                $uri = Item::newURI($guid);
@@ -165,7 +164,7 @@ class Mail
                if (strlen($replyto)) {
                        $reply = true;
                        $condition = ["`uid` = ? AND (`uri` = ? OR `parent-uri` = ?)",
-                               Session::getLocalUser(), $replyto, $replyto];
+                               DI::userSession()->getLocalUserId(), $replyto, $replyto];
                        $mail = DBA::selectFirst('mail', ['convid'], $condition);
                        if (DBA::isResult($mail)) {
                                $convid = $mail['convid'];
@@ -178,7 +177,7 @@ class Mail
                        $conv_guid = System::createUUID();
                        $convuri = $contact['addr'] . ':' . $conv_guid;
 
-                       $fields = ['uid' => Session::getLocalUser(), 'guid' => $conv_guid, 'creator' => $me['addr'],
+                       $fields = ['uid' => DI::userSession()->getLocalUserId(), 'guid' => $conv_guid, 'creator' => $me['addr'],
                                'created' => DateTimeFormat::utcNow(), 'updated' => DateTimeFormat::utcNow(),
                                'subject' => $subject, 'recips' => $contact['addr'] . ';' . $me['addr']];
                        if (DBA::insert('conv', $fields)) {
@@ -197,7 +196,7 @@ class Mail
 
                $post_id = self::insert(
                        [
-                               'uid' => Session::getLocalUser(),
+                               'uid' => DI::userSession()->getLocalUserId(),
                                'guid' => $guid,
                                'convid' => $convid,
                                'from-name' => $me['name'],
@@ -233,7 +232,7 @@ class Mail
                                foreach ($images as $image) {
                                        $image_rid = Photo::ridFromURI($image);
                                        if (!empty($image_rid)) {
-                                               Photo::update(['allow-cid' => '<' . $recipient . '>'], ['resource-id' => $image_rid, 'album' => 'Wall Photos', 'uid' => Session::getLocalUser()]);
+                                               Photo::update(['allow-cid' => '<' . $recipient . '>'], ['resource-id' => $image_rid, 'album' => 'Wall Photos', 'uid' => DI::userSession()->getLocalUserId()]);
                                        }
                                }
                        }
index 035b32b1f03d74d277ef2f0ea13e40d8f3471a18..550d802e8124b81badc3f372279b79f4b9d2c3fc 100644 (file)
@@ -23,7 +23,6 @@ namespace Friendica\Model;
 
 use Friendica\Core\Cache\Enum\Duration;
 use Friendica\Core\Logger;
-use Friendica\Core\Session;
 use Friendica\Core\System;
 use Friendica\Database\DBA;
 use Friendica\DI;
@@ -639,10 +638,10 @@ class Photo
        {
                $sql_extra = Security::getPermissionsSQLByUserId($uid);
 
-               $avatar_type = (Session::getLocalUser() && (Session::getLocalUser() == $uid)) ? self::USER_AVATAR : self::DEFAULT;
-               $banner_type = (Session::getLocalUser() && (Session::getLocalUser() == $uid)) ? self::USER_BANNER : self::DEFAULT;
+               $avatar_type = (DI::userSession()->getLocalUserId() && (DI::userSession()->getLocalUserId() == $uid)) ? self::USER_AVATAR : self::DEFAULT;
+               $banner_type = (DI::userSession()->getLocalUserId() && (DI::userSession()->getLocalUserId() == $uid)) ? self::USER_BANNER : self::DEFAULT;
 
-               $key = 'photo_albums:' . $uid . ':' . Session::getLocalUser() . ':' . Session::getRemoteUser();
+               $key = 'photo_albums:' . $uid . ':' . DI::userSession()->getLocalUserId() . ':' . DI::userSession()->getRemoteUserId();
                $albums = DI::cache()->get($key);
 
                if (is_null($albums) || $update) {
@@ -681,7 +680,7 @@ class Photo
         */
        public static function clearAlbumCache(int $uid)
        {
-               $key = 'photo_albums:' . $uid . ':' . Session::getLocalUser() . ':' . Session::getRemoteUser();
+               $key = 'photo_albums:' . $uid . ':' . DI::userSession()->getLocalUserId() . ':' . DI::userSession()->getRemoteUserId();
                DI::cache()->set($key, null, Duration::DAY);
        }
 
index d3e1f2900cd59675637a6cdaaefe3df201f197fb..2c3f44ddee002b6dcf12e3283b715f2acd243abc 100644 (file)
@@ -23,7 +23,6 @@ namespace Friendica\Model;
 
 use BadMethodCallException;
 use Friendica\Core\Logger;
-use Friendica\Core\Session;
 use Friendica\Core\System;
 use Friendica\Database\Database;
 use Friendica\Database\DBA;
@@ -509,7 +508,7 @@ class Post
        {
                $affected = 0;
 
-               Logger::info('Start Update', ['fields' => $fields, 'condition' => $condition, 'uid' => Session::getLocalUser(),'callstack' => System::callstack(10)]);
+               Logger::info('Start Update', ['fields' => $fields, 'condition' => $condition, 'uid' => DI::userSession()->getLocalUserId(),'callstack' => System::callstack(10)]);
 
                // Don't allow changes to fields that are responsible for the relation between the records
                unset($fields['id']);
index 6574a53ac22ab4c74c57453e10956c2171374904..96932cdb0475b20b1242491c667a5c8b7168ed16 100644 (file)
@@ -30,7 +30,6 @@ use Friendica\Core\Logger;
 use Friendica\Core\Protocol;
 use Friendica\Core\Renderer;
 use Friendica\Core\Search;
-use Friendica\Core\Session;
 use Friendica\Core\System;
 use Friendica\Core\Worker;
 use Friendica\Database\DBA;
@@ -239,7 +238,7 @@ class Profile
 
                DI::page()['title'] = $profile['name'] . ' @ ' . DI::config()->get('config', 'sitename');
 
-               if (!Session::getLocalUser()) {
+               if (!DI::userSession()->getLocalUserId()) {
                        $a->setCurrentTheme($profile['theme']);
                        $a->setCurrentMobileTheme(DI::pConfig()->get($a->getProfileOwner(), 'system', 'mobile_theme') ?? '');
                }
@@ -255,7 +254,7 @@ class Profile
                        require_once $theme_info_file;
                }
 
-               $block = (DI::config()->get('system', 'block_public') && !Session::isAuthenticated());
+               $block = (DI::config()->get('system', 'block_public') && !DI::userSession()->isAuthenticated());
 
                /**
                 * @todo
@@ -295,8 +294,8 @@ class Profile
 
                $profile_contact = [];
 
-               if (Session::getLocalUser() && ($profile['uid'] ?? 0) != Session::getLocalUser()) {
-                       $profile_contact = Contact::getByURL($profile['nurl'], null, [], Session::getLocalUser());
+               if (DI::userSession()->getLocalUserId() && ($profile['uid'] ?? 0) != DI::userSession()->getLocalUserId()) {
+                       $profile_contact = Contact::getByURL($profile['nurl'], null, [], DI::userSession()->getLocalUserId());
                }
                if (!empty($profile['cid']) && self::getMyURL()) {
                        $profile_contact = Contact::selectFirst([], ['id' => $profile['cid']]);
@@ -379,7 +378,7 @@ class Profile
                $xmpp     = !empty($profile['xmpp'])     ? DI::l10n()->t('XMPP:')     : false;
                $matrix   = !empty($profile['matrix'])   ? DI::l10n()->t('Matrix:')   : false;
 
-               if ((!empty($profile['hidewall']) || $block) && !Session::isAuthenticated()) {
+               if ((!empty($profile['hidewall']) || $block) && !DI::userSession()->isAuthenticated()) {
                        $location = $homepage = $about = false;
                }
 
@@ -413,7 +412,7 @@ class Profile
                }
 
                if (!$block && $show_contacts) {
-                       $contact_block = ContactBlock::getHTML($profile, Session::getLocalUser());
+                       $contact_block = ContactBlock::getHTML($profile, DI::userSession()->getLocalUserId());
 
                        if (is_array($profile) && !$profile['hide-friends']) {
                                $contact_count = DBA::count('contact', [
@@ -493,7 +492,7 @@ class Profile
         */
        public static function getBirthdays(): string
        {
-               if (!Session::getLocalUser() || DI::mode()->isMobile() || DI::mode()->isMobile()) {
+               if (!DI::userSession()->getLocalUserId() || DI::mode()->isMobile() || DI::mode()->isMobile()) {
                        return '';
                }
 
@@ -506,7 +505,7 @@ class Profile
 
                $bd_short = DI::l10n()->t('F d');
 
-               $cacheKey = 'get_birthdays:' . Session::getLocalUser();
+               $cacheKey = 'get_birthdays:' . DI::userSession()->getLocalUserId();
                $events   = DI::cache()->get($cacheKey);
                if (is_null($events)) {
                        $result = DBA::p(
@@ -523,7 +522,7 @@ class Profile
                                ORDER BY `start`",
                                Contact::SHARING,
                                Contact::FRIEND,
-                               Session::getLocalUser(),
+                               DI::userSession()->getLocalUserId(),
                                DateTimeFormat::utc('now + 6 days'),
                                DateTimeFormat::utcNow()
                        );
@@ -595,7 +594,7 @@ class Profile
                $a = DI::app();
                $o = '';
 
-               if (!Session::getLocalUser() || DI::mode()->isMobile() || DI::mode()->isMobile()) {
+               if (!DI::userSession()->getLocalUserId() || DI::mode()->isMobile() || DI::mode()->isMobile()) {
                        return $o;
                }
 
@@ -610,7 +609,7 @@ class Profile
                $classtoday = '';
 
                $condition = ["`uid` = ? AND `type` != 'birthday' AND `start` < ? AND `start` >= ?",
-                       Session::getLocalUser(), DateTimeFormat::utc('now + 7 days'), DateTimeFormat::utc('now - 1 days')];
+                       DI::userSession()->getLocalUserId(), DateTimeFormat::utc('now + 7 days'), DateTimeFormat::utc('now - 1 days')];
                $s = DBA::select('event', [], $condition, ['order' => ['start']]);
 
                $r = [];
@@ -620,7 +619,7 @@ class Profile
                        $total = 0;
 
                        while ($rr = DBA::fetch($s)) {
-                               $condition = ['parent-uri' => $rr['uri'], 'uid' => $rr['uid'], 'author-id' => Session::getPublicContact(),
+                               $condition = ['parent-uri' => $rr['uri'], 'uid' => $rr['uid'], 'author-id' => DI::userSession()->getPublicContactId(),
                                        'vid' => [Verb::getID(Activity::ATTEND), Verb::getID(Activity::ATTENDMAYBE)],
                                        'visible' => true, 'deleted' => false];
                                if (!Post::exists($condition)) {
@@ -712,7 +711,7 @@ class Profile
                $my_url = self::getMyURL();
                $my_url = Network::isUrlValid($my_url);
 
-               if (empty($my_url) || Session::getLocalUser()) {
+               if (empty($my_url) || DI::userSession()->getLocalUserId()) {
                        return;
                }
 
@@ -730,7 +729,7 @@ class Profile
 
                $contact = DBA::selectFirst('contact',['id', 'url'], ['id' => $cid]);
 
-               if (DBA::isResult($contact) && Session::getRemoteUser() && Session::getRemoteUser() == $contact['id']) {
+               if (DBA::isResult($contact) && DI::userSession()->getRemoteUserId() && DI::userSession()->getRemoteUserId() == $contact['id']) {
                        Logger::info('The visitor ' . $my_url . ' is already authenticated');
                        return;
                }
@@ -797,7 +796,7 @@ class Profile
                $_SESSION['my_url'] = $visitor['url'];
                $_SESSION['remote_comment'] = $visitor['subscribe'];
 
-               Session::setVisitorsContacts();
+               DI::userSession()->setVisitorsContacts();
 
                $a->setContactId($visitor['id']);
 
@@ -916,7 +915,7 @@ class Profile
         */
        public static function getThemeUid(App $a): int
        {
-               return Session::getLocalUser() ?: $a->getProfileOwner();
+               return DI::userSession()->getLocalUserId() ?: $a->getProfileOwner();
        }
 
        /**