M3 Integration fixes
This commit is contained in:
Regular → Executable
+12
-19
@@ -13,8 +13,8 @@ namespace Modules\Helpdesk\Services;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
use Modules\Helpdesk\Models\GitCommit;
|
||||
use Modules\Helpdesk\Models\GitRepository;
|
||||
use Modules\Helpdesk\Models\GitWebhookLog;
|
||||
@@ -23,6 +23,8 @@ use Throwable;
|
||||
|
||||
final class GitWebhookIngestionService
|
||||
{
|
||||
private const PUSH_HOOK = 'push hook';
|
||||
|
||||
/**
|
||||
* Matches the generated Helpdesk reference format, for example HD-2026-00042.
|
||||
*/
|
||||
@@ -173,10 +175,10 @@ final class GitWebhookIngestionService
|
||||
|
||||
return match ($normalisedProvider) {
|
||||
'github' => in_array($normalisedEvent, ['push', ''], true),
|
||||
'gitlab' => in_array($normalisedEvent, ['push hook', 'push', ''], true),
|
||||
'gitea' => in_array($normalisedEvent, ['push', 'push hook', ''], true),
|
||||
'gitlab' => in_array($normalisedEvent, [self::PUSH_HOOK, 'push', ''], true),
|
||||
'gitea' => in_array($normalisedEvent, ['push', self::PUSH_HOOK, ''], true),
|
||||
'bitbucket' => in_array($normalisedEvent, ['repo push', 'push', ''], true),
|
||||
default => in_array($normalisedEvent, ['push', 'repo push', 'push hook', ''], true),
|
||||
default => in_array($normalisedEvent, ['push', 'repo push', self::PUSH_HOOK, ''], true),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -214,23 +216,14 @@ final class GitWebhookIngestionService
|
||||
{
|
||||
$commits = $payload['commits'] ?? null;
|
||||
|
||||
if (is_array($commits) && $commits !== []) {
|
||||
return array_values(array_filter($commits, static fn (mixed $commit): bool => is_array($commit)));
|
||||
if (! is_array($commits) || $commits === []) {
|
||||
$headCommit = $payload['head_commit'] ?? null;
|
||||
$commits = is_array($headCommit) ? [$headCommit] : Arr::get($payload, 'push.changes.0.commits', []);
|
||||
}
|
||||
|
||||
$headCommit = $payload['head_commit'] ?? null;
|
||||
|
||||
if (is_array($headCommit)) {
|
||||
return [$headCommit];
|
||||
}
|
||||
|
||||
$bitbucketCommits = Arr::get($payload, 'push.changes.0.commits', []);
|
||||
|
||||
if (is_array($bitbucketCommits)) {
|
||||
return array_values(array_filter($bitbucketCommits, static fn (mixed $commit): bool => is_array($commit)));
|
||||
}
|
||||
|
||||
return [];
|
||||
return is_array($commits)
|
||||
? array_values(array_filter($commits, static fn (mixed $commit): bool => is_array($commit)))
|
||||
: [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user