diff --git a/src/Console/Labeler/LabelerPollingCommand.php b/src/Console/Labeler/LabelerPollingCommand.php new file mode 100644 index 0000000..63f16d5 --- /dev/null +++ b/src/Console/Labeler/LabelerPollingCommand.php @@ -0,0 +1,74 @@ +option('limit'); + + $cursor = Cache::get(self::CACHE_KEY); + + $response = Bluesky::login(Config::string('bluesky.labeler.identifier'), Config::string('bluesky.labeler.password')) + ->listNotifications(limit: $limit, cursor: $cursor); + + $cursor = $response->json('cursor'); + Cache::forever(self::CACHE_KEY, $cursor); + + /** @var array $notifications */ + $notifications = $response->json('notifications'); + + foreach ($notifications as $notification) { + $reason = data_get($notification, 'reason'); + + if (in_array($reason, self::REASONS, true)) { + event(new NotificationReceived($reason, $notification)); + } + } + + return 0; + } +} diff --git a/src/Events/Labeler/NotificationReceived.php b/src/Events/Labeler/NotificationReceived.php new file mode 100644 index 0000000..dc51084 --- /dev/null +++ b/src/Events/Labeler/NotificationReceived.php @@ -0,0 +1,14 @@ +