3 * StatusNet - the distributed open-source microblogging tool
4 * Copyright (C) 2008, 2009, StatusNet, 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('STATUSNET') && !defined('LACONICA')) {
25 * Queue handler for watching new notices and posting to enjit.
26 * @fixme is this actually being used/functional atm?
28 class EnjitQueueHandler extends QueueHandler
35 function handle($notice)
38 $profile = Profile::staticGet($notice->profile_id);
40 $this->log(LOG_INFO, "Posting Notice ".$notice->id." from ".$profile->nickname);
42 if ( ! $notice->is_local ) {
43 $this->log(LOG_INFO, "Skipping remote notice");
48 # Build an Atom message from the notice
50 $noticeurl = common_local_url('shownotice', array('notice' => $notice->id));
51 $msg = $profile->nickname . ': ' . $notice->content;
53 $atom = "<entry xmlns='http://www.w3.org/2005/Atom'>\n";
54 $atom .= "<apisource>".common_config('enjit','source')."</apisource>\n";
55 $atom .= "<source>\n";
56 $atom .= "<title>" . $profile->nickname . " - " . common_config('site', 'name') . "</title>\n";
57 $atom .= "<link href='" . $profile->profileurl . "'/>\n";
58 $atom .= "<link rel='self' type='application/rss+xml' href='" . common_local_url('userrss', array('nickname' => $profile->nickname)) . "'/>\n";
59 $atom .= "<author><name>" . $profile->nickname . "</name></author>\n";
60 $atom .= "<icon>" . $profile->avatarUrl(AVATAR_PROFILE_SIZE) . "</icon>\n";
61 $atom .= "</source>\n";
62 $atom .= "<title>" . htmlspecialchars($msg) . "</title>\n";
63 $atom .= "<summary>" . htmlspecialchars($msg) . "</summary>\n";
64 $atom .= "<link rel='alternate' href='" . $noticeurl . "' />\n";
65 $atom .= "<id>". $notice->uri . "</id>\n";
66 $atom .= "<published>".common_date_w3dtf($notice->created)."</published>\n";
67 $atom .= "<updated>".common_date_w3dtf($notice->modified)."</updated>\n";
68 $atom .= "</entry>\n";
70 $url = common_config('enjit', 'apiurl') . "/submit/". common_config('enjit','apikey');
76 # POST the message to $config['enjit']['apiurl']
78 $request = HTTPClient::start();
79 $response = $request->post($url, null, $data);
81 return $response->isOk();