Compare commits

...

21 Commits
3.x ... v2.3.12

Author SHA1 Message Date
Graham Campbell
47bc73f9e9 Release v2.3.12 2017-06-28 23:41:31 +01:00
Graham Campbell
81fc6479d5 Revert to original travis config 2017-06-28 22:53:06 +01:00
Graham Campbell
c9ca99990c Update .travis.yml 2017-06-28 22:49:07 +01:00
Graham Campbell
e0d35d6e64 Merge branch '2.3' of https://github.com/CachetHQ/Cachet into 2.3 2017-06-28 22:39:55 +01:00
Graham Campbell
813be34f25 Upgraded dependencies 2017-06-28 22:39:41 +01:00
Graham Campbell
900723105b Update .travis.yml 2017-06-28 22:38:44 +01:00
Graham Campbell
8012a201b9 Update .travis.yml 2017-06-28 22:00:28 +01:00
Graham Campbell
706e7765e1 Update .travis.yml 2017-06-28 21:52:45 +01:00
Guido Hendriks
bcff3d0730 Improve testCreateSubscriberWithSubscriptions test case (#2487) 2017-06-28 21:45:27 +01:00
James Brooks
db5bf005bc Apply fixes from StyleCI (#2606)
[ci skip] [skip ci]
2017-06-28 20:52:41 +01:00
James Brooks
dac88efce6 Merge pull request #2601 from Daniel15/2.3-with-patches
Backport API endpoint to get system status to v2.3
2017-06-28 20:52:08 +01:00
James Brooks
38ef2630ee Add system status to /status endpoint 2017-06-20 17:18:38 +10:00
James Brooks
c215ad4111 Implement the system status api endpoint. Closes #1936 2017-06-20 17:09:03 +10:00
James Brooks
c899839a7f Back to dev 2017-04-12 23:05:32 +01:00
James Brooks
2e5e8b1545 Bump version to 2.3.11 2017-04-12 23:05:09 +01:00
James Brooks
7e556d5dba Apply fixes from StyleCI (#2486)
[ci skip] [skip ci]
2017-04-12 23:04:21 +01:00
James Brooks
331e176fbc Updated deps 2017-03-25 11:42:25 +00:00
James Brooks
bde0abe472 Fix handling of individual component subscriptions via API 2016-09-21 18:35:58 +01:00
James Brooks
f2bf2eff68 Test creating a subscriber returns subscriptions 2016-09-21 18:17:22 +01:00
James Brooks
50ab96fc4f Load subscriptions when creating a subscriber 2016-09-21 18:16:08 +01:00
James Brooks
3cbee1302e Update deps 2016-09-21 18:08:56 +01:00
15 changed files with 695 additions and 455 deletions

View File

@@ -1,14 +1,17 @@
language: php
sudo: false
dist: trusty
php:
- 5.5.9
- 5.5
- 5.6
- 7.0
- 7.1
- hhvm
sudo: false
before_install: cp .env.example .env
install: travis_retry composer install --no-interaction --no-scripts --prefer-source

View File

@@ -1 +1 @@
2.3.11-dev
2.3.12

View File

@@ -44,17 +44,17 @@ class SubscribeSubscriberCommandHandler
// Decide what to subscribe the subscriber to.
if ($subscriptions = $command->subscriptions) {
$subscriptions = Component::whereIn('id', $subscriptions);
$components = Component::whereIn('id', $subscriptions)->get();
} else {
$subscriptions = Component::all();
$components = Component::all();
}
foreach ($subscriptions as $component) {
$components->map(function ($component) use ($subscriber) {
Subscription::create([
'subscriber_id' => $subscriber->id,
'component_id' => $component->id,
]);
}
});
if ($command->verified) {
dispatch(new VerifySubscriberCommand($subscriber));
@@ -62,6 +62,8 @@ class SubscribeSubscriberCommandHandler
event(new SubscriberHasSubscribedEvent($subscriber));
}
$subscriber->load('subscriptions');
return $subscriber;
}
}

View File

@@ -13,7 +13,6 @@ namespace CachetHQ\Cachet\Bus\Handlers\Commands\Subscriber;
use CachetHQ\Cachet\Bus\Commands\Subscriber\UnsubscribeSubscriberCommand;
use CachetHQ\Cachet\Bus\Events\Subscriber\SubscriberHasUnsubscribedEvent;
use CachetHQ\Cachet\Models\Subscriber;
class UnsubscribeSubscriberCommandHandler
{

View File

@@ -11,13 +11,38 @@
namespace CachetHQ\Cachet\Composers;
use CachetHQ\Cachet\Integrations\Core\System;
use CachetHQ\Cachet\Models\Component;
use CachetHQ\Cachet\Models\ComponentGroup;
use CachetHQ\Cachet\Models\Incident;
use Illuminate\Contracts\View\View;
/**
* This is the status page composer.
*
* @author James Brooks <james@alt-three.com>
*/
class StatusPageComposer
{
/**
* The system instance.
*
* @var \CachetHQ\Cachet\Integrations\Contracts\System
*/
protected $system;
/**
* Create a new status page composer instance.
*
* @param \CachetHQ\Cachet\Integrations\Contracts\System $system
*
* @return void
*/
public function __construct(System $system)
{
$this->system = $system;
}
/**
* Index page view composer.
*
@@ -27,42 +52,7 @@ class StatusPageComposer
*/
public function compose(View $view)
{
$totalComponents = Component::enabled()->count();
$majorOutages = Component::enabled()->status(4)->count();
$isMajorOutage = $totalComponents ? ($majorOutages / $totalComponents) >= 0.5 : false;
// Default data
$withData = [
'system_status' => 'info',
'system_message' => trans_choice('cachet.service.bad', $totalComponents),
'favicon' => 'favicon-high-alert',
];
if ($isMajorOutage) {
$withData = [
'system_status' => 'danger',
'system_message' => trans_choice('cachet.service.major', $totalComponents),
'favicon' => 'favicon-high-alert',
];
} elseif (Component::enabled()->notStatus(1)->count() === 0) {
// If all our components are ok, do we have any non-fixed incidents?
$incidents = Incident::notScheduled()->orderBy('created_at', 'desc')->get()->filter(function ($incident) {
return $incident->status > 0;
});
$incidentCount = $incidents->count();
if ($incidentCount === 0 || ($incidentCount >= 1 && (int) $incidents->first()->status === 4)) {
$withData = [
'system_status' => 'success',
'system_message' => trans_choice('cachet.service.good', $totalComponents),
'favicon' => 'favicon',
];
}
} else {
if (Component::enabled()->whereIn('status', [2, 3])->count() > 0) {
$withData['favicon'] = 'favicon-medium-alert';
}
}
$status = $this->system->getStatus();
// Scheduled maintenance code.
$scheduledMaintenance = Incident::scheduled()->orderBy('scheduled_at')->get();
@@ -72,7 +62,7 @@ class StatusPageComposer
$componentGroups = ComponentGroup::whereIn('id', $usedComponentGroups)->orderBy('order')->get();
$ungroupedComponents = Component::enabled()->where('group_id', 0)->orderBy('order')->orderBy('created_at')->get();
$view->with($withData)
$view->with($status)
->withComponentGroups($componentGroups)
->withUngroupedComponents($ungroupedComponents)
->withScheduledMaintenance($scheduledMaintenance);

View File

@@ -0,0 +1,47 @@
<?php
/*
* This file is part of Cachet.
*
* (c) Alt Three Services Limited
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace CachetHQ\Cachet\Foundation\Providers;
use CachetHQ\Cachet\Integrations\Contracts\System as SystemContract;
use CachetHQ\Cachet\Integrations\Core\System;
use Illuminate\Contracts\Container\Container;
use Illuminate\Support\ServiceProvider;
/**
* This is the integration service provider.
*
* @author James Brooks <james@alt-three.com>
*/
class IntegrationServiceProvider extends ServiceProvider
{
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->registerSystem();
}
/**
* Register the system class.
*
* @return void
*/
protected function registerSystem()
{
$this->app->singleton(SystemContract::class, function (Container $app) {
return new System();
});
}
}

View File

@@ -11,6 +11,7 @@
namespace CachetHQ\Cachet\Http\Controllers\Api;
use CachetHQ\Cachet\Integrations\Contracts\System;
use CachetHQ\Cachet\Integrations\Releases;
/**
@@ -44,4 +45,19 @@ class GeneralController extends AbstractApiController
'latest' => $latest,
])->item(CACHET_VERSION);
}
/**
* Get the system status message.
*
* @return \Illuminate\Http\JsonResponse
*/
public function status()
{
$system = app()->make(System::class)->getStatus();
return $this->item([
'status' => $system['system_status'],
'message' => $system['system_message'],
]);
}
}

View File

@@ -33,6 +33,7 @@ class ApiRoutes
$router->group(['middleware' => ['auth.api']], function (Registrar $router) {
$router->get('ping', 'GeneralController@ping');
$router->get('version', 'GeneralController@version');
$router->get('status', 'GeneralController@status');
$router->get('components', 'ComponentController@getComponents');
$router->get('components/groups', 'ComponentGroupController@getGroups');

View File

@@ -0,0 +1,27 @@
<?php
/*
* This file is part of Cachet.
*
* (c) Alt Three Services Limited
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace CachetHQ\Cachet\Integrations\Contracts;
/**
* This is the system interface.
*
* @author James Brooks <james@alt-three.com>
*/
interface System
{
/**
* Get the entire system status.
*
* @return array
*/
public function getStatus();
}

View File

@@ -0,0 +1,70 @@
<?php
/*
* This file is part of Cachet.
*
* (c) Alt Three Services Limited
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace CachetHQ\Cachet\Integrations\Core;
use CachetHQ\Cachet\Integrations\Contracts\System as SystemContract;
use CachetHQ\Cachet\Models\Component;
use CachetHQ\Cachet\Models\Incident;
/**
* This is the core system class.
*
* @author James Brooks <james@alt-three.com>
*/
class System implements SystemContract
{
/**
* Get the entire system status.
*
* @return array
*/
public function getStatus()
{
$enabledScope = Component::enabled();
$totalComponents = Component::enabled()->count();
$majorOutages = Component::enabled()->status(4)->count();
$isMajorOutage = $totalComponents ? ($majorOutages / $totalComponents) >= 0.5 : false;
// Default data
$status = [
'system_status' => 'info',
'system_message' => trans_choice('cachet.service.bad', $totalComponents),
'favicon' => 'favicon-high-alert',
];
if ($isMajorOutage) {
$status = [
'system_status' => 'danger',
'system_message' => trans_choice('cachet.service.major', $totalComponents),
'favicon' => 'favicon-high-alert',
];
} elseif (Component::enabled()->notStatus(1)->count() === 0) {
// If all our components are ok, do we have any non-fixed incidents?
$incidents = Incident::notScheduled()->orderBy('created_at', 'desc')->get()->filter(function ($incident) {
return $incident->status > 0;
});
$incidentCount = $incidents->count();
if ($incidentCount === 0 || ($incidentCount >= 1 && (int) $incidents->first()->status === 4)) {
$status = [
'system_status' => 'success',
'system_message' => trans_choice('cachet.service.good', $totalComponents),
'favicon' => 'favicon',
];
}
} elseif (Component::enabled()->whereIn('status', [2, 3])->count() > 0) {
$status['favicon'] = 'favicon-medium-alert';
}
return $status;
}
}

View File

@@ -28,7 +28,7 @@
"alt-three/throttle": "^1.0",
"alt-three/validator": "^1.5",
"aws/aws-sdk-php": "^3.7",
"backup-manager/laravel": "^1.1",
"backup-manager/laravel": "dev-master#df53f9c9d8c6be5d7a2638f45d54b8fb7bc51e2b",
"barryvdh/laravel-cors": "^0.8",
"doctrine/dbal": "^2.5",
"fedeisas/laravel-mail-css-inliner": "^1.5",
@@ -49,7 +49,7 @@
"filp/whoops": "^2.1",
"fzaninotto/faker": "^1.6",
"graham-campbell/testbench-core": "^1.1",
"mockery/mockery": "0.9.5",
"mockery/mockery": "0.9.9",
"phpunit/phpunit": "4.8.21",
"symfony/css-selector": "^3.0",
"symfony/dom-crawler": "^3.0"

860
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -184,6 +184,7 @@ return [
'CachetHQ\Cachet\Foundation\Providers\ComposerServiceProvider',
'CachetHQ\Cachet\Foundation\Providers\ConsoleServiceProvider',
'CachetHQ\Cachet\Foundation\Providers\ConfigServiceProvider',
'CachetHQ\Cachet\Foundation\Providers\IntegrationServiceProvider',
'CachetHQ\Cachet\Foundation\Providers\EventServiceProvider',
'CachetHQ\Cachet\Foundation\Providers\RepositoryServiceProvider',
'CachetHQ\Cachet\Foundation\Providers\RouteServiceProvider',

View File

@@ -73,15 +73,20 @@ class SubscriberTest extends AbstractApiTestCase
$this->post('/api/v1/subscribers', [
'email' => 'support@alt-three.com',
'verify' => true,
'subscriptions' => [
'components' => [
1,
2,
3,
],
]);
$this->assertResponseOk();
$this->seeHeader('Content-Type', 'application/json');
$this->seeJson(['email' => 'support@alt-three.com']);
$this->seeJsonStructure(['data' => ['subscriptions' => []]]);
$data = $this->decodeResponseJson();
$this->assertCount(2, $data['data']['subscriptions']);
$this->assertEquals(1, $data['data']['subscriptions'][0]['component_id']);
$this->assertEquals(3, $data['data']['subscriptions'][1]['component_id']);
}
public function testDeleteSubscriber()

View File

@@ -0,0 +1,31 @@
<?php
/*
* This file is part of Cachet.
*
* (c) Alt Three Services Limited
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace CachetHQ\Tests\Cachet\Foundation\Providers;
use AltThree\TestBench\ServiceProviderTrait;
use CachetHQ\Cachet\Integrations\Contracts\System;
use CachetHQ\Tests\Cachet\AbstractTestCase;
/**
* This is the integration service provider test class.
*
* @author James Brooks <james@alt-three.com>
*/
class IntegrationServiceProviderTest extends AbstractTestCase
{
use ServiceProviderTrait;
public function testSystemIsInjectable()
{
$this->assertIsInjectable(System::class);
}
}