3 * Laconica - a distributed open-source microblogging tool
4 * Copyright (C) 2008, Controlez-Vous, Inc.
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 if (!defined('LACONICA')) { exit(1); }
22 function ping_broadcast_notice($notice) {
23 if (!$notice->is_local) {
27 # Array of servers, URL => type
28 $notify = common_config('ping', 'notify');
29 $profile = $notice->getProfile();
30 $tags = ping_notice_tags($notice);
32 foreach ($notify as $notify_url => $type) {
36 $req = xmlrpc_encode_request('weblogUpdates.ping',
37 array($profile->nickname, # site name
38 common_local_url('showstream',
39 array('nickname' => $profile->nickname)),
40 common_local_url('shownotice',
41 array('notice' => $notice->id)),
42 common_local_url('userrss',
43 array('nickname' => $profile->nickname)),
46 # We re-use this tool's fetcher, since it's pretty good
48 $fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
51 common_log(LOG_WARNING, 'Failed to initialize Yadis fetcher.', __FILE__);
55 $result = $fetcher->post($notify_url,
61 common_log(LOG_WARNING, 'Unknown notify type for ' . $notify_url . ': ' . $type);
66 function ping_notice_tags($notice) {
67 $tag = new Notice_tag();
68 $tag->notice_id = $notice->id;
71 while ($tag->fetch()) {
76 return implode('|', $tags);