Hide IP addresses from activity logs not generated by the user themselves

This commit is contained in:
DaneEveritt 2022-06-27 20:52:27 -04:00
parent b570769a34
commit 4aa163b76f
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
5 changed files with 15 additions and 18 deletions

View file

@ -21,7 +21,7 @@ class ActivityLogTransformer extends BaseClientTransformer
'batch' => $model->batch,
'event' => $model->event,
'is_api' => !is_null($model->api_key_id),
'ip' => $model->ip,
'ip' => optional($model->actor)->is($this->request->user()) ? $model->ip : null,
'description' => $model->description,
'properties' => $this->properties($model),
'has_additional_metadata' => $this->hasAdditionalMetadata($model),
@ -49,7 +49,11 @@ class ActivityLogTransformer extends BaseClientTransformer
}
$properties = $model->properties
->mapWithKeys(function ($value, $key) {
->mapWithKeys(function ($value, $key) use ($model) {
if ($key === 'ip' && !optional($model->actor)->is($this->request->user())) {
return [$key => '[hidden]'];
}
if (!is_array($value)) {
return [$key => $value];
}