summaryrefslogtreecommitdiff
path: root/plugins/OStatus/classes
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2010-02-24 15:54:29 -0500
committerEvan Prodromou <evan@status.net>2010-02-24 15:54:29 -0500
commit01cfe86cd27eb302a69c5d6df8eddc4893b774c3 (patch)
tree2f72a1fa1a6d5309d5f10c94667e92bfb099e771 /plugins/OStatus/classes
parentc0d13097dd96b3596b43e34e7fff0acd97a838f0 (diff)
parent0c7844734edbed42c2ea3046dc1418cba828e583 (diff)
Merge branch 'testing' of git@gitorious.org:statusnet/mainline into testing
Diffstat (limited to 'plugins/OStatus/classes')
-rw-r--r--plugins/OStatus/classes/HubSub.php2
-rw-r--r--plugins/OStatus/classes/Ostatus_profile.php46
2 files changed, 42 insertions, 6 deletions
diff --git a/plugins/OStatus/classes/HubSub.php b/plugins/OStatus/classes/HubSub.php
index eae2928c3..1ac181fee 100644
--- a/plugins/OStatus/classes/HubSub.php
+++ b/plugins/OStatus/classes/HubSub.php
@@ -164,7 +164,7 @@ class HubSub extends Memcached_DataObject
'token' => $token,
'retries' => $retries);
$qm = QueueManager::get();
- $qm->enqueue($data, 'hubverify');
+ $qm->enqueue($data, 'hubconf');
}
/**
diff --git a/plugins/OStatus/classes/Ostatus_profile.php b/plugins/OStatus/classes/Ostatus_profile.php
index e8ab06522..5e38a523e 100644
--- a/plugins/OStatus/classes/Ostatus_profile.php
+++ b/plugins/OStatus/classes/Ostatus_profile.php
@@ -422,21 +422,57 @@ class Ostatus_profile extends Memcached_DataObject
return false;
}
- public function notifyActivity($activity)
+ /**
+ * Send a Salmon notification ping immediately, and confirm that we got
+ * an acceptable response from the remote site.
+ *
+ * @param mixed $entry XML string, Notice, or Activity
+ * @return boolean success
+ */
+ public function notifyActivity($entry)
{
if ($this->salmonuri) {
+ $salmon = new Salmon();
+ return $salmon->post($this->salmonuri, $this->notifyPrepXml($entry));
+ }
- $xml = '<?xml version="1.0" encoding="UTF-8" ?' . '>' .
- $activity->asString(true);
+ return false;
+ }
- $salmon = new Salmon(); // ?
+ /**
+ * Queue a Salmon notification for later. If queues are disabled we'll
+ * send immediately but won't get the return value.
+ *
+ * @param mixed $entry XML string, Notice, or Activity
+ * @return boolean success
+ */
+ public function notifyDeferred($entry)
+ {
+ if ($this->salmonuri) {
+ $data = array('salmonuri' => $this->salmonuri,
+ 'entry' => $this->notifyPrepXml($entry));
- return $salmon->post($this->salmonuri, $xml);
+ $qm = QueueManager::get();
+ return $qm->enqueue($data, 'salmon');
}
return false;
}
+ protected function notifyPrepXml($entry)
+ {
+ $preamble = '<?xml version="1.0" encoding="UTF-8" ?' . '>';
+ if (is_string($entry)) {
+ return $entry;
+ } else if ($entry instanceof Activity) {
+ return $preamble . $entry->asString(true);
+ } else if ($entry instanceof Notice) {
+ return $preamble . $entry->asAtomEntry(true, true);
+ } else {
+ throw new ServerException("Invalid type passed to Ostatus_profile::notify; must be XML string or Activity entry");
+ }
+ }
+
function getBestName()
{
if ($this->isGroup()) {