Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions app/GraphQL/Mutations/ChangeGlobalRole.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Enums\GlobalRole;
use App\Exceptions\GraphQLMutationException;
use App\Models\User;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\Rule;
use Illuminate\Validation\ValidationException;
Expand Down Expand Up @@ -55,6 +56,8 @@ public function __invoke(null $_, array $args): self
$userToChange->admin = $args['role'] === GlobalRole::ADMINISTRATOR;
$userToChange->save();

Log::info("User {$user->id} changed global role to {$args['role']->value} for user {$userToChange->id}.");

$this->user = $userToChange;

return $this;
Expand Down
3 changes: 3 additions & 0 deletions app/GraphQL/Mutations/ChangeProjectRole.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use App\Models\Project;
use App\Models\User;
use Exception;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\Rule;

Expand Down Expand Up @@ -65,6 +66,8 @@ public function __invoke(null $_, array $args): self
},
]);

Log::info("User {$user->id} changed role to {$args['role']->value} for user {$userToChange->id} in project {$project->id}.");

if ($rowsEdited !== 1) {
throw new Exception('Failed to update pivot table with new role.');
}
Expand Down
3 changes: 3 additions & 0 deletions app/GraphQL/Mutations/ClaimSite.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Exceptions\GraphQLMutationException;
use App\Models\Site;
use App\Models\User;
use Illuminate\Support\Facades\Log;

final class ClaimSite extends AbstractMutation
{
Expand Down Expand Up @@ -36,6 +37,8 @@ public function __invoke(null $_, array $args): self

$site->maintainers()->syncWithoutDetaching($user);

Log::info("User {$user->id} claimed site {$site->id}.");

$this->site = $site;
$this->user = $user;

Expand Down
8 changes: 8 additions & 0 deletions app/GraphQL/Mutations/CreateAuthenticationToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Illuminate\Auth\AuthenticationException;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\Log;

final class CreateAuthenticationToken extends AbstractMutation
{
Expand Down Expand Up @@ -47,6 +48,13 @@ public function __invoke(null $_, array $args): self
$args['expiration'],
);

$logMessage = "User {$user->id} created authentication token with scope {$this->token->scope}";
if ($this->token->projectid > 0) {
$logMessage .= " for project {$this->token->projectid}";
}

Log::info("$logMessage.");

return $this;
}
}
3 changes: 3 additions & 0 deletions app/GraphQL/Mutations/CreateComment.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use App\Models\Comment;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\Log;

final class CreateComment extends AbstractMutation
{
Expand Down Expand Up @@ -41,6 +42,8 @@ public function __invoke(null $_, array $args): self

$this->comment = $comment->refresh();

Log::info("User {$user->id} left comment {$comment->id} on build {$build?->id}.");

return $this;
}
}
3 changes: 3 additions & 0 deletions app/GraphQL/Mutations/CreateGlobalInvitation.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Exception;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Str;
Expand Down Expand Up @@ -74,6 +75,8 @@ public function __invoke(null $_, array $args): self
'password' => Hash::make($password),
]);

Log::info("User {$user->id} invited user {$this->invitedUser->email} with role {$this->invitedUser->role->value}.");

// The email gets sent to the queue, so we have no way to know immediately whether it was sent or not.
// TODO: We should eventually track whether the email was actually sent.
Mail::to($args['email'])->send(new InvitedToCdash($this->invitedUser, $password));
Expand Down
4 changes: 4 additions & 0 deletions app/GraphQL/Mutations/CreatePinnedTestMeasurement.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Models\PinnedTestMeasurement;
use App\Models\Project;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\Log;

final class CreatePinnedTestMeasurement extends AbstractMutation
{
Expand Down Expand Up @@ -35,6 +36,9 @@ public function __invoke(null $_, array $args): self
'position' => $nextAvailablePosition,
]);

$user = auth()->user();
Log::info("User {$user?->id} created pinned test measurement {$this->pinnedTestMeasurement?->id} for project {$project?->id}.");

