-
- // Instead of adding enclosures as an extension to JSON
- // Activities, it seems like we should be using the
- // attachements property of ActivityObject
-
- $attachments = array();
-
- // XXX: OK, this is kinda cheating. We should probably figure out
- // what kind of objects these are based on mime-type and then
- // create specific object types. Right now this rely on
- // duck-typing. Also, we should include an embed code for
- // video attachments.
-
- foreach ($this->enclosures as $enclosure) {
-
- if (is_string($enclosure)) {
-
- $attachments[]['id'] = $enclosure;
-
- } else {
-
- $attachments[]['id'] = $enclosure->url;
-
- $mediaLink = new ActivityStreamsMediaLink(
- $enclosure->url,
- null,
- null,
- $enclosure->mimetype
- // XXX: Add 'size' as an extension to MediaLink?
- );
-
- $attachments[]['mediaLink'] = $mediaLink->asArray(); // extension
-
- if ($enclosure->title) {
- $attachments[]['displayName'] = $enclosure->title;
- }
+ foreach ($this->attachments as $attachment) {
+ if (empty($activity['object']['attachments'])) {
+ $activity['object']['attachments'] = array();