Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8495deb

Browse files
committed
Don't send attributes if it's empty
1 parent 46929e0 commit 8495deb

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

‎pkg/gps/GpsProducer.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,14 @@ public function send(Destination $destination, Message $message): void
3737

3838
/** @var Topic $topic */
3939
$topic = $this->context->getClient()->topic($destination->getTopicName());
40-
$topic->publish([
41-
'data' => json_encode($message),
42-
'attributes' => $message->getAttributes(),
43-
]);
40+
41+
$params = ['data' => json_encode($message)];
42+
43+
if (count($message->getAttributes()) > 0) {
44+
$params['attributes'] = $message->getAttributes();
45+
}
46+
47+
$topic->publish($params);
4448
}
4549

4650
public function setDeliveryDelay(?int $deliveryDelay = null): Producer

‎pkg/gps/Tests/GpsProducerTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ public function testShouldSendMessage()
3535
->method('publish')
3636
->with($this->identicalTo([
3737
'data' => '{"body":"","properties":[],"headers":[]}',
38-
'attributes' => [],
3938
])
4039
);
4140

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /