fixed poll parsing

This commit is contained in:
Max Nuding 2025-05-20 19:46:05 +02:00
parent 5d009163f0
commit 56078fabad
Signed by: phlaym
SSH Key Fingerprint: SHA256:mionmF+5trOUI1AxqzAU1ZK3tv6IiDcdKGXcMWwa1nQ

View File

@ -521,27 +521,21 @@ class APnutI
return []; return [];
} }
$polls = []; $polls = [];
$this->logger->debug('Parsing ' . count($response) . 'results'); $this->logger->debug('Parsing ' . count($response) . ' results');
foreach ($response as $post) { foreach ($response as $post) {
if (!empty($post['raw'])) { if (!empty($post['raw'])) {
foreach ($post['raw'] as $raw) { foreach ($post['raw'] as $raw_type => $raw) {
if (!empty($raw[Poll::$notice_type])) { if ($raw_type === Poll::$notice_type) {
try { try {
$this->logger->debug('Parsing poll from raw'); $this->logger->debug('Parsing poll from raw', $raw);
$polls[] = new Poll($raw, $this); /*$data = ['raw' => [
Poll::$notice_type => $raw
]];*/
$polls[] = new Poll($post, $this);
} catch (NotSupportedPollException) { } catch (NotSupportedPollException) {
$this->logger->warning('Parsing poll from raw failed. Loading from poll id'); $this->logger->warning('Parsing poll from raw failed. Loading from poll id');
$polls[] = $this->getPoll($raw[Poll::$notice_type]['poll_id']); $polls[] = $this->getPoll($raw[Poll::$notice_type]['poll_id']);
} }
// if (empty($raw[Poll::$notice_type]['prompt'])) {
// $polls[] = $this->getPoll($raw[Poll::$notice_type]['poll_id']);
// } else {
// /*$poll_parsing_data = [
// 'type' => Poll::$notice_type,
// 'value' => $raw[Poll::$notice_type]
// ];*/
// $polls[] = new Poll($raw, $this);
// }
} }
} }
} }