Skip to content

Conversation

@Jean-Beru
Copy link
Contributor

Add Webhook component integration.

Webhook URLs fallback to the component's one (/webhook/gotenberg) if no configuration is set.

@Jean-Beru Jean-Beru force-pushed the add-webhook-component-integration branch 8 times, most recently from 9b8c0c4 to c5809a8 Compare November 21, 2024 20:42
@Jean-Beru Jean-Beru force-pushed the add-webhook-component-integration branch from c5809a8 to 8c8d531 Compare November 21, 2024 20:44
@Jean-Beru Jean-Beru marked this pull request as ready for review November 21, 2024 20:46
service('sensiolabs_gotenberg.asset.base_dir_formatter'),
service('.sensiolabs_gotenberg.webhook_configuration_registry'),
service('request_stack'),
service('router')->nullOnInvalid(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still no desire to clean this file ? 👼

$services->set('.sensiolabs_gotenberg.builder')
    ->abstract()   
    ->args([
        service('sensiolabs_gotenberg.client'),
        service('sensiolabs_gotenberg.asset.base_dir_formatter'),
        service('.sensiolabs_gotenberg.webhook_configuration_registry'),
        service('request_stack'),
        service('router')->nullOnInvalid(),
    ])
    ->call('setLogger', [service('logger')->nullOnInvalid()])
;

$services->set('.sensiolabs_gotenberg.pdf_builder.markdown', MarkdownPdfBuilder::class)
    ->parent('.sensiolabs_gotenberb.builder')
    ->share(false)
    ->tag('sensiolabs_gotenberg.pdf_builder')
;

// ... 

Or... even better: introduce a BuilderFactory ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still no desire to clean this file ? 👼

I want to clean this file. I did it in a PoC about refactoring builder: #118

Or... even better: introduce a BuilderFactory ?

I also planned to test that 😉


return new SuccessGotenbergEvent(
$id,
$request->getContent(true),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is messenger able to serialize a resource ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

I'll make some tests. It coud depend on the transport used (ex: 512Mb fot RabbitMQ)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmmm. That would mean that we might need to save the file beforehand ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get how it works... the "resource" here is some form POST data, right ? So there is a limit in Symfony itself to receive the form data, no ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Jean-Beru : where we at on this matter ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Paused for now since I'm focus on the #118.

FYI, I'll try to introduce a StoreInterface that can be used to store PDF before sending the Messenger message. This interface could also be used as (or instead) processors to save files.

Comment on lines +14 to +24
public function __construct(
string $id,
mixed $file,
private readonly string $filename,
private readonly string $contentType,
private readonly int $contentLength,
) {
$payload['file'] = $file;

parent::__construct(self::SUCCESS, $id, $payload);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure i would create array like this :|

Copy link
Contributor Author

@Jean-Beru Jean-Beru Nov 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow. I missed that one 😄

Besides, is it still relevant to add the file in $payload instead of adding an other private property?

throw new MissingRequiredFieldException('->webhookUrl() was never called.');
}
$successWebhookUrl = $this->successWebhookUrl;
if (!$successWebhookUrl) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strict ?

}
$successWebhookUrl = $this->successWebhookUrl;
if (!$successWebhookUrl) {
if (!$this->urlGenerator) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strict ?

AssetBaseDirFormatter $asset,
WebhookConfigurationRegistryInterface $webhookConfigurationRegistry,
private readonly RequestStack $requestStack,
UrlGeneratorInterface|null $urlGenerator = null,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better to be consistent with parent construct. I suggest to switch with the request stack.

AssetBaseDirFormatter $asset,
WebhookConfigurationRegistryInterface $webhookConfigurationRegistry,
private readonly RequestStack $requestStack,
UrlGeneratorInterface|null $urlGenerator = null,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

switch with request stack


return new SuccessGotenbergEvent(
$id,
$request->getContent(true),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmmm. That would mean that we might need to save the file beforehand ?

{
"status": 500,
"message": "An error occurred."
} No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EOF

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants