-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Messenger] Add AvailableAtStamp to delay messages until fixed DateTime #36512
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
Conversation
I have given more thought to this PR and I would like two things to be discussed.
$timezone = new DateTimeZone('UTC');
$availableAt = new DateTime(
$availableAtStamp
->getAvailableAt()
->format('Y-m-d H:i:s'),
$timezone
);
$now = new DateTime(
(new DateTime())
->format('Y-m-d H:i:s'),
$timezone
);
$delay = $availableAt->getTimestamp() - $now->getTimestamp();
|
What's the status here? It looks like there is an unrelated commit. |
Can't we add a |
@ogizanagi I agree, it could be a really good idea |
I like @ogizanagi idea. |
I was thinking the same! Maybe |
We've just moved away from |
As linked by @maxhelias , I've just proposed the exact same thing in #38459 (sorry for the duplication)...
|
I've send a new PR: #38480 |
…:delayUntil() (Nyholm) This PR was squashed before being merged into the 5.x branch. Discussion ---------- [Messenger] Add DelayStamp::delayFor() and DelayStamp::delayUntil() | Q | A | ------------- | --- | Branch? | 5.x | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | Fix #38141 | License | MIT | Doc PR | This PR will revert the work by @Toflar in #38141. He added some helper methods and I want to add a generic factory method that adds a DateInterval. This PR will also close #38480 and fix #38459. It is also related to a comment in #36512 (comment) that was liked by a few people. Maybe adding both `DelayStamp::delayFor(\DateInterval)` and `DelayStamp::delayUntil(\DateTimeInterface)` is overkill. But this covers all the bases and I hope that it will be the last change to this small class. Commits ------- c5de1eb [Messenger] Add DelayStamp::delayFor() and DelayStamp::delayUntil()
An AvailableAtStamp and an AvailableAtStampMiddleware have been added to allow posponing a message to a fixed date and time. Internally, the middleware calculates the difference in milliseconds between the desired date and the current date and adds a DelayStamp to the envelope.