Added canVote() to poll
This commit is contained in:
parent
e639234a95
commit
d3f85ad779
@ -328,7 +328,7 @@ class APnutI
|
||||
}
|
||||
|
||||
//TODO: Ping server and validate token
|
||||
public function isAuthenticated(bool $allow_server_token = false): bool
|
||||
public function isAuthenticated(bool $allow_server_token = false, bool $skip_verify_token = false): bool
|
||||
{
|
||||
$is_authenticated = ($allow_server_token && !empty($this->server_token))
|
||||
|| isset($this->access_token);
|
||||
|
@ -122,6 +122,13 @@ class Poll
|
||||
return $type === Poll::$notice_type || in_array($type, Poll::$poll_types);
|
||||
}
|
||||
|
||||
public function canVote()
|
||||
{
|
||||
$is_authenticated = $this->api->isAuthenticated(false, true);
|
||||
$is_closed = $this->closed_at >= new \DateTime();
|
||||
return $is_authenticated && !$is_closed;
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
if (!empty($this->user)) {
|
||||
|
Loading…
Reference in New Issue
Block a user