mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Allow setting event parameters as sensitive
This commit is contained in:
@@ -590,7 +590,7 @@ App::shutdown()
|
||||
|
||||
Realtime::send(
|
||||
projectId: $target['projectId'] ?? $project->getId(),
|
||||
payload: $queueForEvents->getPayload(),
|
||||
payload: $queueForEvents->getRealtimePayload(),
|
||||
events: $allEvents,
|
||||
channels: $target['channels'],
|
||||
roles: $target['roles'],
|
||||
|
||||
@@ -52,6 +52,7 @@ class Event
|
||||
protected string $class = '';
|
||||
protected string $event = '';
|
||||
protected array $params = [];
|
||||
protected array $sensitive = [];
|
||||
protected array $payload = [];
|
||||
protected array $context = [];
|
||||
protected ?Document $project = null;
|
||||
@@ -161,12 +162,17 @@ class Event
|
||||
* Set payload for this event.
|
||||
*
|
||||
* @param array $payload
|
||||
* @param array $sensitive
|
||||
* @return self
|
||||
*/
|
||||
public function setPayload(array $payload): self
|
||||
public function setPayload(array $payload, array $sensitive = []): self
|
||||
{
|
||||
$this->payload = $payload;
|
||||
|
||||
foreach ($sensitive as $key) {
|
||||
$this->sensitive[$key] = true;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -180,6 +186,19 @@ class Event
|
||||
return $this->payload;
|
||||
}
|
||||
|
||||
public function getRealtimePayload(): array
|
||||
{
|
||||
$payload = [];
|
||||
|
||||
foreach ($this->payload as $key => $value) {
|
||||
if (!isset($this->sensitive[$key])) {
|
||||
$payload[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $payload;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set context for this event.
|
||||
*
|
||||
@@ -242,6 +261,13 @@ class Event
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setParamSensitive(string $key): self
|
||||
{
|
||||
$this->sensitive[$key] = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get param of event.
|
||||
*
|
||||
@@ -294,6 +320,7 @@ class Event
|
||||
public function reset(): self
|
||||
{
|
||||
$this->params = [];
|
||||
$this->sensitive = [];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user