VKAPI: Join/leave group

This commit is contained in:
veselcraft 2022-11-06 16:06:57 +03:00
parent aaf24b166e
commit ab51482558
No known key found for this signature in database
GPG key ID: AED66BC1AC628A4E

View file

@ -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;
}
}