diff --git a/app/Http/Controllers/Api/Client/ActivityLogController.php b/app/Http/Controllers/Api/Client/ActivityLogController.php
index 3fbfa11a9..9e1fcc63d 100644
--- a/app/Http/Controllers/Api/Client/ActivityLogController.php
+++ b/app/Http/Controllers/Api/Client/ActivityLogController.php
@@ -16,10 +16,7 @@ class ActivityLogController extends ClientApiController
{
$activity = QueryBuilder::for($request->user()->activity())
->with('actor')
- ->allowedFilters([
- AllowedFilter::exact('ip'),
- AllowedFilter::partial('event'),
- ])
+ ->allowedFilters([AllowedFilter::partial('event')])
->allowedSorts(['timestamp'])
->paginate(min($request->query('per_page', 25), 100))
->appends($request->query());
diff --git a/app/Http/Controllers/Api/Client/Servers/ActivityLogController.php b/app/Http/Controllers/Api/Client/Servers/ActivityLogController.php
index dabd9df78..adfb3ad7e 100644
--- a/app/Http/Controllers/Api/Client/Servers/ActivityLogController.php
+++ b/app/Http/Controllers/Api/Client/Servers/ActivityLogController.php
@@ -25,10 +25,7 @@ class ActivityLogController extends ClientApiController
$activity = QueryBuilder::for($server->activity())
->with('actor')
->allowedSorts(['timestamp'])
- ->allowedFilters([
- AllowedFilter::exact('ip'),
- AllowedFilter::partial('event'),
- ])
+ ->allowedFilters([AllowedFilter::partial('event')])
->when(config('activity.hide_admin_activity'), function (Builder $builder) use ($server) {
// We could do this with a query and a lot of joins, but that gets pretty
// painful so for now we'll execute a simpler query.
diff --git a/app/Transformers/Api/Client/ActivityLogTransformer.php b/app/Transformers/Api/Client/ActivityLogTransformer.php
index b64a23769..8518b59da 100644
--- a/app/Transformers/Api/Client/ActivityLogTransformer.php
+++ b/app/Transformers/Api/Client/ActivityLogTransformer.php
@@ -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];
}
diff --git a/resources/scripts/api/definitions/user/models.d.ts b/resources/scripts/api/definitions/user/models.d.ts
index 944d1b81e..f42697eec 100644
--- a/resources/scripts/api/definitions/user/models.d.ts
+++ b/resources/scripts/api/definitions/user/models.d.ts
@@ -22,7 +22,7 @@ interface SSHKey extends Model {
interface ActivityLog extends Model<'actor'> {
batch: UUID | null;
event: string;
- ip: string;
+ ip: string | null;
isApi: boolean;
description: string | null;
properties: Record