Skip to content

Commit

Permalink
updated alias account event logging context
Browse files Browse the repository at this point in the history
  • Loading branch information
MelonSmasher committed Dec 13, 2017
1 parent 0d6691c commit 3639f27
Show file tree
Hide file tree
Showing 6 changed files with 159 additions and 31 deletions.
35 changes: 29 additions & 6 deletions app/Events/Api/AliasAccount/AliasAccountCreated.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,36 @@ public function __construct(AliasAccount $account)
{
parent::__construct();

Log::info('Alias Account Created:', [
'id' => $account->id,
'username' => $account->username,
'owner' => $account->account->format_full_name(true),
'owner_username' => $account->account->username
]);

$logMessage = 'created alias account - ';
$logContext = [
'action' => 'create',
'model' => 'alias_account',
'alias_account_id' => $account->id,
'alias_account_username' => $account->username,
'alias_account_created' => $account->created_at,
'alias_account_updated' => $account->updated_at,
'alias_account_owner_id' => $account->account->id,
'alias_account_owner_name' => $account->account->format_full_name(true),
'alias_account_owner_username' => $account->account->username,
'alias_account_owner_identifier' => $account->account->identifier,
'requester_id' => 0,
'requester_name' => 'System',
'requester_ip' => getRequestIP(),
'request_proxy_ip' => getRequestIP(true),
'request_method' => \Request::getMethod(),
'request_url' => \Request::fullUrl(),
'request_uri' => \Request::getRequestUri(),
'request_scheme' => \Request::getScheme(),
'request_host' => \Request::getHost()
];

if (auth()->user()) {

$logMessage = auth()->user()->name . ' ' . $logMessage;
$logContext['requester_id'] = auth()->user()->id;
$logContext['requester_name'] = auth()->user()->name;

if (Settings::get('broadcast-events', false)) {

$trans = $account->toArray();
Expand Down Expand Up @@ -64,5 +85,7 @@ public function __construct(AliasAccount $account)
'bg-green'
);
}

Log::info($logMessage, $logContext);
}
}
34 changes: 28 additions & 6 deletions app/Events/Api/AliasAccount/AliasAccountDestroyed.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,35 @@ public function __construct(AliasAccount $account)
{
parent::__construct();

Log::info('Alias Account Deleted:', [
'id' => $account->id,
'username' => $account->username,
'owner' => $account->account->format_full_name(true),
'owner_username' => $account->account->username
]);
$logMessage = 'destroyed alias account - ';
$logContext = [
'action' => 'destroy',
'model' => 'alias_account',
'alias_account_id' => $account->id,
'alias_account_username' => $account->username,
'alias_account_created' => $account->created_at,
'alias_account_updated' => $account->updated_at,
'alias_account_owner_id' => $account->account->id,
'alias_account_owner_name' => $account->account->format_full_name(true),
'alias_account_owner_username' => $account->account->username,
'alias_account_owner_identifier' => $account->account->identifier,
'requester_id' => 0,
'requester_name' => 'System',
'requester_ip' => getRequestIP(),
'request_proxy_ip' => getRequestIP(true),
'request_method' => \Request::getMethod(),
'request_url' => \Request::fullUrl(),
'request_uri' => \Request::getRequestUri(),
'request_scheme' => \Request::getScheme(),
'request_host' => \Request::getHost()
];

if (auth()->user()) {

$logMessage = auth()->user()->name . ' ' . $logMessage;
$logContext['requester_id'] = auth()->user()->id;
$logContext['requester_name'] = auth()->user()->name;

if (Settings::get('broadcast-events', false)) {

$trans = $account->toArray();
Expand Down Expand Up @@ -59,5 +79,7 @@ public function __construct(AliasAccount $account)
'bg-red'
);
}

Log::info($logMessage, $logContext);
}
}
34 changes: 28 additions & 6 deletions app/Events/Api/AliasAccount/AliasAccountRestored.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,35 @@ public function __construct(AliasAccount $account)
{
parent::__construct();

Log::info('Alias Account Restored:', [
'id' => $account->id,
'username' => $account->username,
'owner' => $account->account->format_full_name(true),
'owner_username' => $account->account->username
]);
$logMessage = 'restored alias account - ';
$logContext = [
'action' => 'restore',
'model' => 'alias_account',
'alias_account_id' => $account->id,
'alias_account_username' => $account->username,
'alias_account_created' => $account->created_at,
'alias_account_updated' => $account->updated_at,
'alias_account_owner_id' => $account->account->id,
'alias_account_owner_name' => $account->account->format_full_name(true),
'alias_account_owner_username' => $account->account->username,
'alias_account_owner_identifier' => $account->account->identifier,
'requester_id' => 0,
'requester_name' => 'System',
'requester_ip' => getRequestIP(),
'request_proxy_ip' => getRequestIP(true),
'request_method' => \Request::getMethod(),
'request_url' => \Request::fullUrl(),
'request_uri' => \Request::getRequestUri(),
'request_scheme' => \Request::getScheme(),
'request_host' => \Request::getHost()
];

if (auth()->user()) {

$logMessage = auth()->user()->name . ' ' . $logMessage;
$logContext['requester_id'] = auth()->user()->id;
$logContext['requester_name'] = auth()->user()->name;

if (Settings::get('broadcast-events', false)) {

$account->primary_duty = $account->primaryDuty;
Expand Down Expand Up @@ -65,5 +85,7 @@ public function __construct(AliasAccount $account)
'bg-lime'
);
}

Log::info($logMessage, $logContext);
}
}
34 changes: 28 additions & 6 deletions app/Events/Api/AliasAccount/AliasAccountUpdated.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,35 @@ public function __construct(AliasAccount $account)
{
parent::__construct();

Log::info('Alias Account Updated:', [
'id' => $account->id,
'username' => $account->username,
'owner' => $account->account->format_full_name(true),
'owner_username' => $account->account->username
]);
$logMessage = 'updated alias account - ';
$logContext = [
'action' => 'update',
'model' => 'alias_account',
'alias_account_id' => $account->id,
'alias_account_username' => $account->username,
'alias_account_created' => $account->created_at,
'alias_account_updated' => $account->updated_at,
'alias_account_owner_id' => $account->account->id,
'alias_account_owner_name' => $account->account->format_full_name(true),
'alias_account_owner_username' => $account->account->username,
'alias_account_owner_identifier' => $account->account->identifier,
'requester_id' => 0,
'requester_name' => 'System',
'requester_ip' => getRequestIP(),
'request_proxy_ip' => getRequestIP(true),
'request_method' => \Request::getMethod(),
'request_url' => \Request::fullUrl(),
'request_uri' => \Request::getRequestUri(),
'request_scheme' => \Request::getScheme(),
'request_host' => \Request::getHost()
];

if (auth()->user()) {

$logMessage = auth()->user()->name . ' ' . $logMessage;
$logContext['requester_id'] = auth()->user()->id;
$logContext['requester_name'] = auth()->user()->name;

if (Settings::get('broadcast-events', false)) {

$trans = $account->toArray();
Expand Down Expand Up @@ -62,5 +82,7 @@ public function __construct(AliasAccount $account)
'bg-lime'
);
}

Log::info($logMessage, $logContext);
}
}
30 changes: 26 additions & 4 deletions app/Events/Api/AliasAccount/AliasAccountViewed.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,34 @@ public function __construct(AliasAccount $account)
{
parent::__construct();

$user_name = 'System';
$logMessage = 'viewed alias account - ';
$logContext = [
'action' => 'view',
'model' => 'alias_account',
'alias_account_id' => $account->id,
'alias_account_username' => $account->username,
'alias_account_created' => $account->created_at,
'alias_account_updated' => $account->updated_at,
'alias_account_owner_id' => $account->account->id,
'alias_account_owner_name' => $account->account->format_full_name(true),
'alias_account_owner_username' => $account->account->username,
'alias_account_owner_identifier' => $account->account->identifier,
'requester_id' => 0,
'requester_name' => 'System',
'requester_ip' => getRequestIP(),
'request_proxy_ip' => getRequestIP(true),
'request_method' => \Request::getMethod(),
'request_url' => \Request::fullUrl(),
'request_uri' => \Request::getRequestUri(),
'request_scheme' => \Request::getScheme(),
'request_host' => \Request::getHost()
];

if ($user = auth()->user()) {

$user_name = $user->name;
$logMessage = auth()->user()->name . ' ' . $logMessage;
$logContext['requester_id'] = auth()->user()->id;
$logContext['requester_name'] = auth()->user()->name;

if (Settings::get('broadcast-events', false)) {
// @todo broadcast view event
Expand All @@ -37,7 +60,6 @@ public function __construct(AliasAccount $account)
);
}

Log::info($user_name . ' viewed ' . $account->account->format_full_name() . '\'s alias account [' . $account->username . ']');

Log::info($logMessage, $logContext);
}
}
23 changes: 20 additions & 3 deletions app/Events/Api/AliasAccount/AliasAccountsViewed.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,28 @@ public function __construct($accountIds = [])
{
parent::__construct();

$user_name = 'System';
$logMessage = 'viewed alias accounts - ';
$logContext = [
'action' => 'view',
'model' => 'alias_account',
'alias_account_ids' => $accountIds,
'alias_account_id_count' => count($accountIds),
'requester_id' => 0,
'requester_name' => 'System',
'requester_ip' => getRequestIP(),
'request_proxy_ip' => getRequestIP(true),
'request_method' => \Request::getMethod(),
'request_url' => \Request::fullUrl(),
'request_uri' => \Request::getRequestUri(),
'request_scheme' => \Request::getScheme(),
'request_host' => \Request::getHost()
];

if ($user = auth()->user()) {

$user_name = $user->name;
$logMessage = auth()->user()->name . ' ' . $logMessage;
$logContext['requester_id'] = auth()->user()->id;
$logContext['requester_name'] = auth()->user()->name;

if (Settings::get('broadcast-events', false)) {
//@todo broadcast view event
Expand All @@ -36,6 +53,6 @@ public function __construct($accountIds = [])

}

Log::info($user_name . ' viewed ' . count($accountIds) . ' accounts', $accountIds);
Log::info($logMessage, $logContext);
}
}

0 comments on commit 3639f27

Please sign in to comment.