return $this;
}
}
4 changes: 4 additions & 0 deletions app/GraphQL/Mutations/CreateProject.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Models\Project;
use App\Services\ProjectService;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\Log;

class CreateProject
{
Expand All @@ -27,6 +28,9 @@ public function __invoke(null $_, array $args): Project
'role' => Project::PROJECT_ADMIN,
]);

$user = auth()->user();
Log::info("User {$user?->id} created project {$project->id}.");

return $project;
}
}
4 changes: 4 additions & 0 deletions app/GraphQL/Mutations/CreateRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Models\Project;
use App\Models\Repository;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\Log;

final class CreateRepository extends AbstractMutation
{
Expand Down Expand Up @@ -34,6 +35,9 @@ public function __invoke(null $_, array $args): self
'branch' => $args['branch'],
]);

$user = auth()->user();
Log::info("User {$user?->id} created repository {$this->repository?->id} for project {$project?->id}.");

return $this;
}
}
3 changes: 3 additions & 0 deletions app/GraphQL/Mutations/DeleteAuthenticationToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Models\AuthToken;
use App\Utils\AuthTokenUtil;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Support\Facades\Log;

final class DeleteAuthenticationToken extends AbstractMutation
{
Expand All @@ -26,6 +27,8 @@ public function __invoke(null $_, array $args): self
throw new AuthenticationException('This action is unauthorized.');
}

Log::info("User {$userid} deleted authentication token {$args['tokenId']}.");

return $this;
}
}
4 changes: 4 additions & 0 deletions app/GraphQL/Mutations/DeletePinnedTestMeasurement.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use App\Models\PinnedTestMeasurement;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\Log;

final class DeletePinnedTestMeasurement extends AbstractMutation
{
Expand All @@ -22,6 +23,9 @@ public function __invoke(null $_, array $args): self

$measurement?->delete();

$user = auth()->user();
Log::info("User {$user?->id} deleted pinned test measurement {$args['id']}.");

return $this;
}
}
4 changes: 4 additions & 0 deletions app/GraphQL/Mutations/DeleteRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use App\Models\Repository;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\Log;

final class DeleteRepository extends AbstractMutation
{
Expand All @@ -22,6 +23,9 @@ public function __invoke(null $_, array $args): self

$repository?->delete();

$user = auth()->user();
Log::info("User {$user?->id} deleted repository {$args['repositoryId']}.");

return $this;
}
}
3 changes: 3 additions & 0 deletions app/GraphQL/Mutations/InviteToProject.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use App\Models\User;
use Exception;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\Rule;
Expand Down Expand Up @@ -77,6 +78,8 @@ public function __invoke(null $_, array $args): self
'invitation_timestamp' => Carbon::now(),
]);

Log::info("User {$user->id} invited user {$args['email']} to project {$project->id} with role {$args['role']->value}.");

// The email gets sent to the queue, so we have no way to know immediately whether it was sent or not.
// TODO: We should eventually track whether the email was actually sent.
Mail::to($args['email'])->send(new InvitedToProject($this->invitedUser));
Expand Down
3 changes: 3 additions & 0 deletions app/GraphQL/Mutations/JoinProject.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Exceptions\GraphQLMutationException;
use App\Models\Project;
use App\Models\User;
use Illuminate\Support\Facades\Log;

final class JoinProject extends AbstractMutation
{
Expand Down Expand Up @@ -41,6 +42,8 @@ public function __invoke(null $_, array $args): self
'role' => Project::PROJECT_USER,
]);

Log::info("User {$user->id} joined project {$project->id}.");

return $this;
}
}
3 changes: 3 additions & 0 deletions app/GraphQL/Mutations/RemoveProjectUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Exceptions\GraphQLMutationException;
use App\Models\Project;
use App\Models\User;
use Illuminate\Support\Facades\Log;

