Browse Source

remove meta key/values markup (by new protocol)

main
ghost 9 months ago
parent
commit
ae32370f44
  1. 19
      src/controller/room.php

19
src/controller/room.php

@ -12,6 +12,8 @@ class Room
private \Yggverse\Cache\Memory $_memory; private \Yggverse\Cache\Memory $_memory;
private \PDO $_database; private \PDO $_database;
private const PARENT_REGEX = '/^[>@]?([A-f0-9]{64})\s/i';
public function __construct($config) public function __construct($config)
{ {
// Init memory // Init memory
@ -351,7 +353,7 @@ class Room
// Append mention if provided // Append mention if provided
if ($mention) if ($mention)
{ {
$message = '@' . $mention . PHP_EOL . $message; $message = $mention . PHP_EOL . $message;
} }
// Validate final message length // Validate final message length
@ -402,7 +404,7 @@ class Room
$this->_config->kevachat->post->pool->account $this->_config->kevachat->post->pool->account
), ),
':namespace' => $namespace, ':namespace' => $namespace,
':key' => sprintf('%s@anon', $time), ':key' => 'anon',
':value' => $message ':value' => $message
] ]
); );
@ -426,10 +428,7 @@ class Room
// Make blockchain record // Make blockchain record
return $this->_kevacoin->kevaPut( return $this->_kevacoin->kevaPut(
$namespace, $namespace,
sprintf( 'anon',
'%s@anon',
time()
),
$message $message
); );
} }
@ -556,7 +555,7 @@ class Room
// Try to find related quote value // Try to find related quote value
$quote = null; $quote = null;
if (preg_match('/^@([A-z0-9]{64})/', $data['value'], $mention)) if (preg_match(self::PARENT_REGEX, $data['value'], $mention))
{ {
// Message starts with mention // Message starts with mention
if (!empty($mention[1])) if (!empty($mention[1]))
@ -585,7 +584,7 @@ class Room
// Remove original mention from message // Remove original mention from message
$data['value'] = preg_replace( $data['value'] = preg_replace(
'/^@([A-z0-9]{64})/', self::PARENT_REGEX,
null, null,
$this->_escape( $this->_escape(
$data['value'] $data['value']
@ -670,7 +669,7 @@ class Room
), ),
// author // author
'@' . $matches[2], $matches[2],
// quote // quote
$quote, $quote,
@ -861,7 +860,7 @@ class Room
// Remove mention ID from quote // Remove mention ID from quote
$value = preg_replace( $value = preg_replace(
'/^@([A-z0-9]{64})/', self::PARENT_REGEX,
null, null,
$this->_escape( $this->_escape(
$value $value

Loading…
Cancel
Save