Browse Source

store whether the subscriber used namespace params

send the verification with namespaced params if the request was namespaced, otherwise use plain params.
master
Aaron Parecki 9 years ago
parent
commit
483266d54e
2 changed files with 13 additions and 4 deletions
  1. +3
    -0
      controllers/push.php
  2. +10
    -4
      lib/PushTask.php

+ 3
- 0
controllers/push.php View File

@ -75,6 +75,8 @@ $app->post('/', function() use($app) {
push_error($app, 'Callback URL was invalid');
}
$namespaced = k($params, 'hub_mode') ? 1 : 0; // set namespaced=1 if they used hub_mode in the request
if($mode == 'subscribe') {
verify_push_topic_url($topic, $app);
@ -90,6 +92,7 @@ $app->post('/', function() use($app) {
// Always set a new requested date and challenge
$subscription->date_requested = db\now();
$subscription->challenge = db\random_hash();
$subscription->namespaced = $namespaced;
db\set_updated($subscription);
$subscription->save();

+ 10
- 4
lib/PushTask.php View File

@ -14,13 +14,19 @@ class PushTask {
$exp_ts = time() + $lease_seconds;
$exp_date = date('Y-m-d H:i:s', $exp_ts);
if($feed->namespaced) {
$prefix = 'hub.';
} else {
$prefix = '';
}
$push_params = [
'hub.mode' => ($mode == 'subscribe' ? 'subscribe' : 'unsubscribe'),
'hub.topic' => $feed->feed_url,
'hub.challenge' => $subscription->challenge
$prefix.'mode' => ($mode == 'subscribe' ? 'subscribe' : 'unsubscribe'),
$prefix.'topic' => $feed->feed_url,
$prefix.'challenge' => $subscription->challenge
];
if($mode == 'subscribe') {
$push_params['hub.lease_seconds'] = $lease_seconds;
$push_params[$prefix.'lease_seconds'] = $lease_seconds;
}
$url = parse_url($subscription->callback_url);

Loading…
Cancel
Save