public function ackSend(array $message, array $payload, $earliestGet = 0, $priority = 0.0, $newTimestamp = true)
{
$id = null;
if (array_key_exists('id', $message)) {
$id = $message['id'];
}
if (!is_a($id, 'MongoDB\\BSON\\ObjectID')) {
throw new \InvalidArgumentException('$message does not have a field "id" that is a ObjectID');
}
if (!is_int($earliestGet)) {
throw new \InvalidArgumentException('$earliestGet was not an int');
}
if (!is_float($priority)) {
throw new \InvalidArgumentException('$priority was not a float');
}
if (is_nan($priority)) {
throw new \InvalidArgumentException('$priority was NaN');
}
if ($newTimestamp !== true && $newTimestamp !== false) {
throw new \InvalidArgumentException('$newTimestamp was not a bool');
}
//Ensure $earliestGet is between 0 and MONGO_INT32_MAX
$earliestGet = min(max(0, $earliestGet * 1000), self::MONGO_INT32_MAX);
$toSet = ['payload' => $payload, 'running' => false, 'resetTimestamp' => new \MongoDB\BSON\UTCDateTime(self::MONGO_INT32_MAX), 'earliestGet' => new \MongoDB\BSON\UTCDateTime($earliestGet), 'priority' => $priority];
if ($newTimestamp) {
$toSet['created'] = new \MongoDB\BSON\UTCDateTime((int) (microtime(true) * 1000));
}
//using upsert because if no documents found then the doc was removed (SHOULD ONLY HAPPEN BY SOMEONE MANUALLY)
//so we can just send
$this->collection->updateOne(['_id' => $id], ['$set' => $toSet], ['upsert' => true]);
}