Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GDPR #3431

Closed
wants to merge 29 commits into from
Closed

GDPR #3431

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
381f7a4
add a new setting: privacy.privacy-statement
Naugrimm Jan 23, 2019
831ed3b
add a new setting: privacy.imprint, move routes to the correct contro…
Naugrimm Jan 23, 2019
ad01aab
l11n
Naugrimm Jan 23, 2019
c3bd8ff
add privacy/imprint link to emails
Naugrimm Jan 23, 2019
2b785fe
styleci
Naugrimm Jan 23, 2019
e3d322b
CachetHQ/Cachet#3054 add footer to subscribe/manage subscription routes
Naugrimm Jan 24, 2019
00abf05
add checkbox "accept privacy statement" when adding subscribers
Naugrimm Jan 24, 2019
21e6b4c
add settings.about_app to the subscribe.subscribe route
Naugrimm Jan 24, 2019
2f49657
CachetHQ/Cachet#3102 fix redirects when adding subscribers/verifying …
Naugrimm Jan 24, 2019
eba7e80
CachetHQ/Cachet/#3102 add List-Unsubscribe header
Naugrimm Jan 24, 2019
cbc1024
add a button on the new privacy settings page to remove unverified su…
Naugrimm Jan 24, 2019
e2d9ae8
add laravel-ide-helper and gitignore generated files
Naugrimm Jan 25, 2019
9f17e7b
fix missing config key
Naugrimm Jan 25, 2019
6b3b6c9
styleci
Naugrimm Jan 25, 2019
36b2b9d
fix unit tests.
Naugrimm Jan 25, 2019
071437e
Revert "add laravel-ide-helper and gitignore generated files"
Naugrimm Jan 28, 2019
aa3b4b4
automatically set the privacy statement to "accepted" if the setting …
Naugrimm Jan 28, 2019
074b3c8
hide the "privacy statement" and "imprint" link if the respective set…
Naugrimm Jan 28, 2019
de7de25
show an error page if no privacy statement/imprint is configured
Naugrimm Jan 28, 2019
e1f0b51
use Illuminate\Support\Str instead of the helper function
Naugrimm Jan 28, 2019
1325d89
set author
Naugrimm Jan 28, 2019
886e2a7
add Markdown-Icon to the textareas
Naugrimm Jan 28, 2019
6d257fc
do not alias axios in the Vue app
Naugrimm Jan 28, 2019
d74e65f
npm run dev
Naugrimm Jan 28, 2019
62d9854
use CarbonInterval->totalDays instead of "totalDayz"
Naugrimm Jan 28, 2019
f0ce6a0
styleci
Naugrimm Jan 28, 2019
9120b97
revert changes to compiled assets
Naugrimm Feb 3, 2019
934d32e
merge 2.4
Naugrimm Jan 26, 2020
21348ac
fix accesslint issues
Naugrimm Jan 26, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/Bus/Commands/Incident/CreateIncidentCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ final class CreateIncidentCommand
*
* @return void
*/
public function __construct($name, $status, $message, $visible, $component_id, $component_status, $notify, $stickied, $occurred_at, $template, array $template_vars = [], $meta = [])
public function __construct($name, $status, $message, $visible, $component_id, $component_status, $notify, $stickied, $occurred_at, $template, array $template_vars = [], array $meta = [])
{
$this->name = $name;
$this->status = $status;
Expand Down
12 changes: 11 additions & 1 deletion app/Bus/Commands/Incident/UpdateIncidentCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ final class UpdateIncidentCommand
*/
public $template_vars;

/**
* Meta key/value pairs.
*
* @var array
*/
public $meta = [];

/**
* The validation rules.
*
Expand All @@ -122,6 +129,7 @@ final class UpdateIncidentCommand
'stickied' => 'nullable|bool',
'occurred_at' => 'nullable|string',
'template' => 'nullable|string',
'meta' => 'nullable|array',
];

/**
Expand All @@ -139,10 +147,11 @@ final class UpdateIncidentCommand
* @param string|null $occurred_at
* @param string|null $template
* @param array $template_vars
* @param array $meta
*
* @return void
*/
public function __construct(Incident $incident, $name, $status, $message, $visible, $component_id, $component_status, $notify, $stickied, $occurred_at, $template, array $template_vars = [])
public function __construct(Incident $incident, $name, $status, $message, $visible, $component_id, $component_status, $notify, $stickied, $occurred_at, $template, array $template_vars = [], array $meta = [])
{
$this->incident = $incident;
$this->name = $name;
Expand All @@ -156,5 +165,6 @@ public function __construct(Incident $incident, $name, $status, $message, $visib
$this->occurred_at = $occurred_at;
$this->template = $template;
$this->template_vars = $template_vars;
$this->meta = $meta;
}
}
14 changes: 12 additions & 2 deletions app/Bus/Commands/Subscriber/SubscribeSubscriberCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,21 @@ final class SubscribeSubscriberCommand
*/
public $subscriptions;

/**
* If the subscriber accepted the privacy statement.
*
* @var bool
*/
public $acceptPrivacyStatement;

/**
* The validation rules.
*
* @var array
*/
public $rules = [
'email' => 'required|email',
'email' => 'required|email',
'acceptPrivacyStatement' => 'required|accepted',
];

/**
Expand All @@ -54,13 +62,15 @@ final class SubscribeSubscriberCommand
* @param string $email
* @param bool $verified
* @param array|null $subscriptions
* @param bool $acceptPrivacyStatement
*
* @return void
*/
public function __construct($email, $verified = false, $subscriptions = null)
public function __construct($email, $verified = false, $subscriptions = null, $acceptPrivacyStatement = false)
{
$this->email = $email;
$this->verified = $verified;
$this->subscriptions = $subscriptions;
$this->acceptPrivacyStatement = $acceptPrivacyStatement;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use CachetHQ\Cachet\Bus\Commands\Incident\CreateIncidentCommand;
use CachetHQ\Cachet\Bus\Events\Incident\IncidentWasCreatedEvent;
use CachetHQ\Cachet\Bus\Exceptions\Incident\InvalidIncidentTimestampException;
use CachetHQ\Cachet\Bus\Handlers\Traits\StoresMeta;
use CachetHQ\Cachet\Models\Component;
use CachetHQ\Cachet\Models\Incident;
use CachetHQ\Cachet\Models\IncidentTemplate;
Expand All @@ -32,6 +33,8 @@
*/
class CreateIncidentCommandHandler
{
use StoresMeta;

/**
* The authentication guard instance.
*
Expand Down Expand Up @@ -104,14 +107,7 @@ public function handle(CreateIncidentCommand $command)

// Store any meta?
if ($meta = $command->meta) {
foreach ($meta as $key => $value) {
Meta::create([
'key' => $key,
'value' => $value,
'meta_type' => 'incidents',
'meta_id' => $incident->id,
]);
}
$this->storeMeta($command->meta, 'incidents', $incident->id);
}

// Update the component.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use CachetHQ\Cachet\Bus\Commands\Incident\UpdateIncidentCommand;
use CachetHQ\Cachet\Bus\Events\Incident\IncidentWasUpdatedEvent;
use CachetHQ\Cachet\Bus\Exceptions\Incident\InvalidIncidentTimestampException;
use CachetHQ\Cachet\Bus\Handlers\Traits\StoresMeta;
use CachetHQ\Cachet\Models\Component;
use CachetHQ\Cachet\Models\Incident;
use CachetHQ\Cachet\Models\IncidentTemplate;
Expand All @@ -30,6 +31,8 @@
*/
class UpdateIncidentCommandHandler
{
use StoresMeta;

/**
* The authentication guard instance.
*
Expand Down Expand Up @@ -86,6 +89,11 @@ public function handle(UpdateIncidentCommand $command)
// Rather than making lots of updates, just fill and save.
$incident->save();

// Store any meta?
if ($meta = $command->meta) {
$this->storeMeta($command->meta, 'incidents', $incident->id);
}

// Update the component.
if ($component = Component::find($command->component_id)) {
execute(new UpdateComponentCommand(
Expand Down
34 changes: 34 additions & 0 deletions app/Bus/Handlers/Events/MessageSending.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?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\Bus\Handlers\Events;

/**
* This class is called immediately before sending a message into the mail channel.
*
* @author Erik Anders <[email protected]>
*/
class MessageSending
{
/**
* Handle the any actions that need storing.
*
* @param \Illuminate\Mail\Events\MessageSending $event
*
* @return void
*/
public function handle($event)
{
if ($unsubscribeUrl = $event->data['unsubscribeUrl'] ?? null) {
$event->message->getHeaders()->addTextHeader('List-Unsubscribe', '<'.$unsubscribeUrl.'>');
}
}
}
81 changes: 81 additions & 0 deletions app/Bus/Handlers/Traits/StoresMeta.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?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\Bus\Handlers\Traits;

use CachetHQ\Cachet\Models\Meta;

trait StoresMeta
{
/**
* Stores all Meta values of a model.
*
* @param array $metaData
* @param string $metaType
* @param string|int $metaId
* @param string $metaModel
*
* @return void
*/
public function storeMeta($metaData, $metaType, $metaId, $metaModel = Meta::class)
{
// Validation required instead of type hinting because it could be passed as false or NULL
if (!is_array($metaData)) {
return;
}

foreach ($metaData as $key => $value) {
$modelInstance = call_user_func(
[$metaModel, 'firstOrNew'],
[
'key' => $key,
'meta_type' => $metaType,
'meta_id' => $metaId,
]
);

$value = $this->removeEmptyValues($value);
if (!empty($value)) {
$modelInstance->setAttribute('value', $value);
$modelInstance->save();
continue;
}

// The value is empty, remove the row
if ($modelInstance->exists) {
$modelInstance->delete();
}
}
}

/**
* Determine if a Value is empty.
*
* @param mixed $values
*
* @return array|mixed
*/
protected function removeEmptyValues($values)
{
if (!is_array($values)) {
return empty($values) ? null : $values;
}

foreach ($values as $key => $value) {
if (!empty($value)) {
continue;
}
unset($values[$key]);
}

return $values;
}
}
2 changes: 1 addition & 1 deletion app/Composers/ComponentsComposer.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function __construct(Guard $guard)
public function compose(View $view)
{
$componentGroups = $this->getVisibleGroupedComponents();
$ungroupedComponents = Component::ungrouped()->get();
$ungroupedComponents = Component::ungrouped()->orderBy('status', 'desc')->get();

$view->withComponentGroups($componentGroups)
->withUngroupedComponents($ungroupedComponents);
Expand Down
5 changes: 3 additions & 2 deletions app/Composers/StatusComposer.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use CachetHQ\Cachet\Integrations\Contracts\System;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Arr;

/**
* This is the status composer.
Expand Down Expand Up @@ -52,7 +53,7 @@ public function compose(View $view)
{
$status = $this->system->getStatus();

$view->withSystemStatus(array_get($status, 'system_status'));
$view->withSystemMessage(array_get($status, 'system_message'));
$view->withSystemStatus(Arr::get($status, 'system_status'));
$view->withSystemMessage(Arr::get($status, 'system_message'));
}
}
3 changes: 2 additions & 1 deletion app/Composers/TimezoneLocaleComposer.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use DateTimeZone;
use Illuminate\Contracts\Config\Repository;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Arr;

/**
* This is the timezone locale composer class.
Expand Down Expand Up @@ -58,7 +59,7 @@ public function compose(View $view)
$langs = array_map(function ($lang) use ($enabledLangs) {
$locale = basename($lang);

return [$locale => array_get($enabledLangs, $locale, [
return [$locale => Arr::get($enabledLangs, $locale, [
'name' => $locale,
'subset' => null,
])];
Expand Down
45 changes: 44 additions & 1 deletion app/Console/Commands/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@

namespace CachetHQ\Cachet\Console\Commands;

use CachetHQ\Cachet\Models\User;
use Dotenv\Dotenv;
use Dotenv\Exception\InvalidPathException;
use Illuminate\Console\Command;
use Illuminate\Contracts\Console\Kernel;
use Illuminate\Contracts\Events\Dispatcher;

/**
Expand Down Expand Up @@ -70,6 +72,7 @@ public function handle()
$this->configureDrivers();
$this->configureMail();
$this->configureCachet();
$this->configureUser();
}

$this->line('Installing Cachet...');
Expand Down Expand Up @@ -313,9 +316,11 @@ protected function configureMail(array $config = [])
/**
* Configure Cachet.
*
* @param array $config
*
* @return void
*/
protected function configureCachet()
protected function configureCachet(array $config = [])
{
$config = [];
if ($this->confirm('Do you wish to use Cachet Beacon?')) {
Expand All @@ -332,6 +337,33 @@ protected function configureCachet()
}
}

/**
* Configure the first user.
*
* @return void
*/
protected function configureUser()
{
if (!$this->confirm('Do you want to create an admin user?')) {
return;
}

// We need to refresh the config to get access to the newly connected database.
$this->getFreshConfiguration();

// Now we need to install the application.
// $this->call('cachet:install');

$user = [
'username' => $this->ask('Please enter your username'),
'email' => $this->ask('Please enter your email'),
'password' => $this->secret('Please enter your password'),
'level' => User::LEVEL_ADMIN,
];

User::create($user);
}

/**
* Configure the redis connection.
*
Expand Down Expand Up @@ -372,6 +404,17 @@ protected function formatConfigsTable(array $config)
$this->table(['Setting', 'Value'], $configRows);
}

/**
* Boot a fresh copy of the application configuration.
*
* @return void
*/
protected function getFreshConfiguration()
{
$app = require $this->laravel->bootstrapPath().'/app.php';
$app->make(Kernel::class)->bootstrap();
}

/**
* Writes to the .env file with given parameters.
*
Expand Down
Loading