mirror of
https://github.com/openvk/openvk
synced 2024-12-22 16:42:32 +03:00
VKAPI: Join/leave group
This commit is contained in:
parent
aaf24b166e
commit
ab51482558
1 changed files with 28 additions and 0 deletions
|
@ -233,4 +233,32 @@ final class Groups extends VKAPIRequestHandler
|
|||
*/
|
||||
];
|
||||
}
|
||||
|
||||
function join(int $group_id)
|
||||
{
|
||||
$this->requireUser();
|
||||
|
||||
$club = (new ClubsRepo)->get($group_id);
|
||||
|
||||
$isMember = !is_null($this->getUser()) ? (int) $club->getSubscriptionStatus($this->getUser()) : 0;
|
||||
|
||||
if($isMember == 0)
|
||||
$club->toggleSubscription($this->getUser());
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
function leave(int $group_id)
|
||||
{
|
||||
$this->requireUser();
|
||||
|
||||
$club = (new ClubsRepo)->get($group_id);
|
||||
|
||||
$isMember = !is_null($this->getUser()) ? (int) $club->getSubscriptionStatus($this->getUser()) : 0;
|
||||
|
||||
if($isMember == 1)
|
||||
$club->toggleSubscription($this->getUser());
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue