4 * StatusNet, the distributed open-source microblogging tool
8 * Returns 1 if nickname is available on this instance, 0 if not. Error if site is private.
12 * LICENCE: This program is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Affero General Public License as published by
14 * the Free Software Foundation, either version 3 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Affero General Public License for more details.
22 * You should have received a copy of the GNU Affero General Public License
23 * along with this program. If not, see <http://www.gnu.org/licenses/>.
27 * @author Hannes Mannerheim <h@nnesmannerhe.im>
28 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
29 * @link http://www.gnu.org/software/social/
32 if (!defined('GNUSOCIAL')) { exit(1); }
34 class ApiCheckNicknameAction extends ApiAction
37 protected function prepare(array $args=array())
39 parent::prepare($args);
41 if (common_config('site', 'private')) {
42 $this->clientError(_('This site is private.'), 403);
45 if ($this->format !== 'json') {
46 $this->clientError('This method currently only serves JSON.', 415);
52 protected function handle()
56 $nickname = $this->trimmed('nickname');
59 Nickname::normalize($nickname, true);
61 } catch (NicknameException $e) {
65 $this->initDocument('json');
66 $this->showJsonObjects($nickname_ok);
67 $this->endDocument('json');