Page MenuHomeDevCentral

D122.id289.diff
No OneTemporary

D122.id289.diff

diff --git a/app/Events/PhabricatorPayloadEvent.php b/app/Events/PhabricatorPayloadEvent.php
--- a/app/Events/PhabricatorPayloadEvent.php
+++ b/app/Events/PhabricatorPayloadEvent.php
@@ -16,6 +16,17 @@
public $door;
/**
+ * The Phabricator instance
+ * @var string
+ */
+ protected $instance;
+
+ /**
+ * The raw payload
+ */
+ public $payload;
+
+ /**
* The story sent by the request
* @var PhabricatorStory
*/
@@ -28,14 +39,31 @@
public $projects;
/**
+ * Gets story from the request
+ *
+ * @param string $instance The Phabricator instance URL
+ * @return PhabricatorStory
+ */
+ protected function getStory () {
+ return PhabricatorStory::loadFromArray(
+ $this->instance,
+ $this->payload
+ );
+ }
+
+ /**
* Creates a new event instance.
*
* @param string $door
- * @param string $event
+ * @param string $instance The Phabricator instance URL
* @param stdClass $payload
*/
- public function __construct($door, PhabricatorStory $story) {
+ public function __construct($door, $instance, $payload) {
$this->door = $door;
+ $this->instance = $instance;
+ $this->payload = $payload;
+
+ $story = $this->getStory();
$this->story = $story;
$this->projects = $story->getProjects(); // Cost: up to 3 API calls
}
diff --git a/app/Http/Controllers/Gate/PhabricatorGateController.php b/app/Http/Controllers/Gate/PhabricatorGateController.php
--- a/app/Http/Controllers/Gate/PhabricatorGateController.php
+++ b/app/Http/Controllers/Gate/PhabricatorGateController.php
@@ -86,34 +86,19 @@
'service' => static::SERVICE_NAME,
'door' => $this->door
]);
- file_put_contents(
- storage_path('logs/payload.json'),
- json_encode($this->payload)
- );
}
///
/// Payload processing
///
- /**
- * Gets story from the request
- *
- * @return PhabricatorStory
- */
- protected function getStory () {
- return PhabricatorStory::loadFromArray(
- $this->instance,
- $this->payload
- );
- }
-
protected function onPayload () {
$this->initializeReport();
Event::fire(new PhabricatorPayloadEvent(
$this->door,
- $this->getStory()
+ $this->instance,
+ $this->payload
));
}
}
diff --git a/app/Listeners/LastPayloadSaver.php b/app/Listeners/LastPayloadSaver.php
--- a/app/Listeners/LastPayloadSaver.php
+++ b/app/Listeners/LastPayloadSaver.php
@@ -39,14 +39,16 @@
* @param Illuminate\Events\Dispatcher $events
*/
public function subscribe ($events) {
+ $ns = 'Nasqueron\Notifications\Events';
$class = 'Nasqueron\Notifications\Listeners\LastPayloadSaver';
- $events->listen(
- 'Nasqueron\Notifications\Events\GitHubPayloadEvent',
- "$class@onPayload"
- );
- $events->listen(
- 'Nasqueron\Notifications\Events\DockerHubPayloadEvent',
- "$class@onPayload"
- );
+ $eventsToListen = [
+ 'DockerHubPayloadEvent',
+ 'GitHubPayloadEvent',
+ 'PhabricatorPayloadEvent',
+ ];
+
+ foreach ($eventsToListen as $event) {
+ $events->listen("$ns\\$event", "$class@onPayload");
+ }
}
}

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 18, 08:41 (22 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2250398
Default Alt Text
D122.id289.diff (3 KB)

Event Timeline