Add image to JSON ActivityObject and title + links to the JSON document

This commit is contained in:
Zach Copley
2011-02-16 16:21:46 -08:00
parent 764a29e2ff
commit e4d5c47ebf
4 changed files with 136 additions and 6 deletions

View File

@@ -652,13 +652,35 @@ class ActivityObject
// TODO: downstreamDuplicates
// TODO: embedCode
// TODO: embedCode (video)
// id
$object['id'] = $this->id;
// TODO: image
// Need to make MediaLink serialization
if ($this->type == ActivityObject::PERSON
|| $this->type == ActivityObject::GROUP) {
// XXX: Not sure what the best avatar is to use for the
// author's "image". For now, I'm using the stream size
// one, but possibly it should be large
$avatarLink = null;
foreach ($this->avatarLinks as $a) {
if ($a->height == AVATAR_STREAM_SIZE) {
$avatarLink = $a;
break;
}
}
$imgLink = new ActivityStreamsMediaLink(
$avatarLink->url,
$avatarLink->width,
$avatarLink->height,
$avatarLink->type
);
$object['image'] = $imgLink->asArray();
}
// objectType
$object['type'] = $this->type;
@@ -673,6 +695,6 @@ class ActivityObject
// TODO: extensions (OStatus stuff, etc.)
return $object;
return array_filter($object);
}
}