Skip to content

Commit

Permalink
Save null value to database when response body is empty and translate…
Browse files Browse the repository at this point in the history
… it in view to proper text
  • Loading branch information
hluchas authored and dongilbert committed Apr 14, 2020
1 parent 57e4c5b commit b25c98e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/bundles/WebhookBundle/Model/WebhookModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ public function processWebhook(Webhook $webhook, WebhookQueue $queue = null)

$responseBody = $response->getBody()->getContents();
if (!$responseBody) {
$responseBody = '<<< Empty response body received >>>'; // Empty response body mark for log
$responseBody = null; // Save null value to database
}

$responseStatusCode = $response->getStatusCode();
Expand Down
1 change: 1 addition & 0 deletions app/bundles/WebhookBundle/Translations/en_US/messages.ini
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ mautic.webhook.webhook.header.edit="Edit Webhook"
mautic.webhook.webhook.header.new="Create New Webhook"
mautic.webhook.webhook.logs.desc="These are the logs for this hook. Each time an event triggers this hook to be activated we record the HTTP response header. A successful response should be a 200 header. All other responses are considered an error."
mautic.webhook.webhook.logs.title="Webhook Response Log"
mautic.webhook.webhook.logs.empty.response="Empty response body received"
mautic.webhook.webhook.menu.index="Webhooks"
mautic.webhook.webhook_url="Webhook Url"
mautic.webhook.webhooks="Webhooks"
Expand Down
9 changes: 8 additions & 1 deletion app/bundles/WebhookBundle/Views/Webhook/details.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,14 @@
]);
?>
</td>
<td><?php echo $log->getNote(); ?></td>
<td><?php
$note = $log->getNote();
if ($note) :
echo $note;
else :
echo $view['translator']->trans('mautic.webhook.webhook.logs.empty.response');
endif;
?></td>
<td><?php echo $log->getRuntime(); ?> s</td>
<td><?php echo $view['date']->toFull($log->getDateAdded()); ?></td>
</tr>
Expand Down

0 comments on commit b25c98e

Please sign in to comment.