Apply suggestions

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak 2022-02-20 14:10:57 +01:00
parent 9c6f6bcb95
commit 0209892631
2 changed files with 7 additions and 1 deletions

View file

@ -358,14 +358,18 @@ class Group
throw new HTTPException\NotFoundException('Group not found.');
}
$contactIds = [];
foreach ($contacts as $cid) {
$cdata = Contact::getPublicAndUserContactID($cid, $group['uid']);
if (empty($cdata['user'])) {
throw new HTTPException\NotFoundException('Invalid contact.');
}
DBA::delete('group_member', ['gid' => $gid, 'contact-id' => $cdata['user']]);
$contactIds[] = $cdata['user'];
}
DBA::delete('group_member', ['gid' => $gid, 'contact-id' => $contactIds]);
}
/**

View file

@ -45,6 +45,7 @@ class Accounts extends BaseApi
if (empty($request['account_ids']) || empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
return Group::removeMembers($this->parameters['id'], $request['account_ids']);
}
@ -59,6 +60,7 @@ class Accounts extends BaseApi
if (empty($request['account_ids']) || empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
return Group::addMembers($this->parameters['id'], $request['account_ids']);
}