mirror of
https://github.com/friendica/friendica
synced 2025-04-21 22:30:11 +00:00
Replace "group" with "circle" in the rest of the code
- Remaining mentions already mean "forum"
This commit is contained in:
parent
4f6e02357a
commit
4f7740264e
120 changed files with 1308 additions and 1304 deletions
|
@ -19,14 +19,15 @@
|
|||
*
|
||||
*/
|
||||
|
||||
namespace Friendica\Module\Api\Friendica\Group;
|
||||
namespace Friendica\Module\Api\Friendica\Circle;
|
||||
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Group;
|
||||
use Friendica\Model\Circle;
|
||||
use Friendica\Module\BaseApi;
|
||||
use Friendica\Network\HTTPException;
|
||||
|
||||
/**
|
||||
* API endpoint: /api/friendica/circle_create
|
||||
* API endpoint: /api/friendica/group_create
|
||||
*/
|
||||
class Create extends BaseApi
|
||||
|
@ -43,23 +44,22 @@ class Create extends BaseApi
|
|||
|
||||
// error if no name specified
|
||||
if ($name == '') {
|
||||
throw new HTTPException\BadRequestException('group name not specified');
|
||||
throw new HTTPException\BadRequestException('circle name not specified');
|
||||
}
|
||||
|
||||
// error message if specified group name already exists
|
||||
// error message if specified circle name already exists
|
||||
if (DBA::exists('group', ['uid' => $uid, 'name' => $name, 'deleted' => false])) {
|
||||
throw new HTTPException\BadRequestException('group name already exists');
|
||||
throw new HTTPException\BadRequestException('circle name already exists');
|
||||
}
|
||||
|
||||
// Check if the group needs to be reactivated
|
||||
// Check if the circle needs to be reactivated
|
||||
if (DBA::exists('group', ['uid' => $uid, 'name' => $name, 'deleted' => true])) {
|
||||
$reactivate_group = true;
|
||||
$reactivate_circle = true;
|
||||
}
|
||||
|
||||
// create group
|
||||
$ret = Group::create($uid, $name);
|
||||
$ret = Circle::create($uid, $name);
|
||||
if ($ret) {
|
||||
$gid = Group::getIdByName($uid, $name);
|
||||
$gid = Circle::getIdByName($uid, $name);
|
||||
} else {
|
||||
throw new HTTPException\BadRequestException('other API error');
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ class Create extends BaseApi
|
|||
foreach ($users as $user) {
|
||||
$cid = $user['cid'];
|
||||
if (DBA::exists('contact', ['id' => $cid, 'uid' => $uid])) {
|
||||
Group::addMember($gid, $cid);
|
||||
Circle::addMember($gid, $cid);
|
||||
} else {
|
||||
$erroraddinguser = true;
|
||||
$errorusers[] = $cid;
|
||||
|
@ -78,7 +78,7 @@ class Create extends BaseApi
|
|||
}
|
||||
|
||||
// return success message incl. missing users in array
|
||||
$status = ($erroraddinguser ? 'missing user' : ((isset($reactivate_group) && $reactivate_group) ? 'reactivated' : 'ok'));
|
||||
$status = ($erroraddinguser ? 'missing user' : (!empty($reactivate_circle) ? 'reactivated' : 'ok'));
|
||||
|
||||
$result = ['success' => true, 'gid' => $gid, 'name' => $name, 'status' => $status, 'wrong users' => $errorusers];
|
||||
|
|
@ -19,15 +19,16 @@
|
|||
*
|
||||
*/
|
||||
|
||||
namespace Friendica\Module\Api\Friendica\Group;
|
||||
namespace Friendica\Module\Api\Friendica\Circle;
|
||||
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Group;
|
||||
use Friendica\Model\Circle;
|
||||
use Friendica\Module\BaseApi;
|
||||
use Friendica\Network\HTTPException\BadRequestException;
|
||||
|
||||
/**
|
||||
* API endpoint: /api/friendica/group/delete
|
||||
* API endpoint: /api/friendica/circle/delete
|
||||
*/
|
||||
class Delete extends BaseApi
|
||||
{
|
||||
|
@ -55,16 +56,16 @@ class Delete extends BaseApi
|
|||
|
||||
// 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');
|
||||
throw new BadRequestException('wrong circle name');
|
||||
}
|
||||
|
||||
// delete group
|
||||
$gid = Group::getIdByName($uid, $request['name']);
|
||||
// delete circle
|
||||
$gid = Circle::getIdByName($uid, $request['name']);
|
||||
if (empty($request['gid'])) {
|
||||
throw new BadRequestException('other API error');
|
||||
}
|
||||
|
||||
$ret = Group::remove($gid);
|
||||
$ret = Circle::remove($gid);
|
||||
|
||||
if ($ret) {
|
||||
// return success
|
|
@ -19,7 +19,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
namespace Friendica\Module\Api\Friendica\Group;
|
||||
namespace Friendica\Module\Api\Friendica\Circle;
|
||||
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
|
@ -28,6 +28,7 @@ use Friendica\Module\BaseApi;
|
|||
use Friendica\Network\HTTPException;
|
||||
|
||||
/**
|
||||
* API endpoint: /api/friendica/circle_show
|
||||
* API endpoint: /api/friendica/group_show
|
||||
*/
|
||||
class Show extends BaseApi
|
||||
|
@ -41,22 +42,22 @@ class Show extends BaseApi
|
|||
// params
|
||||
$gid = $this->getRequestValue($request, 'gid', 0);
|
||||
|
||||
// get data of the specified group id or all groups if not specified
|
||||
// get data of the specified circle id or all circles if not specified
|
||||
if ($gid != 0) {
|
||||
$groups = DBA::selectToArray('group', [], ['deleted' => false, 'uid' => $uid, 'id' => $gid]);
|
||||
$circles = DBA::selectToArray('group', [], ['deleted' => false, 'uid' => $uid, 'id' => $gid]);
|
||||
|
||||
// error message if specified gid is not in database
|
||||
if (!DBA::isResult($groups)) {
|
||||
if (!DBA::isResult($circles)) {
|
||||
throw new HTTPException\BadRequestException('gid not available');
|
||||
}
|
||||
} else {
|
||||
$groups = DBA::selectToArray('group', [], ['deleted' => false, 'uid' => $uid]);
|
||||
$circles = DBA::selectToArray('group', [], ['deleted' => false, 'uid' => $uid]);
|
||||
}
|
||||
|
||||
// loop through all groups and retrieve all members for adding data in the user array
|
||||
// loop through all circles and retrieve all members for adding data in the user array
|
||||
$grps = [];
|
||||
foreach ($groups as $rr) {
|
||||
$members = Contact\Group::getById($rr['id']);
|
||||
foreach ($circles as $circle) {
|
||||
$members = Contact\Circle::getById($circle['id']);
|
||||
$users = [];
|
||||
|
||||
if ($type == 'xml') {
|
||||
|
@ -71,7 +72,7 @@ class Show extends BaseApi
|
|||
$users[] = DI::twitterUser()->createFromContactId($member['contact-id'], $uid, true)->toArray();
|
||||
}
|
||||
}
|
||||
$grps[] = ['name' => $rr['name'], 'gid' => $rr['id'], $user_element => $users];
|
||||
$grps[] = ['name' => $circle['name'], 'gid' => $circle['id'], $user_element => $users];
|
||||
}
|
||||
|
||||
$this->response->exit('group_update', ['group' => $grps], $this->parameters['extension'] ?? null);
|
|
@ -19,15 +19,16 @@
|
|||
*
|
||||
*/
|
||||
|
||||
namespace Friendica\Module\Api\Friendica\Group;
|
||||
namespace Friendica\Module\Api\Friendica\Circle;
|
||||
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Group;
|
||||
use Friendica\Model\Circle;
|
||||
use Friendica\Module\BaseApi;
|
||||
use Friendica\Network\HTTPException\BadRequestException;
|
||||
|
||||
/**
|
||||
* API endpoint: /api/friendica/circle_update
|
||||
* API endpoint: /api/friendica/group_update
|
||||
*/
|
||||
class Update extends BaseApi
|
||||
|
@ -45,7 +46,7 @@ class Update extends BaseApi
|
|||
|
||||
// error if no name specified
|
||||
if (!$name) {
|
||||
throw new BadRequestException('group name not specified');
|
||||
throw new BadRequestException('circle name not specified');
|
||||
}
|
||||
|
||||
// error if no gid specified
|
||||
|
@ -54,15 +55,15 @@ class Update extends BaseApi
|
|||
}
|
||||
|
||||
// remove members
|
||||
$members = Contact\Group::getById($gid);
|
||||
$members = Contact\Circle::getById($gid);
|
||||
foreach ($members as $member) {
|
||||
$cid = $member['id'];
|
||||
foreach ($users as $user) {
|
||||
$found = $user['cid'] == $cid;
|
||||
}
|
||||
if (!isset($found) || !$found) {
|
||||
$gid = Group::getIdByName($uid, $name);
|
||||
Group::removeMember($gid, $cid);
|
||||
$gid = Circle::getIdByName($uid, $name);
|
||||
Circle::removeMember($gid, $cid);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -73,7 +74,7 @@ class Update extends BaseApi
|
|||
$cid = $user['cid'];
|
||||
|
||||
if (DBA::exists('contact', ['id' => $cid, 'uid' => $uid])) {
|
||||
Group::addMember($gid, $cid);
|
||||
Circle::addMember($gid, $cid);
|
||||
} else {
|
||||
$erroraddinguser = true;
|
||||
$errorusers[] = $cid;
|
|
@ -53,9 +53,9 @@ class Create extends BaseApi
|
|||
'place' => '', //location of the event
|
||||
'publish' => 0, //publish message
|
||||
'allow_cid' => '', //array of allowed person, if access restricted
|
||||
'allow_gid' => '', //array of allowed groups, if access restricted
|
||||
'allow_gid' => '', //array of allowed circles, if access restricted
|
||||
'deny_cid' => '', //array of denied person, if access restricted
|
||||
'deny_gid' => '', //array of denied groups, if access restricted
|
||||
'deny_gid' => '', //array of denied circles, if access restricted
|
||||
], $request);
|
||||
|
||||
// error if no name specified
|
||||
|
|
|
@ -78,8 +78,8 @@ class Create extends BaseApi
|
|||
$acl_input_error = false;
|
||||
$acl_input_error |= !ACL::isValidContact($allow_cid, $uid);
|
||||
$acl_input_error |= !ACL::isValidContact($deny_cid, $uid);
|
||||
$acl_input_error |= !ACL::isValidGroup($allow_gid, $uid);
|
||||
$acl_input_error |= !ACL::isValidGroup($deny_gid, $uid);
|
||||
$acl_input_error |= !ACL::isValidCircle($allow_gid, $uid);
|
||||
$acl_input_error |= !ACL::isValidCircle($deny_gid, $uid);
|
||||
if ($acl_input_error) {
|
||||
throw new HTTPException\BadRequestException('acl data invalid');
|
||||
}
|
||||
|
|
|
@ -79,8 +79,8 @@ class Update extends BaseApi
|
|||
$acl_input_error = false;
|
||||
$acl_input_error |= !ACL::isValidContact($allow_cid, $uid);
|
||||
$acl_input_error |= !ACL::isValidContact($deny_cid, $uid);
|
||||
$acl_input_error |= !ACL::isValidGroup($allow_gid, $uid);
|
||||
$acl_input_error |= !ACL::isValidGroup($deny_gid, $uid);
|
||||
$acl_input_error |= !ACL::isValidCircle($allow_gid, $uid);
|
||||
$acl_input_error |= !ACL::isValidCircle($deny_gid, $uid);
|
||||
if ($acl_input_error) {
|
||||
throw new HTTPException\BadRequestException('acl data invalid');
|
||||
}
|
||||
|
|
|
@ -53,11 +53,11 @@ class Lists extends BaseApi
|
|||
|
||||
$cdata = Contact::getPublicAndUserContactID($id, $uid);
|
||||
if (!empty($cdata['user'])) {
|
||||
$groups = DBA::select('group_member', ['gid'], ['contact-id' => $cdata['user']]);
|
||||
while ($group = DBA::fetch($groups)) {
|
||||
$lists[] = DI::mstdnList()->createFromGroupId($group['gid']);
|
||||
$circles = DBA::select('group_member', ['gid'], ['contact-id' => $cdata['user']]);
|
||||
while ($circle = DBA::fetch($circles)) {
|
||||
$lists[] = DI::mstdnList()->createFromCircleId($circle['gid']);
|
||||
}
|
||||
DBA::close($groups);
|
||||
DBA::close($circles);
|
||||
}
|
||||
|
||||
System::jsonExit($lists);
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace Friendica\Module\Api\Mastodon;
|
|||
use Friendica\Core\System;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\BaseApi;
|
||||
use Friendica\Model\Group;
|
||||
use Friendica\Model\Circle;
|
||||
|
||||
/**
|
||||
* @see https://docs.joinmastodon.org/methods/timelines/lists/
|
||||
|
@ -40,11 +40,11 @@ class Lists extends BaseApi
|
|||
DI::mstdnError()->UnprocessableEntity();
|
||||
}
|
||||
|
||||
if (!Group::exists($this->parameters['id'], $uid)) {
|
||||
if (!Circle::exists($this->parameters['id'], $uid)) {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
}
|
||||
|
||||
if (!Group::remove($this->parameters['id'])) {
|
||||
if (!Circle::remove($this->parameters['id'])) {
|
||||
DI::mstdnError()->InternalError();
|
||||
}
|
||||
|
||||
|
@ -64,14 +64,14 @@ class Lists extends BaseApi
|
|||
DI::mstdnError()->UnprocessableEntity();
|
||||
}
|
||||
|
||||
Group::create($uid, $request['title']);
|
||||
Circle::create($uid, $request['title']);
|
||||
|
||||
$id = Group::getIdByName($uid, $request['title']);
|
||||
$id = Circle::getIdByName($uid, $request['title']);
|
||||
if (!$id) {
|
||||
DI::mstdnError()->InternalError();
|
||||
}
|
||||
|
||||
System::jsonExit(DI::mstdnList()->createFromGroupId($id));
|
||||
System::jsonExit(DI::mstdnList()->createFromCircleId($id));
|
||||
}
|
||||
|
||||
public function put(array $request = [])
|
||||
|
@ -85,7 +85,7 @@ class Lists extends BaseApi
|
|||
DI::mstdnError()->UnprocessableEntity();
|
||||
}
|
||||
|
||||
Group::update($this->parameters['id'], $request['title']);
|
||||
Circle::update($this->parameters['id'], $request['title']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -99,18 +99,16 @@ class Lists extends BaseApi
|
|||
if (empty($this->parameters['id'])) {
|
||||
$lists = [];
|
||||
|
||||
$groups = Group::getByUserId($uid);
|
||||
|
||||
foreach ($groups as $group) {
|
||||
$lists[] = DI::mstdnList()->createFromGroupId($group['id']);
|
||||
foreach (Circle::getByUserId($uid) as $circle) {
|
||||
$lists[] = DI::mstdnList()->createFromCircleId($circle['id']);
|
||||
}
|
||||
} else {
|
||||
$id = $this->parameters['id'];
|
||||
|
||||
if (!Group::exists($id, $uid)) {
|
||||
if (!Circle::exists($id, $uid)) {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
}
|
||||
$lists = DI::mstdnList()->createFromGroupId($id);
|
||||
$lists = DI::mstdnList()->createFromCircleId($id);
|
||||
}
|
||||
|
||||
System::jsonExit($lists);
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace Friendica\Module\Api\Mastodon\Lists;
|
|||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Group;
|
||||
use Friendica\Model\Circle;
|
||||
use Friendica\Module\BaseApi;
|
||||
|
||||
/**
|
||||
|
@ -46,7 +46,7 @@ class Accounts extends BaseApi
|
|||
DI::mstdnError()->UnprocessableEntity();
|
||||
}
|
||||
|
||||
return Group::removeMembers($this->parameters['id'], $request['account_ids']);
|
||||
return Circle::removeMembers($this->parameters['id'], $request['account_ids']);
|
||||
}
|
||||
|
||||
protected function post(array $request = [])
|
||||
|
@ -61,7 +61,7 @@ class Accounts extends BaseApi
|
|||
DI::mstdnError()->UnprocessableEntity();
|
||||
}
|
||||
|
||||
Group::addMembers($this->parameters['id'], $request['account_ids']);
|
||||
Circle::addMembers($this->parameters['id'], $request['account_ids']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -30,7 +30,7 @@ use Friendica\Core\Worker;
|
|||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Group;
|
||||
use Friendica\Model\Circle;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Photo;
|
||||
use Friendica\Model\Post;
|
||||
|
@ -230,7 +230,7 @@ class Statuses extends BaseApi
|
|||
$item['deny_gid'] = $owner['deny_gid'];
|
||||
} else {
|
||||
$item['allow_cid'] = '';
|
||||
$item['allow_gid'] = '<' . Group::FOLLOWERS . '>';
|
||||
$item['allow_gid'] = '<' . Circle::FOLLOWERS . '>';
|
||||
$item['deny_cid'] = '';
|
||||
$item['deny_gid'] = '';
|
||||
}
|
||||
|
@ -241,7 +241,7 @@ class Statuses extends BaseApi
|
|||
// The permissions are assigned in "expandTags"
|
||||
break;
|
||||
default:
|
||||
if (is_numeric($request['visibility']) && Group::exists($request['visibility'], $uid)) {
|
||||
if (is_numeric($request['visibility']) && Circle::exists($request['visibility'], $uid)) {
|
||||
$item['allow_cid'] = '';
|
||||
$item['allow_gid'] = '<' . $request['visibility'] . '>';
|
||||
$item['deny_cid'] = '';
|
||||
|
|
|
@ -24,34 +24,34 @@ namespace Friendica\Module\Api\Twitter\Lists;
|
|||
use Friendica\App;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Factory\Api\Friendica\Group as FriendicaGroup;
|
||||
use Friendica\Factory\Api\Friendica\Circle as FriendicaCircle;
|
||||
use Friendica\Module\BaseApi;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Group;
|
||||
use Friendica\Model\Circle;
|
||||
use Friendica\Module\Api\ApiResponse;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Util\Profiler;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* Update information about a group.
|
||||
* Update information about a circle.
|
||||
*
|
||||
* @see https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/post-lists-update
|
||||
*/
|
||||
class Create extends BaseApi
|
||||
{
|
||||
/** @var friendicaGroup */
|
||||
private $friendicaGroup;
|
||||
/** @var FriendicaCircle */
|
||||
private $friendicaCircle;
|
||||
|
||||
/** @var Database */
|
||||
private $dba;
|
||||
|
||||
public function __construct(Database $dba, FriendicaGroup $friendicaGroup, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = [])
|
||||
public function __construct(Database $dba, FriendicaCircle $friendicaCircle, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = [])
|
||||
{
|
||||
parent::__construct($app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
|
||||
|
||||
$this->dba = $dba;
|
||||
$this->friendicaGroup = $friendicaGroup;
|
||||
$this->dba = $dba;
|
||||
$this->friendicaCircle = $friendicaCircle;
|
||||
}
|
||||
|
||||
protected function rawContent(array $request = [])
|
||||
|
@ -63,22 +63,22 @@ class Create extends BaseApi
|
|||
$name = $this->getRequestValue($request, 'name', '');
|
||||
|
||||
if ($name == '') {
|
||||
throw new HTTPException\BadRequestException('group name not specified');
|
||||
throw new HTTPException\BadRequestException('circle name not specified');
|
||||
}
|
||||
|
||||
// error message if specified group name already exists
|
||||
// error message if specified circle name already exists
|
||||
if ($this->dba->exists('group', ['uid' => $uid, 'name' => $name, 'deleted' => false])) {
|
||||
throw new HTTPException\BadRequestException('group name already exists');
|
||||
throw new HTTPException\BadRequestException('circle name already exists');
|
||||
}
|
||||
|
||||
$ret = Group::create($uid, $name);
|
||||
$ret = Circle::create($uid, $name);
|
||||
if ($ret) {
|
||||
$gid = Group::getIdByName($uid, $name);
|
||||
$gid = Circle::getIdByName($uid, $name);
|
||||
} else {
|
||||
throw new HTTPException\BadRequestException('other API error');
|
||||
}
|
||||
|
||||
$grp = $this->friendicaGroup->createFromId($gid);
|
||||
$grp = $this->friendicaCircle->createFromId($gid);
|
||||
|
||||
$this->response->exit('statuses', ['lists' => ['lists' => $grp]], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
}
|
||||
|
|
|
@ -24,34 +24,34 @@ namespace Friendica\Module\Api\Twitter\Lists;
|
|||
use Friendica\App;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Factory\Api\Friendica\Group as FriendicaGroup;
|
||||
use Friendica\Factory\Api\Friendica\Circle as FriendicaCirle;
|
||||
use Friendica\Module\BaseApi;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Group;
|
||||
use Friendica\Model\Circle;
|
||||
use Friendica\Module\Api\ApiResponse;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Util\Profiler;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* Delete a group.
|
||||
* Delete a circle.
|
||||
*
|
||||
* @see https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/post-lists-destroy
|
||||
*/
|
||||
class Destroy extends BaseApi
|
||||
{
|
||||
/** @var friendicaGroup */
|
||||
private $friendicaGroup;
|
||||
/** @var FriendicaCirle */
|
||||
private $friendicaCircle;
|
||||
|
||||
/** @var Database */
|
||||
private $dba;
|
||||
|
||||
public function __construct(Database $dba, FriendicaGroup $friendicaGroup, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = [])
|
||||
public function __construct(Database $dba, FriendicaCirle $friendicaCircle, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = [])
|
||||
{
|
||||
parent::__construct($app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
|
||||
|
||||
$this->dba = $dba;
|
||||
$this->friendicaGroup = $friendicaGroup;
|
||||
$this->dba = $dba;
|
||||
$this->friendicaCircle = $friendicaCircle;
|
||||
}
|
||||
|
||||
protected function rawContent(array $request = [])
|
||||
|
@ -67,16 +67,16 @@ class Destroy extends BaseApi
|
|||
throw new HTTPException\BadRequestException('gid not specified');
|
||||
}
|
||||
|
||||
// get data of the specified group id
|
||||
$group = $this->dba->selectFirst('group', [], ['uid' => $uid, 'id' => $gid]);
|
||||
// get data of the specified circle id
|
||||
$circle = $this->dba->selectFirst('group', [], ['uid' => $uid, 'id' => $gid]);
|
||||
// error message if specified gid is not in database
|
||||
if (!$group) {
|
||||
if (!$circle) {
|
||||
throw new HTTPException\BadRequestException('gid not available');
|
||||
}
|
||||
|
||||
$list = $this->friendicaGroup->createFromId($gid);
|
||||
$list = $this->friendicaCircle->createFromId($gid);
|
||||
|
||||
if (Group::remove($gid)) {
|
||||
if (Circle::remove($gid)) {
|
||||
$this->response->exit('statuses', ['lists' => ['lists' => $list]], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace Friendica\Module\Api\Twitter\Lists;
|
|||
use Friendica\App;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Factory\Api\Friendica\Group as FriendicaGroup;
|
||||
use Friendica\Factory\Api\Friendica\Circle as FriendicaCircle;
|
||||
use Friendica\Module\BaseApi;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Module\Api\ApiResponse;
|
||||
|
@ -32,36 +32,36 @@ use Friendica\Util\Profiler;
|
|||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* Returns all groups the user owns.
|
||||
* Returns all circles the user owns.
|
||||
*
|
||||
* @see https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/get-lists-ownerships
|
||||
*/
|
||||
class Ownership extends BaseApi
|
||||
{
|
||||
/** @var friendicaGroup */
|
||||
private $friendicaGroup;
|
||||
/** @var FriendicaCircle */
|
||||
private $friendicaCircle;
|
||||
|
||||
/** @var Database */
|
||||
private $dba;
|
||||
|
||||
public function __construct(Database $dba, FriendicaGroup $friendicaGroup, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = [])
|
||||
public function __construct(Database $dba, FriendicaCircle $friendicaCircle, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = [])
|
||||
{
|
||||
parent::__construct($app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
|
||||
|
||||
$this->dba = $dba;
|
||||
$this->friendicaGroup = $friendicaGroup;
|
||||
$this->dba = $dba;
|
||||
$this->friendicaCircle = $friendicaCircle;
|
||||
}
|
||||
protected function rawContent(array $request = [])
|
||||
{
|
||||
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
|
||||
$uid = BaseApi::getCurrentUserID();
|
||||
|
||||
$groups = $this->dba->select('group', [], ['deleted' => false, 'uid' => $uid, 'cid' => null]);
|
||||
$circles = $this->dba->select('group', [], ['deleted' => false, 'uid' => $uid, 'cid' => null]);
|
||||
|
||||
// loop through all groups
|
||||
// loop through all circles
|
||||
$lists = [];
|
||||
foreach ($groups as $group) {
|
||||
$lists[] = $this->friendicaGroup->createFromId($group['id']);
|
||||
foreach ($circles as $circle) {
|
||||
$lists[] = $this->friendicaCircle->createFromId($circle['id']);
|
||||
}
|
||||
|
||||
$this->response->exit('statuses', ['lists' => ['lists' => $lists]], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
|
|
|
@ -36,7 +36,7 @@ use Friendica\Util\Profiler;
|
|||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* Returns recent statuses from users in the specified group.
|
||||
* Returns recent statuses from users in the specified circle.
|
||||
*
|
||||
* @see https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/get-lists-ownerships
|
||||
*/
|
||||
|
@ -76,9 +76,9 @@ class Statuses extends BaseApi
|
|||
|
||||
$start = max(0, ($page - 1) * $count);
|
||||
|
||||
$groups = $this->dba->selectToArray('group_member', ['contact-id'], ['gid' => $request['list_id']]);
|
||||
$gids = array_column($groups, 'contact-id');
|
||||
$condition = ['uid' => $uid, 'gravity' => [Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT], 'contact-id' => $gids];
|
||||
$members = $this->dba->selectToArray('group_member', ['contact-id'], ['gid' => $request['list_id']]);
|
||||
$cids = array_column($members, 'contact-id');
|
||||
$condition = ['uid' => $uid, 'gravity' => [Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT], 'contact-id' => $cids];
|
||||
$condition = DBA::mergeConditions($condition, ["`uri-id` > ?", $since_id]);
|
||||
|
||||
if ($max_id > 0) {
|
||||
|
|
|
@ -24,34 +24,34 @@ namespace Friendica\Module\Api\Twitter\Lists;
|
|||
use Friendica\App;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Factory\Api\Friendica\Group as FriendicaGroup;
|
||||
use Friendica\Factory\Api\Friendica\Circle as FriendicaCircle;
|
||||
use Friendica\Module\BaseApi;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Group;
|
||||
use Friendica\Model\Circle;
|
||||
use Friendica\Module\Api\ApiResponse;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Util\Profiler;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* Update information about a group.
|
||||
* Update information about a circle.
|
||||
*
|
||||
* @see https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/post-lists-update
|
||||
*/
|
||||
class Update extends BaseApi
|
||||
{
|
||||
/** @var friendicaGroup */
|
||||
private $friendicaGroup;
|
||||
/** @var FriendicaCircle */
|
||||
private $friendicaCircle;
|
||||
|
||||
/** @var Database */
|
||||
private $dba;
|
||||
|
||||
public function __construct(Database $dba, FriendicaGroup $friendicaGroup, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = [])
|
||||
public function __construct(Database $dba, FriendicaCircle $friendicaCircle, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = [])
|
||||
{
|
||||
parent::__construct($app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
|
||||
|
||||
$this->dba = $dba;
|
||||
$this->friendicaGroup = $friendicaGroup;
|
||||
$this->dba = $dba;
|
||||
$this->friendicaCircle = $friendicaCircle;
|
||||
}
|
||||
|
||||
protected function rawContent(array $request = [])
|
||||
|
@ -68,15 +68,15 @@ class Update extends BaseApi
|
|||
throw new HTTPException\BadRequestException('gid not specified');
|
||||
}
|
||||
|
||||
// get data of the specified group id
|
||||
$group = $this->dba->selectFirst('group', [], ['uid' => $uid, 'id' => $gid]);
|
||||
// get data of the specified circle id
|
||||
$circle = $this->dba->selectFirst('group', [], ['uid' => $uid, 'id' => $gid]);
|
||||
// error message if specified gid is not in database
|
||||
if (!$group) {
|
||||
if (!$circle) {
|
||||
throw new HTTPException\BadRequestException('gid not available');
|
||||
}
|
||||
|
||||
if (Group::update($gid, $name)) {
|
||||
$list = $this->friendicaGroup->createFromId($gid);
|
||||
if (Circle::update($gid, $name)) {
|
||||
$list = $this->friendicaCircle->createFromId($gid);
|
||||
|
||||
$this->response->exit('statuses', ['lists' => ['lists' => $list]], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
}
|
||||
|
|
|
@ -62,9 +62,9 @@ class Update extends BaseApi
|
|||
'source' => '',
|
||||
'include_entities' => false,
|
||||
'contact_allow' => $owner['allow_cid'],
|
||||
'group_allow' => $owner['allow_gid'],
|
||||
'circle_allow' => $owner['allow_gid'],
|
||||
'contact_deny' => $owner['deny_cid'],
|
||||
'group_deny' => $owner['deny_gid'],
|
||||
'circle_deny' => $owner['deny_gid'],
|
||||
], $request);
|
||||
|
||||
if (!empty($request['htmlstatus'])) {
|
||||
|
@ -102,9 +102,9 @@ class Update extends BaseApi
|
|||
|
||||
$aclFormatter = DI::aclFormatter();
|
||||
$item['allow_cid'] = $aclFormatter->toString($request['contact_allow']);
|
||||
$item['allow_gid'] = $aclFormatter->toString($request['group_allow']);
|
||||
$item['allow_gid'] = $aclFormatter->toString($request['circle_allow']);
|
||||
$item['deny_cid'] = $aclFormatter->toString($request['contact_deny']);
|
||||
$item['deny_gid'] = $aclFormatter->toString($request['group_deny']);
|
||||
$item['deny_gid'] = $aclFormatter->toString($request['circle_deny']);
|
||||
|
||||
if (!empty($item['allow_cid'] . $item['allow_gid'] . $item['deny_cid'] . $item['deny_gid'])) {
|
||||
$item['private'] = Item::PRIVATE;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue