streams/Code/Module/Event.php

62 lines
1.5 KiB
PHP
Raw Normal View History

2018-10-17 03:25:37 +00:00
<?php
2021-12-03 03:01:39 +00:00
2022-02-16 04:08:28 +00:00
namespace Code\Module;
2018-10-17 03:25:37 +00:00
2022-02-16 04:08:28 +00:00
use Code\Web\Controller;
use Code\Lib\ActivityStreams;
use Code\Lib\Activity;
use Code\Lib\LDSignatures;
use Code\Lib\Channel;
use Code\Web\HTTPSig;
2018-10-17 03:25:37 +00:00
2021-12-02 23:02:31 +00:00
class Event extends Controller
{
2018-10-17 03:25:37 +00:00
2021-12-02 23:02:31 +00:00
public function init()
{
2018-10-17 03:25:37 +00:00
2021-12-02 23:02:31 +00:00
if (ActivityStreams::is_as_request()) {
$item_id = argv(1);
2018-10-17 03:25:37 +00:00
2021-12-03 03:01:39 +00:00
if (!$item_id) {
2021-12-02 23:02:31 +00:00
return;
2021-12-03 03:01:39 +00:00
}
2018-10-17 03:25:37 +00:00
2021-12-02 23:02:31 +00:00
$item_normal = " and item.item_hidden = 0 and item.item_type = 0 and item.item_unpublished = 0
2018-10-17 03:25:37 +00:00
and item.item_delayed = 0 and item.item_blocked = 0 ";
2021-12-02 23:02:31 +00:00
$sql_extra = item_permissions_sql(0);
2018-10-17 03:25:37 +00:00
2021-12-03 03:01:39 +00:00
$r = q(
"select * from item where mid like '%s' $item_normal $sql_extra limit 1",
2021-12-02 23:02:31 +00:00
dbesc(z_root() . '/activity/' . $item_id . '%')
);
2018-10-17 03:42:44 +00:00
2021-12-02 23:02:31 +00:00
if (!$r) {
2021-12-03 03:01:39 +00:00
$r = q(
"select * from item where mid like '%s' $item_normal limit 1",
2021-12-02 23:02:31 +00:00
dbesc(z_root() . '/activity/' . $item_id . '%')
);
2018-10-17 03:25:37 +00:00
2021-12-02 23:02:31 +00:00
if ($r) {
http_status_exit(403, 'Forbidden');
}
http_status_exit(404, 'Not found');
}
2018-10-17 03:25:37 +00:00
2021-12-02 23:02:31 +00:00
xchan_query($r, true);
$items = fetch_post_tags($r);
2018-10-17 03:25:37 +00:00
2022-01-25 01:26:12 +00:00
$channel = Channel::from_id($items[0]['uid']);
2018-10-17 03:25:37 +00:00
2021-12-02 23:02:31 +00:00
if (!is_array($items[0]['obj'])) {
$obj = json_decode($items[0]['obj'], true);
} else {
$obj = $items[0]['obj'];
}
2018-10-17 03:25:37 +00:00
2021-12-02 23:02:31 +00:00
as_return_and_die($obj, $channel);
}
}
2021-12-03 03:01:39 +00:00
}