in src/LegacyEventMapper.php [180:217]
private function convertRawPubsubPayload(array $jsonData, string $requestUriPath): array
{
$path_match = preg_match('#projects/[^/?]+/topics/[^/?]+#', $requestUriPath, $matches);
if ($path_match) {
$topic = $matches[0];
} else {
$topic = 'UNKNOWN_PUBSUB_TOPIC';
$this->stderrStructuredWarn('Failed to extract the topic name from the URL path.');
$this->stderrStructuredWarn(
'Configure your subscription\'s push endpoint to use the following path: ' .
'projects/PROJECT_NAME/topics/TOPIC_NAME'
);
}
if (array_key_exists('publishTime', $jsonData['message'])) {
$timestamp = $jsonData['message']['publishTime'];
} else {
$timestamp = gmdate('%Y-%m-%dT%H:%M:%S.%6NZ');
}
return [
'context' => [
'eventId' => $jsonData['message']['messageId'],
'timestamp' => $timestamp,
'eventType' => self::PUBSUB_CE_EVENT_TYPE,
'resource' => [
'service' => self::PUBSUB_CE_SERVICE,
'type' => self::LEGACY_PUBSUB_MESSAGE_TYPE,
'name' => $topic,
],
],
'data' => [
'@type' => self::LEGACY_PUBSUB_MESSAGE_TYPE,
'data' => $jsonData['message']['data'],
'attributes' => $jsonData['message']['attributes'],
],
];
}