mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
fix: event validator
This commit is contained in:
@@ -87,11 +87,14 @@ class Event extends Validator
|
||||
}
|
||||
|
||||
if ($attribute ?? false) {
|
||||
if (
|
||||
!\array_key_exists($attribute, $events[$type][$action]) ||
|
||||
(($subType ?? false) && !\array_key_exists($attribute, $events[$type][$subType][$action]))
|
||||
) {
|
||||
return false;
|
||||
if (($subType ?? false)) {
|
||||
if (!\array_key_exists($attribute, $events[$type][$subType][$action])) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!\array_key_exists($attribute, $events[$type][$action])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ class EventValidatorTest extends TestCase
|
||||
$this->assertTrue($this->object->isValid('buckets.*'));
|
||||
$this->assertTrue($this->object->isValid('teams.*'));
|
||||
$this->assertTrue($this->object->isValid('users.*'));
|
||||
$this->assertTrue($this->object->isValid('teams.*.memberships.*.update.status'));
|
||||
|
||||
/**
|
||||
* Test for FAILURE
|
||||
@@ -57,5 +58,6 @@ class EventValidatorTest extends TestCase
|
||||
$this->assertFalse($this->object->isValid('collections.*.documents.*.unknown'));
|
||||
$this->assertFalse($this->object->isValid('users.torsten.unknown'));
|
||||
$this->assertFalse($this->object->isValid('users.torsten.delete.email'));
|
||||
$this->assertFalse($this->object->isValid('teams.*.memberships.*.update.unknown'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user