summaryrefslogtreecommitdiff
path: root/plugins/OStatus/actions
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-02-18 18:20:48 +0000
committerBrion Vibber <brion@pobox.com>2010-02-18 18:20:48 +0000
commit22ff358ba8d1fd0396136e1de570d788dd0727b6 (patch)
treee53d46a094dea1c653ad7e2cb6576ac8ec17c86e /plugins/OStatus/actions
parentc2ba7645359242590c8ac60b66f012110ae889ef (diff)
OStatus sub/unsub updates:
- fix for PuSH unsub verification - send Salmon notification on unsub
Diffstat (limited to 'plugins/OStatus/actions')
-rw-r--r--plugins/OStatus/actions/pushcallback.php2
-rw-r--r--plugins/OStatus/actions/pushhub.php9
-rw-r--r--plugins/OStatus/actions/salmon.php2
3 files changed, 9 insertions, 4 deletions
diff --git a/plugins/OStatus/actions/pushcallback.php b/plugins/OStatus/actions/pushcallback.php
index 388c8f9c3..ed859a32f 100644
--- a/plugins/OStatus/actions/pushcallback.php
+++ b/plugins/OStatus/actions/pushcallback.php
@@ -89,7 +89,7 @@ class PushCallbackAction extends Action
if ($profile->verify_token !== $verify_token) {
common_log(LOG_WARNING, __METHOD__ . ": bogus hub callback with bad token \"$verify_token\" for feed $topic");
- throw new ServerError("Bogus hub callback: bad token", 404);
+ throw new ServerException("Bogus hub callback: bad token", 404);
}
if ($mode != $profile->sub_state) {
diff --git a/plugins/OStatus/actions/pushhub.php b/plugins/OStatus/actions/pushhub.php
index 13ec09d52..19599d815 100644
--- a/plugins/OStatus/actions/pushhub.php
+++ b/plugins/OStatus/actions/pushhub.php
@@ -83,6 +83,7 @@ class PushHubAction extends Action
{
$feed = $this->argUrl('hub.topic');
$callback = $this->argUrl('hub.callback');
+ $token = $this->arg('hub.verify_token', null);
common_log(LOG_DEBUG, __METHOD__ . ": checking sub'd to $feed $callback");
if ($this->getSub($feed, $callback)) {
@@ -96,7 +97,6 @@ class PushHubAction extends Action
$sub = new HubSub();
$sub->topic = $feed;
$sub->callback = $callback;
- $sub->verify_token = $this->arg('hub.verify_token', null);
$sub->secret = $this->arg('hub.secret', null);
if (strlen($sub->secret) > 200) {
throw new ClientException("hub.secret must be no longer than 200 chars", 400);
@@ -115,7 +115,7 @@ class PushHubAction extends Action
// @fixme check errors ;)
- $data = array('sub' => $sub, 'mode' => 'subscribe');
+ $data = array('sub' => $sub, 'mode' => 'subscribe', 'token' => $token);
$qm = QueueManager::get();
$qm->enqueue($data, 'hubverify');
@@ -130,6 +130,8 @@ class PushHubAction extends Action
* 202 Accepted - request saved and awaiting verification
* 204 No Content - already subscribed
* 400 Bad Request - invalid params or rejected feed
+ *
+ * @fixme background this
*/
function unsubscribe()
{
@@ -138,7 +140,8 @@ class PushHubAction extends Action
$sub = $this->getSub($feed, $callback);
if ($sub) {
- if ($sub->verify('unsubscribe')) {
+ $token = $this->arg('hub.verify_token', null);
+ if ($sub->verify('unsubscribe', $token)) {
$sub->delete();
common_log(LOG_INFO, "PuSH unsubscribed $feed for $callback");
} else {
diff --git a/plugins/OStatus/actions/salmon.php b/plugins/OStatus/actions/salmon.php
index 9ca019826..224134cd7 100644
--- a/plugins/OStatus/actions/salmon.php
+++ b/plugins/OStatus/actions/salmon.php
@@ -34,6 +34,8 @@ class SalmonAction extends Action
function prepare($args)
{
+ parent::prepare($args);
+
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
$this->clientError(_('This method requires a POST.'));
}