git.gnu.io has moved to IP address 209.51.188.249 -- please double check where you are logging in.

Commit da42d36d authored by Zach Copley's avatar Zach Copley

Activity Streams JSON - express to and in-reply-to stuff as person objects

parent 20e41466
......@@ -364,6 +364,27 @@ class Activity
if ($this->verb == ActivityVerb::POST && count($this->objects) == 1) {
$activity['object'] = $this->objects[0]->asArray();
// Context stuff. For now I'm just sticking most of it
// in a property called "context"
if (!empty($this->context)) {
if (!empty($this->context->location)) {
$loc = $this->context->location;
// GeoJSON
$activity['geopoint'] = array(
'type' => 'Point',
'coordinates' => array($loc->lat, $loc->lon)
);
}
$activity['to'] = $this->context->getToArray();
$activity['context'] = $this->context->asArray();
}
// Instead of adding enclosures as an extension to JSON
// Activities, it seems like we should be using the
// attachedObjects property of ActivityObject
......@@ -457,28 +478,6 @@ class Activity
}
}
// Context stuff. For now I'm just sticking most of it
// in a property called "context"
if (!empty($this->context)) {
if (!empty($this->context->location)) {
$loc = $this->context->location;
// GeoJSON
$activity['geopoint'] = array(
'type' => 'Point',
'coordinates' => array($loc->lat, $loc->lon)
);
}
$activity['to'] = $this->context->getToArray();
$activity['context'] = $this->context->asArray();
}
return array_filter($activity);
}
......
......@@ -137,19 +137,16 @@ class ActivityContext
*
* @return array the context
*/
function asArray()
{
$context = array();
$context['replyToId'] = $this->replyToID;
$context['replyToUrl'] = $this->replyToUrl;
$context['replyTo'] = $this->getInReplyToArray();
$context['conversation'] = $this->conversation;
$context['forwardId'] = $this->forwardID;
$context['forwardUrl'] = $this->forwardUrl;
// XXX: We might want to have the attention to stuff
// in here like we do with Atom
return array_filter($context);
}
......@@ -164,16 +161,38 @@ class ActivityContext
*
* @return array the array of recipients
*/
function getToArray()
{
$tos = array();
foreach ($this->attention as $attnUrl) {
$to = array('id' => $attnUrl, 'url' => $attnUrl);
$to = array(
'objectType' => 'person',
'id' => $attnUrl,
'url' => $attnUrl
);
$tos[] = $to;
}
return $tos;
}
/*
* Show replyTo
*/
function getInReplyToArray()
{
$replyToObj = array('objectType' => 'note');
$replyToObj['id'] = $this->replyToID;
if (!empty($this->replyToUrl)) {
$replyToObj['url'] = $this->replyToUrl;
}
}
}
Markdown is supported
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