Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove base64_encode/decode of the payload. #78

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion src/Jobs/PubSubJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function getJobId()
*/
public function getRawBody()
{
return base64_decode($this->job->data());
return $this->job->data();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/PubSubQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function pushRaw($payload, $queue = null, array $options = [])

$this->subscribeToTopic($topic);

$publish = ['data' => base64_encode($payload)];
$publish = ['data' => $payload];

if (! empty($options)) {
$publish['attributes'] = $this->validateMessageAttributes($options);
Expand Down Expand Up @@ -204,7 +204,7 @@ public function bulk($jobs, $data = '', $queue = null)

foreach ((array) $jobs as $job) {
$payload = $this->createPayload($job, $this->getQueue($queue), $data);
$payloads[] = ['data' => base64_encode($payload)] + (isset($job->orderingKey) ? ['orderingKey' => $job->orderingKey] : []);
$payloads[] = ['data' => $payload] + (isset($job->orderingKey) ? ['orderingKey' => $job->orderingKey] : []);
}

$topic = $this->getTopic($this->getQueue($queue), $this->topicAutoCreation);
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Jobs/PubSubJobTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ protected function setUp(): void
{
$this->messageId = '1234';
$this->messageData = json_encode(['id' => $this->messageId, 'foo' => 'bar']);
$this->messageEncodedData = base64_encode($this->messageData);
$this->messageEncodedData = $this->messageData;

$this->container = $this->createMock(Container::class);
$this->queue = $this->createMock(PubSubQueue::class);
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/PubSubQueueTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function testPushRaw(): void
$this->topic->method('publish')
->willReturn($this->expectedResult)
->with($this->callback(function ($publish) use ($payload) {
$decoded_payload = base64_decode($publish['data']);
$decoded_payload = $publish['data'];

return $decoded_payload === $payload;
}));
Expand Down Expand Up @@ -203,7 +203,7 @@ public function testPopWhenJobsAvailable(): void
->willReturn($this->topic);

$this->message->method('data')
->willReturn(base64_encode(json_encode(['foo' => 'bar'])));
->willReturn(json_encode(['foo' => 'bar']));

$this->queue->setContainer($this->createMock(Container::class));

Expand Down Expand Up @@ -275,7 +275,7 @@ public function testBulk(): void
->method('publishBatch')
->willReturn($this->expectedResult)
->with($this->callback(function ($payloads) use ($jobs, $data) {
$decoded_payload = json_decode(base64_decode($payloads[0]['data']), true);
$decoded_payload = json_decode($payloads[0]['data'], true);

return $decoded_payload['job'] === $jobs[0] && $decoded_payload['data'] === $data;
}));
Expand Down