Move ActivityPub endpoints to an AP class
This commit is contained in:
parent
6331e1e71c
commit
f62f82df75
|
@ -19,10 +19,9 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Friendica\Module;
|
namespace Friendica\Module\ActivityPub;
|
||||||
|
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
use Friendica\DI;
|
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
use Friendica\Protocol\ActivityPub;
|
use Friendica\Protocol\ActivityPub;
|
||||||
|
@ -34,15 +33,12 @@ class Followers extends BaseModule
|
||||||
{
|
{
|
||||||
public static function rawContent(array $parameters = [])
|
public static function rawContent(array $parameters = [])
|
||||||
{
|
{
|
||||||
$a = DI::app();
|
if (empty($parameters['nickname'])) {
|
||||||
|
|
||||||
// @TODO: Replace with parameter from router
|
|
||||||
if (empty($a->argv[1])) {
|
|
||||||
throw new \Friendica\Network\HTTPException\NotFoundException();
|
throw new \Friendica\Network\HTTPException\NotFoundException();
|
||||||
}
|
}
|
||||||
|
|
||||||
// @TODO: Replace with parameter from router
|
// @TODO: Replace with parameter from router
|
||||||
$owner = User::getOwnerDataByNick($a->argv[1]);
|
$owner = User::getOwnerDataByNick($parameters['nickname']);
|
||||||
if (empty($owner)) {
|
if (empty($owner)) {
|
||||||
throw new \Friendica\Network\HTTPException\NotFoundException();
|
throw new \Friendica\Network\HTTPException\NotFoundException();
|
||||||
}
|
}
|
|
@ -19,10 +19,9 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Friendica\Module;
|
namespace Friendica\Module\ActivityPub;
|
||||||
|
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
use Friendica\DI;
|
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
use Friendica\Protocol\ActivityPub;
|
use Friendica\Protocol\ActivityPub;
|
||||||
|
@ -34,15 +33,11 @@ class Following extends BaseModule
|
||||||
{
|
{
|
||||||
public static function rawContent(array $parameters = [])
|
public static function rawContent(array $parameters = [])
|
||||||
{
|
{
|
||||||
$a = DI::app();
|
if (empty($parameters['nickname'])) {
|
||||||
|
|
||||||
// @TODO: Replace with parameter from router
|
|
||||||
if (empty($a->argv[1])) {
|
|
||||||
throw new \Friendica\Network\HTTPException\NotFoundException();
|
throw new \Friendica\Network\HTTPException\NotFoundException();
|
||||||
}
|
}
|
||||||
|
|
||||||
// @TODO: Replace with parameter from router
|
$owner = User::getOwnerDataByNick($parameters['nickname']);
|
||||||
$owner = User::getOwnerDataByNick($a->argv[1]);
|
|
||||||
if (empty($owner)) {
|
if (empty($owner)) {
|
||||||
throw new \Friendica\Network\HTTPException\NotFoundException();
|
throw new \Friendica\Network\HTTPException\NotFoundException();
|
||||||
}
|
}
|
|
@ -19,7 +19,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Friendica\Module;
|
namespace Friendica\Module\ActivityPub;
|
||||||
|
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
|
@ -36,8 +36,6 @@ class Inbox extends BaseModule
|
||||||
{
|
{
|
||||||
public static function rawContent(array $parameters = [])
|
public static function rawContent(array $parameters = [])
|
||||||
{
|
{
|
||||||
$a = DI::app();
|
|
||||||
|
|
||||||
$postdata = Network::postdata();
|
$postdata = Network::postdata();
|
||||||
|
|
||||||
if (empty($postdata)) {
|
if (empty($postdata)) {
|
||||||
|
@ -51,13 +49,12 @@ class Inbox extends BaseModule
|
||||||
$filename = 'failed-activitypub';
|
$filename = 'failed-activitypub';
|
||||||
}
|
}
|
||||||
$tempfile = tempnam(get_temppath(), $filename);
|
$tempfile = tempnam(get_temppath(), $filename);
|
||||||
file_put_contents($tempfile, json_encode(['argv' => $a->argv, 'header' => $_SERVER, 'body' => $postdata], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
|
file_put_contents($tempfile, json_encode(['parameters' => $parameters, 'header' => $_SERVER, 'body' => $postdata], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
|
||||||
Logger::log('Incoming message stored under ' . $tempfile);
|
Logger::notice('Incoming message stored', ['file' => $tempfile]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @TODO: Replace with parameter from router
|
if (!empty($parameters['nickname'])) {
|
||||||
if (!empty($a->argv[1])) {
|
$user = DBA::selectFirst('user', ['uid'], ['nickname' => $parameters['nickname']]);
|
||||||
$user = DBA::selectFirst('user', ['uid'], ['nickname' => $a->argv[1]]);
|
|
||||||
if (!DBA::isResult($user)) {
|
if (!DBA::isResult($user)) {
|
||||||
throw new \Friendica\Network\HTTPException\NotFoundException();
|
throw new \Friendica\Network\HTTPException\NotFoundException();
|
||||||
}
|
}
|
|
@ -19,7 +19,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Friendica\Module;
|
namespace Friendica\Module\ActivityPub;
|
||||||
|
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
|
@ -19,10 +19,9 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Friendica\Module;
|
namespace Friendica\Module\ActivityPub;
|
||||||
|
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
use Friendica\DI;
|
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
use Friendica\Protocol\ActivityPub;
|
use Friendica\Protocol\ActivityPub;
|
||||||
use Friendica\Util\HTTPSignature;
|
use Friendica\Util\HTTPSignature;
|
||||||
|
@ -34,14 +33,11 @@ class Outbox extends BaseModule
|
||||||
{
|
{
|
||||||
public static function rawContent(array $parameters = [])
|
public static function rawContent(array $parameters = [])
|
||||||
{
|
{
|
||||||
$a = DI::app();
|
if (empty($parameters['nickname'])) {
|
||||||
|
|
||||||
// @TODO: Replace with parameter from router
|
|
||||||
if (empty($a->argv[1])) {
|
|
||||||
throw new \Friendica\Network\HTTPException\NotFoundException();
|
throw new \Friendica\Network\HTTPException\NotFoundException();
|
||||||
}
|
}
|
||||||
|
|
||||||
$owner = User::getOwnerDataByNick($a->argv[1]);
|
$owner = User::getOwnerDataByNick($parameters['nickname']);
|
||||||
if (empty($owner)) {
|
if (empty($owner)) {
|
||||||
throw new \Friendica\Network\HTTPException\NotFoundException();
|
throw new \Friendica\Network\HTTPException\NotFoundException();
|
||||||
}
|
}
|
|
@ -235,26 +235,28 @@ class Transmitter
|
||||||
*/
|
*/
|
||||||
public static function getOutbox($owner, $page = null, $requester = '')
|
public static function getOutbox($owner, $page = null, $requester = '')
|
||||||
{
|
{
|
||||||
$public_contact = Contact::getIdForURL($owner['url']);
|
$condition = ['private' => [Item::PUBLIC, Item::UNLISTED]];
|
||||||
$condition = ['uid' => 0, 'contact-id' => $public_contact,
|
|
||||||
'private' => [Item::PUBLIC, Item::UNLISTED]];
|
|
||||||
|
|
||||||
if (!empty($requester)) {
|
if (!empty($requester)) {
|
||||||
$requester_id = Contact::getIdForURL($requester, $owner['uid']);
|
$requester_id = Contact::getIdForURL($requester, $owner['uid']);
|
||||||
if (!empty($requester_id)) {
|
if (!empty($requester_id)) {
|
||||||
$permissionSets = DI::permissionSet()->selectByContactId($requester_id, $owner['uid']);
|
$permissionSets = DI::permissionSet()->selectByContactId($requester_id, $owner['uid']);
|
||||||
if (!empty($permissionSets)) {
|
if (!empty($permissionSets)) {
|
||||||
$condition = ['uid' => $owner['uid'], 'origin' => true,
|
$condition = ['psid' => array_merge($permissionSets->column('id'),
|
||||||
'psid' => array_merge($permissionSets->column('id'),
|
|
||||||
[DI::permissionSet()->getIdFromACL($owner['uid'], '', '', '', '')])];
|
[DI::permissionSet()->getIdFromACL($owner['uid'], '', '', '', '')])];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$condition = array_merge($condition,
|
$condition = array_merge($condition,
|
||||||
['author-id' => $public_contact,
|
['uid' => $owner['uid'],
|
||||||
'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT],
|
'author-id' => Contact::getIdForURL($owner['url'], 0, false),
|
||||||
'deleted' => false, 'visible' => true]);
|
'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT],
|
||||||
|
'network' => Protocol::FEDERATED,
|
||||||
|
'parent-network' => Protocol::FEDERATED,
|
||||||
|
'origin' => true,
|
||||||
|
'deleted' => false,
|
||||||
|
'visible' => true]);
|
||||||
|
|
||||||
$count = Post::count($condition);
|
$count = Post::count($condition);
|
||||||
|
|
||||||
|
@ -269,8 +271,6 @@ class Transmitter
|
||||||
$data['type'] = 'OrderedCollectionPage';
|
$data['type'] = 'OrderedCollectionPage';
|
||||||
$list = [];
|
$list = [];
|
||||||
|
|
||||||
$condition['parent-network'] = Protocol::NATIVE_SUPPORT;
|
|
||||||
|
|
||||||
$items = Post::select(['id'], $condition, ['limit' => [($page - 1) * 20, 20], 'order' => ['created' => true]]);
|
$items = Post::select(['id'], $condition, ['limit' => [($page - 1) * 20, 20], 'order' => ['created' => true]]);
|
||||||
while ($item = Post::fetch($items)) {
|
while ($item = Post::fetch($items)) {
|
||||||
$activity = self::createActivityFromItem($item['id'], true);
|
$activity = self::createActivityFromItem($item['id'], true);
|
||||||
|
|
|
@ -266,14 +266,14 @@ return [
|
||||||
'/status_message/{guid}' => [Module\Diaspora\Fetch::class, [R::GET]],
|
'/status_message/{guid}' => [Module\Diaspora\Fetch::class, [R::GET]],
|
||||||
'/reshare/{guid}' => [Module\Diaspora\Fetch::class, [R::GET]],
|
'/reshare/{guid}' => [Module\Diaspora\Fetch::class, [R::GET]],
|
||||||
],
|
],
|
||||||
'/filed' => [Module\Search\Filed::class, [R::GET]],
|
'/filed' => [Module\Search\Filed::class, [R::GET]],
|
||||||
'/filer[/{id:\d+}]' => [Module\Filer\SaveTag::class, [R::GET]],
|
'/filer[/{id:\d+}]' => [Module\Filer\SaveTag::class, [R::GET]],
|
||||||
'/filerm/{id:\d+}' => [Module\Filer\RemoveTag::class, [R::GET]],
|
'/filerm/{id:\d+}' => [Module\Filer\RemoveTag::class, [R::GET]],
|
||||||
'/follow_confirm' => [Module\FollowConfirm::class, [R::GET, R::POST]],
|
'/follow_confirm' => [Module\FollowConfirm::class, [R::GET, R::POST]],
|
||||||
'/followers/{owner}' => [Module\Followers::class, [R::GET]],
|
'/followers/{nickname}' => [Module\ActivityPub\Followers::class, [R::GET]],
|
||||||
'/following/{owner}' => [Module\Following::class, [R::GET]],
|
'/following/{nickname}' => [Module\ActivityPub\Following::class, [R::GET]],
|
||||||
'/friendica[/json]' => [Module\Friendica::class, [R::GET]],
|
'/friendica[/json]' => [Module\Friendica::class, [R::GET]],
|
||||||
'/friendica/inbox' => [Module\Inbox::class, [R::GET, R::POST]],
|
'/friendica/inbox' => [Module\ActivityPub\Inbox::class, [R::GET, R::POST]],
|
||||||
|
|
||||||
'/fsuggest/{contact:\d+}' => [Module\FriendSuggest::class, [R::GET, R::POST]],
|
'/fsuggest/{contact:\d+}' => [Module\FriendSuggest::class, [R::GET, R::POST]],
|
||||||
|
|
||||||
|
@ -288,12 +288,12 @@ return [
|
||||||
'/{group:\d+}/add/{contact:\d+}' => [Module\Group::class, [R::GET, R::POST]],
|
'/{group:\d+}/add/{contact:\d+}' => [Module\Group::class, [R::GET, R::POST]],
|
||||||
'/{group:\d+}/remove/{contact:\d+}' => [Module\Group::class, [R::GET, R::POST]],
|
'/{group:\d+}/remove/{contact:\d+}' => [Module\Group::class, [R::GET, R::POST]],
|
||||||
],
|
],
|
||||||
'/hashtag' => [Module\Hashtag::class, [R::GET]],
|
'/hashtag' => [Module\Hashtag::class, [R::GET]],
|
||||||
'/help[/{doc:.+}]' => [Module\Help::class, [R::GET]],
|
'/help[/{doc:.+}]' => [Module\Help::class, [R::GET]],
|
||||||
'/home' => [Module\Home::class, [R::GET]],
|
'/home' => [Module\Home::class, [R::GET]],
|
||||||
'/hcard/{profile}[/{action}]' => [Module\HoverCard::class, [R::GET]],
|
'/hcard/{profile}[/{action}]' => [Module\HoverCard::class, [R::GET]],
|
||||||
'/inbox[/{nickname}]' => [Module\Inbox::class, [R::GET, R::POST]],
|
'/inbox[/{nickname}]' => [Module\ActivityPub\Inbox::class, [R::GET, R::POST]],
|
||||||
'/invite' => [Module\Invite::class, [R::GET, R::POST]],
|
'/invite' => [Module\Invite::class, [R::GET, R::POST]],
|
||||||
|
|
||||||
'/install' => [
|
'/install' => [
|
||||||
'[/]' => [Module\Install::class, [R::GET, R::POST]],
|
'[/]' => [Module\Install::class, [R::GET, R::POST]],
|
||||||
|
@ -355,10 +355,10 @@ return [
|
||||||
'/h2b' => [Module\Oembed::class, [R::GET]],
|
'/h2b' => [Module\Oembed::class, [R::GET]],
|
||||||
'/{hash}' => [Module\Oembed::class, [R::GET]],
|
'/{hash}' => [Module\Oembed::class, [R::GET]],
|
||||||
],
|
],
|
||||||
'/outbox/{owner}' => [Module\Outbox::class, [R::GET]],
|
'/outbox/{nickname}' => [Module\ActivityPub\Outbox::class, [R::GET]],
|
||||||
'/owa' => [Module\Owa::class, [R::GET]],
|
'/owa' => [Module\Owa::class, [R::GET]],
|
||||||
'/openid' => [Module\Security\OpenID::class, [R::GET]],
|
'/openid' => [Module\Security\OpenID::class, [R::GET]],
|
||||||
'/opensearch' => [Module\OpenSearch::class, [R::GET]],
|
'/opensearch' => [Module\OpenSearch::class, [R::GET]],
|
||||||
|
|
||||||
'/parseurl' => [Module\ParseUrl::class, [R::GET]],
|
'/parseurl' => [Module\ParseUrl::class, [R::GET]],
|
||||||
'/permission/tooltip/{type}/{id:\d+}' => [Module\PermissionTooltip::class, [R::GET]],
|
'/permission/tooltip/{type}/{id:\d+}' => [Module\PermissionTooltip::class, [R::GET]],
|
||||||
|
|
Loading…
Reference in New Issue
Block a user