Replies: 1 comment 2 replies
-
@freekmurze Thanks for looking into this! I'm a bit confused about the current status of this item, as to me this is clearly a bug and not an "idea" (as per the category above). |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
We've come across an interesting example. Take the following code sample:
You will see that the value after
json_encode
changes. We have an actual production piece of code that behaves similarly to this special payload.The problem with laravel-webhook-server is the following:
As an immediate correction, we serialized and unserialized our payload:
I see two possibilities moving forward.
1. Serializing once
To me, the crux of the issue is that the headers should be generated at the same moment as the body. I suggest to
getAllHeaders
toCallWebhookJob
(https://github.com/spatie/laravel-webhook-server/blob/main/src/WebhookCall.php#L249-L262)handle
function and serialize the payload only once (https://github.com/spatie/laravel-webhook-server/blob/main/src/CallWebhookJob.php#L70-L72)We would lose the headers in the job trail, but to me, this is not a huge loss.
2. Accepting only string payloads
Taking a step back, it doesn't seem like this library's job to serialize the payload. You could require the payload to be a string and generate the signature in the same way. Strings are still mutable so it would be worth implementing solution 1 too.
The drawback is that by doing this you would be breaking your current interface so it would require extra work to make sure that a backward-compatible mechanism remains.
We're ready at my company (Ocus) to help make those changes and submit a PR. Could you let us know which solution you prefer or if you'd like another one?
Beta Was this translation helpful? Give feedback.
All reactions