Add Remote Flow (#43) and PHP Unit Tests from dansup (#37)

Now the code is following most of PSR
Various changes from various branches (some testing will be required)
Fixed various issues
This commit is contained in:
Diogo Cordeiro
2018-07-26 21:12:13 +00:00
parent e377b87ff7
commit eaad9423dd
45 changed files with 4723 additions and 1918 deletions

View File

@@ -25,8 +25,8 @@
* @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/
*/
if (!defined ('GNUSOCIAL')) {
exit (1);
if (!defined('GNUSOCIAL')) {
exit(1);
}
/**
@@ -40,39 +40,38 @@ if (!defined ('GNUSOCIAL')) {
*/
class Activitypub_attachment extends Managed_DataObject
{
/**
* Generates a pretty array from an Attachment object
*
* @author Diogo Cordeiro <diogo@fc.up.pt>
* @param Attachment $attachment
* @return pretty array to be used in a response
*/
public static function attachment_to_array ($attachment)
{
$res = [
/**
* Generates a pretty array from an Attachment object
*
* @author Diogo Cordeiro <diogo@fc.up.pt>
* @param Attachment $attachment
* @return pretty array to be used in a response
*/
public static function attachment_to_array($attachment)
{
$res = [
'@context' => [
"https://www.w3.org/ns/activitystreams",
[
"@language" => "en"
]
],
'id' => $attachment->getID (),
'id' => $attachment->getID(),
'mimetype' => $attachment->mimetype,
'url' => $attachment->getUrl (),
'url' => $attachment->getUrl(),
'size' => intval($attachment->size), // $attachment->getSize ()
'title' => $attachment->getTitle (),
'title' => $attachment->getTitle(),
'meta' => null
];
// Image
if (substr ($res["mimetype"], 0, 5) == "image")
{
$res["meta"]= [
// Image
if (substr($res["mimetype"], 0, 5) == "image") {
$res["meta"]= [
'width' => $attachment->width,
'height' => $attachment->height
];
}
return $res;
}
return $res;
}
}