$dom = DOMDocument::loadXML($xml);
- // XXX: check that document element is Atom entry
+ if ($dom->documentElement->namespaceURI != Activity::ATOM ||
+ $dom->documentElement->localName != 'entry') {
+ $this->clientError(_m('Salmon post must be an Atom entry.'));
+ }
// XXX: check the signature
- // We need to run an entry into Activity, so get the first one
- $entries = $dom->getElementsByTagNameNS(Activity::ATOM, 'entry');
- if ($entries && $entries->length) {
- // @fixme is it legit to have multiple entries?
- $this->act = new Activity($entries->item(0), $dom->documentElement);
- }
+ $this->act = new Activity($dom->documentElement);
return true;
}
':' . $actor->id .
':' . time(); // @fixme
- //$entry = new Atom10Entry();
+ // @fixme consolidate all these NS settings somewhere
+ $attributes = array('xmlns' => Activity::ATOM,
+ 'xmlns:activity' => 'http://activitystrea.ms/spec/1.0/',
+ 'xmlns:thr' => 'http://purl.org/syndication/thread/1.0',
+ 'xmlns:georss' => 'http://www.georss.org/georss',
+ 'xmlns:ostatus' => 'http://ostatus.org/schema/1.0');
+
$entry = new XMLStringer();
- $entry->elementStart('entry');
+ $entry->elementStart('entry', $attributes);
$entry->element('id', null, $id);
$entry->element('title', null, $text);
$entry->element('summary', null, $text);
$entry->raw($object->asActivityNoun('object'));
$entry->elementEnd('entry');
- $feed = $this->atomFeed($actor);
- $feed->addEntry($entry);
-
- $xml = $feed->getString();
+ $xml = $entry->getString();
common_log(LOG_INFO, "Posting to Salmon endpoint $this->salmonuri: $xml");
$salmon = new Salmon(); // ?