Tabs to spaces, superfluous whitespace removed.

This commit is contained in:
Siebrand Mazeland 2010-10-30 13:47:19 +02:00
parent 0c64df8cd9
commit 8391058ea4

View File

@ -20,13 +20,12 @@
if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
function ping_broadcast_notice($notice) { function ping_broadcast_notice($notice) {
if ($notice->is_local != Notice::LOCAL_PUBLIC && $notice->is_local != Notice::LOCAL_NONPUBLIC) {
return true;
}
if ($notice->is_local != Notice::LOCAL_PUBLIC && $notice->is_local != Notice::LOCAL_NONPUBLIC) { # Array of servers, URL => type
return true; $notify = common_config('ping', 'notify');
}
# Array of servers, URL => type
$notify = common_config('ping', 'notify');
try { try {
$profile = $notice->getProfile(); $profile = $notice->getProfile();
} catch (Exception $e) { } catch (Exception $e) {
@ -35,21 +34,21 @@ function ping_broadcast_notice($notice) {
common_log(LOG_ERR, "Exception getting notice profile: " . $e->getMessage()); common_log(LOG_ERR, "Exception getting notice profile: " . $e->getMessage());
return true; return true;
} }
$tags = ping_notice_tags($notice); $tags = ping_notice_tags($notice);
foreach ($notify as $notify_url => $type) { foreach ($notify as $notify_url => $type) {
switch ($type) { switch ($type) {
case 'xmlrpc': case 'xmlrpc':
case 'extended': case 'extended':
$req = xmlrpc_encode_request('weblogUpdates.ping', $req = xmlrpc_encode_request('weblogUpdates.ping',
array($profile->nickname, # site name array($profile->nickname, # site name
common_local_url('showstream', common_local_url('showstream',
array('nickname' => $profile->nickname)), array('nickname' => $profile->nickname)),
common_local_url('shownotice', common_local_url('shownotice',
array('notice' => $notice->id)), array('notice' => $notice->id)),
common_local_url('userrss', common_local_url('userrss',
array('nickname' => $profile->nickname)), array('nickname' => $profile->nickname)),
$tags)); $tags));
$request = HTTPClient::start(); $request = HTTPClient::start();
$request->setConfig('connect_timeout', common_config('ping', 'timeout')); $request->setConfig('connect_timeout', common_config('ping', 'timeout'));
@ -79,9 +78,8 @@ function ping_broadcast_notice($notice) {
"Ping success for $notify_url $notice->id"); "Ping success for $notify_url $notice->id");
} }
break; break;
case 'get':
case 'get': case 'post':
case 'post':
$args = array('name' => $profile->nickname, $args = array('name' => $profile->nickname,
'url' => common_local_url('showstream', 'url' => common_local_url('showstream',
array('nickname' => $profile->nickname)), array('nickname' => $profile->nickname)),
@ -108,26 +106,25 @@ function ping_broadcast_notice($notice) {
"'$result->body'"); "'$result->body'");
} }
break; break;
default:
default: common_log(LOG_WARNING, 'Unknown notify type for ' . $notify_url . ': ' . $type);
common_log(LOG_WARNING, 'Unknown notify type for ' . $notify_url . ': ' . $type);
} }
} }
return true; return true;
} }
function ping_notice_tags($notice) { function ping_notice_tags($notice) {
$tag = new Notice_tag(); $tag = new Notice_tag();
$tag->notice_id = $notice->id; $tag->notice_id = $notice->id;
$tags = array(); $tags = array();
if ($tag->find()) { if ($tag->find()) {
while ($tag->fetch()) { while ($tag->fetch()) {
$tags[] = $tag->tag; $tags[] = $tag->tag;
} }
$tag->free(); $tag->free();
unset($tag); unset($tag);
return implode('|', $tags); return implode('|', $tags);
} }
return NULL; return NULL;
} }