]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/ActivityPub/Transmitter.php
Move ProfileFieldRepository::migrateFromLegacyProfile() & delete old repository
[friendica.git] / src / Protocol / ActivityPub / Transmitter.php
index d84baa55588e55bdaff1a26a3803eefca112c179..e741789dad217e22913df0bf6dbee8ad093b2f18 100644 (file)
@@ -166,21 +166,17 @@ class Transmitter
                        'pending' => false,
                        'blocked' => false,
                ];
-               $condition = DBA::buildCondition($parameters);
 
-               $sql = "SELECT COUNT(*) as `count`
-                       FROM `contact`
-                       JOIN `apcontact` ON `apcontact`.`url` = `contact`.`url`
-                       " . $condition;
+               $condition = DBA::mergeConditions($parameters, ["`url` IN (SELECT `url` FROM `apcontact`)"]);
 
-               $contacts = DBA::fetchFirst($sql, ...$parameters);
+               $total = DBA::count('contact', $condition);
 
                $modulePath = '/' . $module . '/';
 
                $data = ['@context' => ActivityPub::CONTEXT];
                $data['id'] = DI::baseUrl() . $modulePath . $owner['nickname'];
                $data['type'] = 'OrderedCollection';
-               $data['totalItems'] = $contacts['count'];
+               $data['totalItems'] = $total;
 
                // When we hide our friends we will only show the pure number but don't allow more.
                $profile = Profile::getByUID($owner['uid']);
@@ -194,16 +190,7 @@ class Transmitter
                        $data['type'] = 'OrderedCollectionPage';
                        $list = [];
 
-                       $sql = "SELECT `contact`.`url`
-                               FROM `contact`
-                               JOIN `apcontact` ON `apcontact`.`url` = `contact`.`url`
-                               " . $condition . "
-                               LIMIT ?, ?";
-
-                       $parameters[] = ($page - 1) * 100;
-                       $parameters[] = 100;
-
-                       $contacts = DBA::p($sql, ...$parameters);
+                       $contacts = DBA::select('contact', ['url'], $condition, ['limit' => [($page - 1) * 100, 100]]);
                        while ($contact = DBA::fetch($contacts)) {
                                $list[] = $contact['url'];
                        }
@@ -242,7 +229,7 @@ class Transmitter
                                $permissionSets = DI::permissionSet()->selectByContactId($requester_id, $owner['uid']);
                                if (!empty($permissionSets)) {
                                        $condition = ['psid' => array_merge($permissionSets->column('id'),
-                                                       [DI::permissionSet()->getIdFromACL($owner['uid'], '', '', '', '')])];
+                                                       [DI::permissionSet()->selectEmptyForUser($owner['uid'])])];
                                }
                        }
                }
@@ -370,7 +357,7 @@ class Transmitter
                        'owner' => $owner['url'],
                        'publicKeyPem' => $owner['pubkey']];
                $data['endpoints'] = ['sharedInbox' => DI::baseUrl() . '/inbox'];
-               $data['icon'] = ['type' => 'Image', 'url' => User::getAvatarUrlForId($uid)];
+               $data['icon'] = ['type' => 'Image', 'url' => User::getAvatarUrl($owner)];
 
                $resourceid = Photo::ridFromURI($owner['photo']);
                if (!empty($resourceid)) {
@@ -1476,10 +1463,10 @@ class Transmitter
                $event = [];
                $event['name'] = $item['event-summary'];
                $event['content'] = BBCode::convertForUriId($item['uri-id'], $item['event-desc'], BBCode::ACTIVITYPUB);
-               $event['startTime'] = DateTimeFormat::utc($item['event-start'] . '+00:00', DateTimeFormat::ATOM);
+               $event['startTime'] = DateTimeFormat::utc($item['event-start'], 'c');
 
                if (!$item['event-nofinish']) {
-                       $event['endTime'] = DateTimeFormat::utc($item['event-finish'] . '+00:00', DateTimeFormat::ATOM);
+                       $event['endTime'] = DateTimeFormat::utc($item['event-finish'], 'c');
                }
 
                if (!empty($item['event-location'])) {
@@ -1487,7 +1474,8 @@ class Transmitter
                        $event['location'] = self::createLocation($item);
                }
 
-               $event['dfrn:adjust'] = (bool)$item['event-adjust'];
+               // 2021.12: Backward compatibility value, all the events now "adjust" to the viewer timezone
+               $event['dfrn:adjust'] = true;
 
                return $event;
        }