|
|
@ -97,23 +97,18 @@ class RoomController extends AbstractController |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Get more info |
|
|
|
// Require valid kevachat meta |
|
|
|
if ($transaction = $client->getRawTransaction($pending['txid'])) |
|
|
|
if ($data = $this->_post($pending)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$feed[] = |
|
|
|
$feed[] = |
|
|
|
[ |
|
|
|
[ |
|
|
|
'pending' => true, |
|
|
|
'id' => $data->id, |
|
|
|
'key' => $pending['key'], |
|
|
|
'user' => $data->user, |
|
|
|
'value' => $pending['value'], |
|
|
|
'icon' => $data->icon, |
|
|
|
'txid' => $pending['txid'], |
|
|
|
'message' => $data->message, |
|
|
|
'transaction' => |
|
|
|
'timestamp' => $data->time, |
|
|
|
[ |
|
|
|
'time' => date('c', $data->time), |
|
|
|
'time' => date('c', $transaction['time']), |
|
|
|
'pending' => true |
|
|
|
'timestamp' => $transaction['time'], |
|
|
|
|
|
|
|
'confirmations' => $transaction['confirmations'], |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
'icon' => $this->_identicon($pending['key']), |
|
|
|
|
|
|
|
'sort' => 0//$transaction['time'] // sort order field |
|
|
|
|
|
|
|
]; |
|
|
|
]; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -127,25 +122,18 @@ class RoomController extends AbstractController |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Get more info |
|
|
|
// Require valid kevachat meta |
|
|
|
if ($transaction = $client->getRawTransaction($post['txid'])) |
|
|
|
if ($data = $this->_post($post)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$feed[] = |
|
|
|
$feed[] = |
|
|
|
[ |
|
|
|
[ |
|
|
|
'pending' => false, |
|
|
|
'id' => $data->id, |
|
|
|
'key' => $post['key'], |
|
|
|
'user' => $data->user, |
|
|
|
'value' => $post['value'], |
|
|
|
'icon' => $data->icon, |
|
|
|
'height' => $post['height'], |
|
|
|
'message' => $data->message, |
|
|
|
# 'vout' => $post['vout'], |
|
|
|
'timestamp' => $data->time, |
|
|
|
'txid' => $post['txid'], |
|
|
|
'time' => date('c', $data->time), |
|
|
|
'transaction' => |
|
|
|
'pending' => false |
|
|
|
[ |
|
|
|
|
|
|
|
'time' => date('c', $transaction['time']), |
|
|
|
|
|
|
|
'timestamp' => $transaction['time'], |
|
|
|
|
|
|
|
'confirmations' => $transaction['confirmations'], |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
'icon' => $this->_identicon($post['key']), |
|
|
|
|
|
|
|
'sort' => $transaction['time'] // sort order field |
|
|
|
|
|
|
|
]; |
|
|
|
]; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -154,7 +142,7 @@ class RoomController extends AbstractController |
|
|
|
array_multisort( |
|
|
|
array_multisort( |
|
|
|
array_column( |
|
|
|
array_column( |
|
|
|
$feed, |
|
|
|
$feed, |
|
|
|
'sort' |
|
|
|
'time' |
|
|
|
), |
|
|
|
), |
|
|
|
SORT_DESC, |
|
|
|
SORT_DESC, |
|
|
|
$feed |
|
|
|
$feed |
|
|
@ -354,7 +342,8 @@ class RoomController extends AbstractController |
|
|
|
$client->kevaPut( |
|
|
|
$client->kevaPut( |
|
|
|
$request->get('namespace'), |
|
|
|
$request->get('namespace'), |
|
|
|
sprintf( |
|
|
|
sprintf( |
|
|
|
'@%s', |
|
|
|
'%s@%s', |
|
|
|
|
|
|
|
time(), // @TODO save timestamp as part of key to keep timing actual for the chat feature |
|
|
|
$request->get('user') === 'ip' ? $request->getClientIp() : 'anonymous' |
|
|
|
$request->get('user') === 'ip' ? $request->getClientIp() : 'anonymous' |
|
|
|
), |
|
|
|
), |
|
|
|
$request->get('message') |
|
|
|
$request->get('message') |
|
|
@ -390,29 +379,53 @@ class RoomController extends AbstractController |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private function _identicon(string $key) |
|
|
|
private function _post(array $data): ?object |
|
|
|
{ |
|
|
|
{ |
|
|
|
if ($key === 'anonymous') |
|
|
|
if (false === preg_match('/^([\d]+)@(.*)$/', $data['key'], $matches)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return false; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
else |
|
|
|
if (empty($matches[1])) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$identicon = new \Jdenticon\Identicon(); |
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
$identicon->setValue($key); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$identicon->setSize(12); |
|
|
|
if (empty($matches[2])) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$identicon->setStyle( |
|
|
|
return (object) |
|
|
|
[ |
|
|
|
[ |
|
|
|
'backgroundColor' => 'rgba(255, 255, 255, 0)', |
|
|
|
'id' => $data['txid'], |
|
|
|
'padding' => 0 |
|
|
|
'time' => $matches[1], |
|
|
|
] |
|
|
|
'user' => $matches[2], |
|
|
|
); |
|
|
|
'icon' => $this->_identicon($matches[2]), |
|
|
|
|
|
|
|
'message' => $data['value'] |
|
|
|
|
|
|
|
]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return $identicon->getImageDataUri('webp'); |
|
|
|
private function _identicon(mixed $value): ?string |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if ($value === 'anonymous') |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$identicon = new \Jdenticon\Identicon(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$identicon->setValue($value); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$identicon->setSize(12); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$identicon->setStyle( |
|
|
|
|
|
|
|
[ |
|
|
|
|
|
|
|
'backgroundColor' => 'rgba(255, 255, 255, 0)', |
|
|
|
|
|
|
|
'padding' => 0 |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $identicon->getImageDataUri('webp'); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |