diff --git a/src/Module/Api/Friendica/Group/Create.php b/src/Module/Api/Friendica/Group/Create.php index 85445588b..be85146f4 100644 --- a/src/Module/Api/Friendica/Group/Create.php +++ b/src/Module/Api/Friendica/Group/Create.php @@ -35,27 +35,27 @@ class Create extends BaseApi { BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE); $uid = BaseApi::getCurrentUserID(); - + // params $name = $_REQUEST['name'] ?? ''; $json = json_decode($_POST['json'], true); $users = $json['user']; - + // error if no name specified if ($name == '') { throw new HTTPException\BadRequestException('group name not specified'); } - + // error message if specified group name already exists if (DBA::exists('group', ['uid' => $uid, 'name' => $name, 'deleted' => false])) { throw new HTTPException\BadRequestException('group name already exists'); } - + // Check if the group needs to be reactivated if (DBA::exists('group', ['uid' => $uid, 'name' => $name, 'deleted' => true])) { $reactivate_group = true; } - + // create group $ret = Group::create($uid, $name); if ($ret) { @@ -63,7 +63,7 @@ class Create extends BaseApi } else { throw new HTTPException\BadRequestException('other API error'); } - + // add members $erroraddinguser = false; $errorusers = []; @@ -76,12 +76,12 @@ class Create extends BaseApi $errorusers[] = $cid; } } - + // return success message incl. missing users in array $status = ($erroraddinguser ? 'missing user' : ((isset($reactivate_group) && $reactivate_group) ? 'reactivated' : 'ok')); - + $result = ['success' => true, 'gid' => $gid, 'name' => $name, 'status' => $status, 'wrong users' => $errorusers]; - + $this->response->exit('group_create', ['$result' => $result], $this->parameters['extension'] ?? null); } } diff --git a/src/Module/Api/Friendica/Group/Delete.php b/src/Module/Api/Friendica/Group/Delete.php index e845bd7a7..d48e9a4f9 100644 --- a/src/Module/Api/Friendica/Group/Delete.php +++ b/src/Module/Api/Friendica/Group/Delete.php @@ -22,7 +22,6 @@ namespace Friendica\Module\Api\Friendica\Group; use Friendica\Database\DBA; -use Friendica\DI; use Friendica\Model\Group; use Friendica\Module\BaseApi; use Friendica\Network\HTTPException\BadRequestException; diff --git a/src/Module/Api/Friendica/Group/Show.php b/src/Module/Api/Friendica/Group/Show.php index 62e13e08b..3ec2b7625 100644 --- a/src/Module/Api/Friendica/Group/Show.php +++ b/src/Module/Api/Friendica/Group/Show.php @@ -37,14 +37,14 @@ class Show extends BaseApi BaseApi::checkAllowedScope(BaseApi::SCOPE_READ); $uid = BaseApi::getCurrentUserID(); $type = $this->parameters['extension'] ?? ''; - + // params $gid = $_REQUEST['gid'] ?? 0; - + // get data of the specified group id or all groups if not specified if ($gid != 0) { $groups = DBA::selectToArray('group', [], ['deleted' => false, 'uid' => $uid, 'id' => $gid]); - + // error message if specified gid is not in database if (!DBA::isResult($groups)) { throw new HTTPException\BadRequestException('gid not available'); @@ -52,13 +52,13 @@ class Show extends BaseApi } else { $groups = DBA::selectToArray('group', [], ['deleted' => false, 'uid' => $uid]); } - + // loop through all groups and retrieve all members for adding data in the user array $grps = []; foreach ($groups as $rr) { $members = Contact\Group::getById($rr['id']); $users = []; - + if ($type == 'xml') { $user_element = 'users'; $k = 0; diff --git a/src/Module/Api/Twitter/Lists/Create.php b/src/Module/Api/Twitter/Lists/Create.php index 746f71d0f..80071c30e 100644 --- a/src/Module/Api/Twitter/Lists/Create.php +++ b/src/Module/Api/Twitter/Lists/Create.php @@ -53,33 +53,33 @@ class Create extends BaseApi $this->dba = $dba; $this->friendicaGroup = $friendicaGroup; } - + protected function rawContent(array $request = []) { BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE); $uid = BaseApi::getCurrentUserID(); - + // params $name = $_REQUEST['name'] ?? ''; - + if ($name == '') { throw new HTTPException\BadRequestException('group name not specified'); } - + // error message if specified group name already exists if ($this->dba->exists('group', ['uid' => $uid, 'name' => $name, 'deleted' => false])) { throw new HTTPException\BadRequestException('group name already exists'); } - + $ret = Group::create($uid, $name); if ($ret) { $gid = Group::getIdByName($uid, $name); } else { throw new HTTPException\BadRequestException('other API error'); } - + $grp = $this->friendicaGroup->createFromId($gid); - + $this->response->exit('statuses', ['lists' => ['lists' => $grp]], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid)); } } diff --git a/src/Module/Api/Twitter/Lists/Destroy.php b/src/Module/Api/Twitter/Lists/Destroy.php index ee2ac2d3c..06ca9a73d 100644 --- a/src/Module/Api/Twitter/Lists/Destroy.php +++ b/src/Module/Api/Twitter/Lists/Destroy.php @@ -53,29 +53,29 @@ class Destroy extends BaseApi $this->dba = $dba; $this->friendicaGroup = $friendicaGroup; } - + protected function rawContent(array $request = []) { BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE); $uid = BaseApi::getCurrentUserID(); - + // params $gid = $_REQUEST['list_id'] ?? 0; - + // error if no gid specified if ($gid == 0) { throw new HTTPException\BadRequestException('gid not specified'); } - + // get data of the specified group id $group = $this->dba->selectFirst('group', [], ['uid' => $uid, 'id' => $gid]); // error message if specified gid is not in database if (!$group) { throw new HTTPException\BadRequestException('gid not available'); } - + $list = $this->friendicaGroup->createFromId($gid); - + if (Group::remove($gid)) { $this->response->exit('statuses', ['lists' => ['lists' => $list]], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid)); } diff --git a/src/Module/Api/Twitter/Lists/Ownership.php b/src/Module/Api/Twitter/Lists/Ownership.php index 436097970..e94a07823 100644 --- a/src/Module/Api/Twitter/Lists/Ownership.php +++ b/src/Module/Api/Twitter/Lists/Ownership.php @@ -55,9 +55,9 @@ class Ownership extends BaseApi { BaseApi::checkAllowedScope(BaseApi::SCOPE_READ); $uid = BaseApi::getCurrentUserID(); - + $groups = $this->dba->select('group', [], ['deleted' => false, 'uid' => $uid]); - + // loop through all groups $lists = []; foreach ($groups as $group) { diff --git a/src/Module/Api/Twitter/Lists/Statuses.php b/src/Module/Api/Twitter/Lists/Statuses.php index 257d6bc51..5da93740a 100644 --- a/src/Module/Api/Twitter/Lists/Statuses.php +++ b/src/Module/Api/Twitter/Lists/Statuses.php @@ -54,7 +54,7 @@ class Statuses extends BaseApi $this->dba = $dba; $this->twitterStatus = $twitterStatus; } - + protected function rawContent(array $request = []) { BaseApi::checkAllowedScope(BaseApi::SCOPE_READ); diff --git a/src/Module/Api/Twitter/Lists/Update.php b/src/Module/Api/Twitter/Lists/Update.php index 95fe90d0a..d670c3a6d 100644 --- a/src/Module/Api/Twitter/Lists/Update.php +++ b/src/Module/Api/Twitter/Lists/Update.php @@ -58,26 +58,26 @@ class Update extends BaseApi { BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE); $uid = BaseApi::getCurrentUserID(); - + // params $gid = $_REQUEST['list_id'] ?? 0; $name = $_REQUEST['name'] ?? ''; - + // error if no gid specified if ($gid == 0) { throw new HTTPException\BadRequestException('gid not specified'); } - + // get data of the specified group id $group = $this->dba->selectFirst('group', [], ['uid' => $uid, 'id' => $gid]); // error message if specified gid is not in database if (!$group) { throw new HTTPException\BadRequestException('gid not available'); } - + if (Group::update($gid, $name)) { $list = $this->friendicaGroup->createFromId($gid); - + $this->response->exit('statuses', ['lists' => ['lists' => $list]], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid)); } }