mirror of
https://github.com/friendica/friendica
synced 2025-04-21 10:30:13 +00:00
Some more API functions moved
This commit is contained in:
parent
d5703e350c
commit
66db55f0cd
5 changed files with 165 additions and 123 deletions
77
src/Module/Api/Friendica/Group/Delete.php
Normal file
77
src/Module/Api/Friendica/Group/Delete.php
Normal file
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (C) 2010-2021, the Friendica project
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Friendica\Module\Api\Friendica\Group;
|
||||
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Group;
|
||||
use Friendica\Module\BaseApi;
|
||||
use Friendica\Network\HTTPException\BadRequestException;
|
||||
|
||||
/**
|
||||
* API endpoint: /api/friendica/group/delete
|
||||
*/
|
||||
class Delete extends BaseApi
|
||||
{
|
||||
public static function rawContent(array $parameters = [])
|
||||
{
|
||||
self::checkAllowedScope(self::SCOPE_WRITE);
|
||||
$uid = self::getCurrentUserID();
|
||||
|
||||
$request = self::getRequest([
|
||||
'gid' => 0,
|
||||
'name' => ''
|
||||
]);
|
||||
|
||||
// params
|
||||
|
||||
// error if no gid specified
|
||||
if ($request['gid'] == 0 || $request['name'] == "") {
|
||||
throw new BadRequestException('gid or name not specified');
|
||||
}
|
||||
|
||||
// error message if specified gid is not in database
|
||||
if (!DBA::exists('group', ['uid' => $uid, 'id' => $request['gid']])) {
|
||||
throw new BadRequestException('gid not available');
|
||||
}
|
||||
|
||||
// error message if specified gid is not in database
|
||||
if (!DBA::exists('group', ['uid' => $uid, 'id' => $request['gid'], 'name' => $request['name']])) {
|
||||
throw new BadRequestException('wrong group name');
|
||||
}
|
||||
|
||||
// delete group
|
||||
$gid = Group::getIdByName($uid, $request['name']);
|
||||
if (empty($request['gid'])) {
|
||||
throw new BadRequestException('other API error');
|
||||
}
|
||||
|
||||
$ret = Group::remove($gid);
|
||||
|
||||
if ($ret) {
|
||||
// return success
|
||||
$success = ['success' => $ret, 'gid' => $request['gid'], 'name' => $request['name'], 'status' => 'deleted', 'wrong users' => []];
|
||||
self::exit('group_delete', ['$result' => $success], $parameters['extension'] ?? null);
|
||||
} else {
|
||||
throw new BadRequestException('other API error');
|
||||
}
|
||||
}
|
||||
}
|
65
src/Module/Api/GNUSocial/GNUSocial/Config.php
Normal file
65
src/Module/Api/GNUSocial/GNUSocial/Config.php
Normal file
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (C) 2010-2021, the Friendica project
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Friendica\Module\Api\GNUSocial\GNUSocial;
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\BaseApi;
|
||||
|
||||
/**
|
||||
* API endpoint: /api/gnusocial/version, /api/statusnet/version
|
||||
*/
|
||||
class Config extends BaseApi
|
||||
{
|
||||
public static function rawContent(array $parameters = [])
|
||||
{
|
||||
$config = [
|
||||
'site' => [
|
||||
'name' => DI::config()->get('config', 'sitename'),
|
||||
'server' => DI::baseUrl()->getHostname(),
|
||||
'theme' => DI::config()->get('system', 'theme'),
|
||||
'path' => DI::baseUrl()->getUrlPath(),
|
||||
'logo' => DI::baseUrl() . '/images/friendica-64.png',
|
||||
'fancy' => true,
|
||||
'language' => DI::config()->get('system', 'language'),
|
||||
'email' => DI::config()->get('config', 'admin_email'),
|
||||
'broughtby' => '',
|
||||
'broughtbyurl' => '',
|
||||
'timezone' => DI::config()->get('system', 'default_timezone'),
|
||||
'closed' => (bool)(DI::config()->get('config', 'register_policy') == \Friendica\Module\Register::CLOSED),
|
||||
'inviteonly' => (bool)DI::config()->get('system', 'invitation_only'),
|
||||
'private' => (bool)DI::config()->get('system', 'block_public'),
|
||||
'textlimit' => (string) DI::config()->get('config', 'api_import_size', DI::config()->get('config', 'max_import_size')),
|
||||
'sslserver' => null,
|
||||
'ssl' => DI::config()->get('system', 'ssl_policy') == App\BaseURL::SSL_POLICY_FULL ? 'always' : '0',
|
||||
'friendica' => [
|
||||
'FRIENDICA_PLATFORM' => FRIENDICA_PLATFORM,
|
||||
'FRIENDICA_VERSION' => FRIENDICA_VERSION,
|
||||
'DFRN_PROTOCOL_VERSION' => DFRN_PROTOCOL_VERSION,
|
||||
'DB_UPDATE_VERSION' => DB_UPDATE_VERSION,
|
||||
]
|
||||
],
|
||||
];
|
||||
|
||||
self::exit('config', ['config' => $config], $parameters['extension'] ?? null);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue