aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Lib/Activity.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2021-01-20 20:17:50 +0000
committerMario <mario@mariovavti.com>2021-01-20 20:17:50 +0000
commitb242347fa1d41695edcdc378a2403b1621303da2 (patch)
tree6e800d8a5d5b53f4552f620b1f7435b03e38042e /Zotlabs/Lib/Activity.php
parent4e9d8e1a8342d7ae603a3d6caf714ce8b43b00ac (diff)
downloadvolse-hubzilla-b242347fa1d41695edcdc378a2403b1621303da2.tar.gz
volse-hubzilla-b242347fa1d41695edcdc378a2403b1621303da2.tar.bz2
volse-hubzilla-b242347fa1d41695edcdc378a2403b1621303da2.zip
onepoll via zot6 to /zotfeed which implements an outbox
Diffstat (limited to 'Zotlabs/Lib/Activity.php')
-rw-r--r--Zotlabs/Lib/Activity.php60
1 files changed, 51 insertions, 9 deletions
diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php
index 216dfab1a..0f9160bf7 100644
--- a/Zotlabs/Lib/Activity.php
+++ b/Zotlabs/Lib/Activity.php
@@ -2,6 +2,7 @@
namespace Zotlabs\Lib;
+use App;
use Zotlabs\Access\PermissionLimits;
use Zotlabs\Access\PermissionRoles;
use Zotlabs\Access\Permissions;
@@ -246,28 +247,69 @@ class Activity {
}
-
- static function encode_item_collection($items, $id, $type, $extra = null) {
+ static function paged_collection_init($total, $id, $type = 'OrderedCollection') {
$ret = [
'id' => z_root() . '/' . $id,
'type' => $type,
- 'totalItems' => count($items),
+ 'totalItems' => $total,
];
- if ($extra)
- $ret = array_merge($ret, $extra);
+
+ $numpages = $total / App::$pager['itemspage'];
+ $lastpage = (($numpages > intval($numpages)) ? intval($numpages) + 1 : $numpages);
+
+ $ret['first'] = z_root() . '/' . App::$query_string . '?page=1';
+ $ret['last'] = z_root() . '/' . App::$query_string . '?page=' . $lastpage;
+
+ return $ret;
+
+ }
+
+ static function encode_item_collection($items, $id, $type, $total = 0) {
+
+ if ($total > 100) {
+ $ret = [
+ 'id' => z_root() . '/' . $id,
+ 'type' => $type . 'Page',
+ ];
+
+ $numpages = $total / App::$pager['itemspage'];
+ $lastpage = (($numpages > intval($numpages)) ? intval($numpages) + 1 : $numpages);
+
+ $stripped = preg_replace('/([&|\?]page=[0-9]*)/', '', $id);
+ $stripped = rtrim($stripped, '/');
+
+ $ret['partOf'] = z_root() . '/' . $stripped;
+
+ if (App::$pager['page'] < $lastpage) {
+ $ret['next'] = z_root() . '/' . $stripped . '?page=' . (intval(App::$pager['page']) + 1);
+ }
+ if (App::$pager['page'] > 1) {
+ $ret['prev'] = z_root() . '/' . $stripped . '?page=' . (intval(App::$pager['page']) - 1);
+ }
+ }
+ else {
+ $ret = [
+ 'id' => z_root() . '/' . $id,
+ 'type' => $type,
+ 'totalItems' => $total,
+ ];
+ }
if ($items) {
$x = [];
foreach ($items as $i) {
- $t = self::encode_activity($i);
- if ($t)
+ $t = ((get_iconfig($i['id'], 'activitypub', 'rawmsg')) ? get_iconfig($i['id'], 'activitypub', 'rawmsg') : self::encode_activity($i));
+ if ($t) {
$x[] = $t;
+ }
}
- if ($type === 'OrderedCollection')
+ if ($type === 'OrderedCollection') {
$ret['orderedItems'] = $x;
- else
+ }
+ else {
$ret['items'] = $x;
+ }
}
return $ret;