Fix last merge issues

This commit is contained in:
Diogo Cordeiro 2018-07-10 01:47:52 +01:00
parent ecb812d5e6
commit 295d4a254d
19 changed files with 226 additions and 189 deletions

View File

@ -90,6 +90,32 @@ class ActivityPubPlugin extends Plugin
}
}
/**
* Overwrites variables in URL-mapping
*/
class ActivityPubURLMapperOverwrite extends URLMapper
{
static function overwrite_variable ($m, $path, $args, $paramPatterns, $newaction) {
$mimes = [
'application/activity+json',
'application/ld+json',
'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'
];
if (in_array ($_SERVER["HTTP_ACCEPT"], $mimes) == false) {
return true;
}
$m->connect ($path, array('action' => $newaction), $paramPatterns);
$regex = self::makeRegex($path, $paramPatterns);
foreach ($m->variables as $n => $v) {
if ($v[1] == $regex) {
$m->variables[$n][0]['action'] = $newaction;
}
}
}
}
/**
* Plugin return handler
*/

View File

@ -33,7 +33,6 @@ if (!defined ('GNUSOCIAL')) {
* @category Plugin
* @package GNUsocial
* @author Diogo Cordeiro <diogo@fc.up.pt>
* @author Daniel Supernault <danielsupernault@gmail.com>
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://www.gnu.org/software/social/
*/

View File

@ -33,7 +33,6 @@ if (!defined ('GNUSOCIAL')) {
* @category Plugin
* @package GNUsocial
* @author Diogo Cordeiro <diogo@fc.up.pt>
* @author Daniel Supernault <danielsupernault@gmail.com>
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://www.gnu.org/software/social/
*/

View File

@ -1,13 +1,8 @@
<?php
require_once dirname (__DIR__) . DIRECTORY_SEPARATOR . "utils" . DIRECTORY_SEPARATOR . "discovery.php";
use Activitypub_Discovery;
/**
* GNU social - a federating social network
*
* Todo: Description
*
* PHP version 5
* ActivityPubPlugin implementation for GNU Social
*
* LICENCE: This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -26,18 +21,31 @@ use Activitypub_Discovery;
* @package GNUsocial
* @author Diogo Cordeiro <diogo@fc.up.pt>
* @author Daniel Supernault <danielsupernault@gmail.com>
* @copyright 2015 Free Software Foundaction, Inc.
* @copyright 2018 Free Software Foundation http://fsf.org
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link https://gnu.io/social
* @link https://www.gnu.org/software/social/
*/
if (!defined ('GNUSOCIAL')) {
exit (1);
}
if (!defined('GNUSOCIAL')) { exit(1); }
/**
* @category Plugin
* @package GNUsocial
* @author Diogo Cordeiro <diogo@fc.up.pt>
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://www.gnu.org/software/social/
*/
class apActorInboxAction extends ManagedAction
{
protected $needLogin = false;
protected $canPost = true;
/**
* Handle the Actor Inbox request
*
* @return void
*/
protected function handle ()
{
$nickname = $this->trimmed ('nickname');

View File

@ -33,7 +33,6 @@ if (!defined ('GNUSOCIAL')) {
* @category Plugin
* @package GNUsocial
* @author Diogo Cordeiro <diogo@fc.up.pt>
* @author Daniel Supernault <danielsupernault@gmail.com>
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://www.gnu.org/software/social/
*/

View File

@ -1,4 +1,5 @@
<?php
require_once dirname (__DIR__) . DIRECTORY_SEPARATOR . "utils" . DIRECTORY_SEPARATOR . "discovery.php";
use Activitypub_Discovery;
use ActivityPubReturn;
@ -7,9 +8,7 @@ use Activitypub_notice;
/**
* GNU social - a federating social network
*
* Todo: Description
*
* PHP version 5
* ActivityPubPlugin implementation for GNU Social
*
* LICENCE: This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -28,18 +27,31 @@ use Activitypub_notice;
* @package GNUsocial
* @author Diogo Cordeiro <diogo@fc.up.pt>
* @author Daniel Supernault <danielsupernault@gmail.com>
* @copyright 2015 Free Software Foundaction, Inc.
* @copyright 2018 Free Software Foundation http://fsf.org
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link https://gnu.io/social
* @link https://www.gnu.org/software/social/
*/
if (!defined ('GNUSOCIAL')) {
exit (1);
}
if (!defined('GNUSOCIAL')) { exit(1); }
/**
* @category Plugin
* @package GNUsocial
* @author Diogo Cordeiro <diogo@fc.up.pt>
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://www.gnu.org/software/social/
*/
class apSharedInboxAction extends ManagedAction
{
protected $needLogin = false;
protected $canPost = true;
/**
* Handle the Shared Inbox request
*
* @return void
*/
protected function handle ()
{
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
@ -49,7 +61,7 @@ class apSharedInboxAction extends ManagedAction
$data = json_decode (file_get_contents ('php://input'));
// Validate data
if (!(isset($data->type))) {
if (!isset($data->type)) {
ActivityPubReturn::error ("Type was not specified.");
}
if (!isset($data->actor)) {
@ -89,8 +101,7 @@ class apSharedInboxAction extends ManagedAction
// XXX: Invalid actor found, not sure how we handle those
}
}
} else if (empty ($data->to)
|| in_array ($data->to, $public_to)) {
} else if (empty ($data->to) || in_array ($data->to, $public_to)) {
// No need to do anything else at this point, let's just break out the if
} else {
try {

View File

@ -33,7 +33,6 @@ if (!defined ('GNUSOCIAL')) {
* @category Plugin
* @package GNUsocial
* @author Diogo Cordeiro <diogo@fc.up.pt>
* @author Daniel Supernault <danielsupernault@gmail.com>
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://www.gnu.org/software/social/
*/

View File

@ -33,7 +33,6 @@ if (!defined ('GNUSOCIAL')) {
* @category Plugin
* @package GNUsocial
* @author Diogo Cordeiro <diogo@fc.up.pt>
* @author Daniel Supernault <danielsupernault@gmail.com>
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://www.gnu.org/software/social/
*/

View File

@ -33,7 +33,6 @@ if (!defined ('GNUSOCIAL')) {
* @category Plugin
* @package GNUsocial
* @author Diogo Cordeiro <diogo@fc.up.pt>
* @author Daniel Supernault <danielsupernault@gmail.com>
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://www.gnu.org/software/social/
*/

View File

@ -22,8 +22,8 @@ use Profile;
*
* @category Plugin
* @package GNUsocial
* @author Daniel Supernault <danielsupernault@gmail.com>
* @author Diogo Cordeiro <diogo@fc.up.pt>
* @author Daniel Supernault <danielsupernault@gmail.com>
* @copyright 2018 Free Software Foundation http://fsf.org
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link https://www.gnu.org/software/social/
@ -35,12 +35,10 @@ if (!defined ('GNUSOCIAL')) {
/**
* @category Plugin
* @package GNUsocial
* @author Daniel Supernault <danielsupernault@gmail.com>
* @author Diogo Cordeiro <diogo@fc.up.pt>
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://www.gnu.org/software/social/
*/
class Activitypub_Discovery
{
private $discovered_actor_profiles = array ();