final class RemoveProjectUser extends AbstractMutation
{
Expand Down Expand Up @@ -44,6 +45,8 @@ public function __invoke(null $_, array $args): self

$project->users()->detach($userToRemove->id);

Log::info("User {$user->id} removed user {$userToRemove->id} from project {$project->id}.");

return $this;
}
}
4 changes: 4 additions & 0 deletions app/GraphQL/Mutations/RemoveUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Exceptions\GraphQLMutationException;
use App\Models\User;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\Log;

final class RemoveUser extends AbstractMutation
{
Expand All @@ -29,6 +30,9 @@ public function __invoke(null $_, array $args): self

$user->delete();

$authUser = auth()->user();
Log::info("User {$authUser?->id} removed user {$args['userId']}.");

return $this;
}
}
4 changes: 4 additions & 0 deletions app/GraphQL/Mutations/RevokeGlobalInvitation.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Exceptions\GraphQLMutationException;
use App\Models\GlobalInvitation;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\Log;

final class RevokeGlobalInvitation extends AbstractMutation
{
Expand All @@ -29,6 +30,9 @@ public function __invoke(null $_, array $args): self

$invitation->delete();

$user = auth()->user();
Log::info("User {$user?->id} revoked global invitation for {$invitation->email}.");

return $this;
}
}
4 changes: 4 additions & 0 deletions app/GraphQL/Mutations/RevokeProjectInvitation.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Exceptions\GraphQLMutationException;
use App\Models\ProjectInvitation;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\Log;

final class RevokeProjectInvitation extends AbstractMutation
{
Expand All @@ -29,6 +30,9 @@ public function __invoke(null $_, array $args): self

$invitation->delete();

$user = auth()->user();
Log::info("User {$user?->id} revoked invitation for user {$invitation->email} to project {$invitation->project_id}.");

return $this;
}
}
3 changes: 3 additions & 0 deletions app/GraphQL/Mutations/UnclaimSite.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Exceptions\GraphQLMutationException;
use App\Models\Site;
use App\Models\User;
use Illuminate\Support\Facades\Log;

final class UnclaimSite extends AbstractMutation
{
Expand Down Expand Up @@ -36,6 +37,8 @@ public function __invoke(null $_, array $args): self

$site->maintainers()->detach($user);

Log::info("User {$user->id} unclaimed site {$site->id}.");

$this->site = $site;
$this->user = $user;

Expand Down
4 changes: 4 additions & 0 deletions app/GraphQL/Mutations/UpdatePinnedTestMeasurementOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use App\Models\Project;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\Log;

final class UpdatePinnedTestMeasurementOrder extends AbstractMutation
{
Expand Down Expand Up @@ -57,6 +58,9 @@ public function __invoke(null $_, array $args): self

$this->pinnedTestMeasurements = $project?->pinnedTestMeasurements()->orderBy('position')->get();

$user = auth()->user();
Log::info("User {$user?->id} updated pinned test measurement order for project {$project?->id}.");

return $this;
}
}
4 changes: 4 additions & 0 deletions app/GraphQL/Mutations/UpdateProject.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use App\Models\Project;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\Log;

final class UpdateProject extends AbstractMutation
{
Expand All @@ -26,6 +27,9 @@ public function __invoke(null $_, array $args): self

$this->project = $project;

$user = auth()->user();
Log::info("User {$user?->id} updated project {$project?->id}.");

return $this;
}
}
3 changes: 3 additions & 0 deletions app/GraphQL/Mutations/UpdateSiteDescription.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Exceptions\GraphQLMutationException;
use App\Models\Site;
use App\Models\User;
use Illuminate\Support\Facades\Log;

final class UpdateSiteDescription extends AbstractMutation
{
Expand Down Expand Up @@ -41,6 +42,8 @@ public function __invoke(null $_, array $args): self
$newSiteInformation['description'] = $args['description'];
$site->information()->create($newSiteInformation);

Log::info("User {$user->id} updated description for site {$site->id}.");

$this->site = $site;

return $this;
Expand Down