Commit e0b2a997 authored by Tony Emma's avatar Tony Emma
Browse files

Ajout de l'api actor, à tester

parent 9673c877
......@@ -31,6 +31,7 @@ class ApiModule extends CWebModule
'eco.models.*',
'places.models.*',
'news.models.*',
'dda.models.*',
$this->id.'.models.*',
$this->id.'.components.*',
$this->id.'.messages.*',
......
......@@ -33,6 +33,11 @@ class ApiController extends Controller
//'getuseridbymail' => array("href" => "/ph/api/getuseridbymail"),
//"updatefield" => array("href" => "/ph/api/person/updatefield"),
),
"activitypub" => array(
"get" => array("href" => "/ph/api/activitypub/get", "public" => true),
"actor" => array("href"=> "/ph/api/abc/person/actor", "public" => true),
"webfinger" => array("href" => "/.well-known/webfinger","public" => true)
),
"organization"=> array(
"get" => array("href" => "/ph/api/organization/get", "public" => true),
/*"updatefield" => array("href" => "/ph/api/organization/updatefield"),
......
<?php
class ActivitypubController extends ApiController {
protected function beforeAction($action) {
parent::initPage();
return parent::beforeAction($action);
}
public function actions()
{
return array(
'get' => 'api.controllers.activitypub.GetAction',
'actor' => 'api.controllers.activitypub.ActorAction',
'webfinger' => 'api.controllers.activitypub.WebfingerAction'
);
}
}
\ No newline at end of file
<?php
class ActorAction extends CAction{
public function run($id = null, $format = null, $limit=1, $index=0, $tags = null, $multiTags=null , $key = null, $insee = null) {
$controller=$this->getController();
$bindMap = (!empty($id) ? TranslateActivityStream::$dataBinding_actor : null);
$result = Api::getData($bindMap, $format, Citoyen::COLLECTION, $id, $limit, $index, $tags, $multiTags, $key, $insee);
Rest::json($result['entities'][$id]);
Yii::app()->end();
}
}
<?php
class GetAction extends CAction{
public function run($id = null, $format = null, $limit=50, $index=0, $tags = null, $multiTags=null , $key = null, $insee = null) {
$controller=$this->getController();
if($format == Translate::FORMAT_AS)
$bindMap = (empty($id) ? TranslateActivityStream::$dataBinding_allActivityPub : null);
else
$bindMap = (empty($id) ? TranslateCommunecter::$dataBinding_allActivityPub : TranslateCommunecter::$dataBinding_allActivity);
$result = Api::getData($bindMap, $format, ActivityStream::COLLECTION, $id, $limit, $index, $tags, $multiTags, $key, $insee);
if ($format == Translate::FORMAT_KML) {
$strucKml = News::getStrucKml();
Rest::xml($result, $strucKml,$format);
}
else if ($format == Translate::FORMAT_MD) {
//header('Content-Type: text/markdown');
echo $result;
}
Rest::json($result);
Yii::app()->end();
}
}
\ No newline at end of file
<?php
class WebfingerAction extends CAction{
public function run($id = null, $format = null, $limit=1, $index=0, $tags = null, $multiTags=null , $key = null, $insee = null){
$controller=$this->getController();
$bindMap = (!empty($id) ? TranslateActivityStream::$dataBinding_webfinger : null);
$result = Api::getData($bindMap, $format, ActivityStream::COLLECTION2, $id, $limit, $index, $tags, $multiTags, $key, $insee);
Rest::json($result['entities'][$id]);
}
}
\ No newline at end of file
{
{
"swagger": "2.0",
"info": {
"version": "0.0.1",
......@@ -46,6 +46,13 @@
"type": "string",
"required": true
},
"activitypub-id":{
"name": "activitypub-id",
"in": "path",
"description": "The Activity Pub identifier string",
"type": "string",
"required": true
},
"insee": {
"name": "insee",
"in": "query",
......@@ -97,6 +104,55 @@
}
},
"paths": {
"/activitypub/get": {
"get": {
"tags": [
"ActivityPub"
],
"parameters": [
],
"description": "Get information about all Activity Pub.",
"responses": {
"200": {
"description": "The list of Activity Pub.",
"schema": {
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/allActivitypub"
}
}
}
}
}
}
},
"/activitypub/get/id/{activitypub-id}": {
"get": {
"tags": [
"ActivityPub"
],
"parameters": [
{
"$ref": "#/parameters/activitypub-id"
}
],
"description": "Get information about a ActivityPub.",
"responses": {
"200": {
"description": "The ActivityPub object",
"schema": {
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/activitypub"
}
}
}
}
}
}
},
"/person/get": {
"get": {
"tags": [
......@@ -124,7 +180,7 @@
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/allPerson"
"$ref": "#/definitions/allActivitypub"
}
}
}
......@@ -435,6 +491,7 @@
}
}
},
"definitions": {
"meta": {
"type": "object",
......@@ -453,6 +510,82 @@
}
}
},
"allActivitypub": {
"type": "object",
"properties": {
"meta": {
"$ref": "#/definitions/meta"
},
"entities": {
"type": "object",
"properties": {
"id": {
"type": "object",
"properties": {
"@type": {
"type": "string",
"description": "Type of element."
},
"verb": {
"type": "string",
"description": "Type of verb."
},
"author":{
"$ref":"#/definitions/author"
},
"url": {
"$ref": "#/definitions/url"
}
}
}
}
}
}
},
"activitypub": {
"type": "object",
"properties": {
"meta": {
"$ref": "#/definitions/meta"
},
"entities": {
"type": "object",
"properties": {
"id": {
"type": "object",
"properties": {
"@type": {
"type": "string",
"description": "Type of element."
},
"verb": {
"type": "string",
"description": "Type of verb."
},
"author":{
"$ref":"#/definitions/author"
},
"target":{
"$ref":"#/definitions/target"
},
"scope":{
"type":"string"
},
"object":{
"$ref":"#/definitions/object"
},
"url": {
"$ref": "#/definitions/url"
},
"notify":{
"$ref": "#/definitions/notify"
}
}
}
}
}
}
},
"allPerson": {
"type": "object",
"properties": {
......@@ -625,6 +758,62 @@
}
}
},
"author":{
"type":"object",
"properties":{
"id":{
"type":"string",
"description":"id author"
},
"name":{
"type":"string",
"description":"name author"
}
}
},
"target": {
"type": "object",
"properties":{
"type":{
"type":"string",
"description" : "type"
},
"id":{
"type":"string",
"description": "id target"
}
}
},
"object": {
"type": "object",
"properties":{
"displayName":{
"type":"string",
"description" : "type"
},
"displayValue":{
"type":"string",
"description": "id target"
}
}
},
"notify":{
"type":"object",
"properties":{
"objectType":{
"type":"string",
"description": "objectType notify"
},
"id":{
"type":"string",
"description":"id notify"
},
"displayName":{
"type":"string",
"description":"description notifiy"
}
}
},
"allOrganization": {
"type": "object",
"properties": {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment