function pubsubhubbub_init(App $a) {
// PuSH subscription must be considered "public" so just block it
// if public access isn't enabled.
function pubsubhubbub_init(App $a) {
// PuSH subscription must be considered "public" so just block it
// if public access isn't enabled.
- if ($_SERVER['REQUEST_METHOD'] === 'POST') {
- $hub_mode = post_var('hub_mode');
- $hub_callback = post_var('hub_callback');
- $hub_verify_token = post_var('hub_verify_token');
- $hub_secret = post_var('hub_secret');
- $hub_topic = post_var('hub_topic');
+ if (DI::args()->getMethod() === App\Router::POST) {
+ $hub_mode = $_POST['hub_mode'] ?? '';
+ $hub_callback = $_POST['hub_callback'] ?? '';
+ $hub_verify_token = $_POST['hub_verify_token'] ?? '';
+ $hub_secret = $_POST['hub_secret'] ?? '';
+ $hub_topic = $_POST['hub_topic'] ?? '';
throw new \Friendica\Network\HTTPException\NotFoundException();
}
// fetch user from database given the nickname
$condition = ['nickname' => $nick, 'account_expired' => false, 'account_removed' => false];
throw new \Friendica\Network\HTTPException\NotFoundException();
}
// fetch user from database given the nickname
$condition = ['nickname' => $nick, 'account_expired' => false, 'account_removed' => false];
- $owner = DBA::selectFirst('user', ['uid', 'hidewall', 'nickname'], $condition);
+ $owner = DBA::selectFirst('user', ['uid', 'nickname'], $condition);
- // abort if user's wall is supposed to be private
- if ($owner['hidewall']) {
- Logger::log('Local user ' . $nick . 'has chosen to hide wall, ignoring.');
- throw new \Friendica\Network\HTTPException\ForbiddenException();
- }
-
// get corresponding row from contact table
$condition = ['uid' => $owner['uid'], 'blocked' => false,
'pending' => false, 'self' => true];
$contact = DBA::selectFirst('contact', ['poll'], $condition);
if (!DBA::isResult($contact)) {
// get corresponding row from contact table
$condition = ['uid' => $owner['uid'], 'blocked' => false,
'pending' => false, 'self' => true];
$contact = DBA::selectFirst('contact', ['poll'], $condition);
if (!DBA::isResult($contact)) {
$self = DI::baseUrl() . '/api/statuses/user_timeline/' . $owner['nickname'] . '.atom';
if (!Strings::compareLink($hub_topic, $contact['poll']) && !Strings::compareLink($hub_topic2, $contact['poll']) && !Strings::compareLink($hub_topic, $self)) {
$self = DI::baseUrl() . '/api/statuses/user_timeline/' . $owner['nickname'] . '.atom';
if (!Strings::compareLink($hub_topic, $contact['poll']) && !Strings::compareLink($hub_topic2, $contact['poll']) && !Strings::compareLink($hub_topic, $self)) {
$hub_callback = rtrim($hub_callback, ' ?&#');
$separator = parse_url($hub_callback, PHP_URL_QUERY) === null ? '?' : '&';
$hub_callback = rtrim($hub_callback, ' ?&#');
$separator = parse_url($hub_callback, PHP_URL_QUERY) === null ? '?' : '&';
$body = $fetchResult->getBody();
$ret = $fetchResult->getReturnCode();
// give up if the HTTP return code wasn't a success (2xx)
if ($ret < 200 || $ret > 299) {
$body = $fetchResult->getBody();
$ret = $fetchResult->getReturnCode();
// give up if the HTTP return code wasn't a success (2xx)
if ($ret < 200 || $ret > 299) {
throw new \Friendica\Network\HTTPException\NotFoundException();
}
// check that the correct hub_challenge code was echoed back
if (trim($body) !== $hub_challenge) {
throw new \Friendica\Network\HTTPException\NotFoundException();
}
// check that the correct hub_challenge code was echoed back
if (trim($body) !== $hub_challenge) {
- Logger::log("Subscriber did not echo back hub.challenge, ignoring.");
- Logger::log("\"$hub_challenge\" != \"".trim($body)."\"");
+ Logger::notice("Subscriber did not echo back hub.challenge, ignoring.");
+ Logger::notice("\"$hub_challenge\" != \"".trim($body)."\"");