In my application (laravel 8) i create some messages, store them in a postgrey database and send them via webhook to discord ans slack. I can choose to send them right away or delay them with a datetime in the database.
Here is my problem. I dont know how to trigger an event for sending them via webhook when the due date arrive.
For now my only solution is each minute to get all the unsend message from the database, check the due datetime of each message and send them if they match the current datetime.
I would like to create a delay event/job with the intervall beetween now and the due date when i store a delay message in my database.
I create a message at 09/04/2021 at 16h00 with a sending date at 10/04/2021 at 16h00
An event with a delay of 24h is created for sending the message via my webhook later. Of course the delay change with each message i created and it can be from a few minutes to several days.
I look at queue job and event in laravel 8 but i can't find something that work
Here is my migration for Message Models
public function up()
{
Schema::create('messages', function (Blueprint $table) {
$table->id();
$table->timestamps();
$table->text('text');
$table->datetime('date_message');
$table->boolean('delay');
$table->boolean('discord');
$table->boolean('slack');
$table->boolean('status');
$table->biginteger('user_id');
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
});
}
date_message is the date I want my message to be sent
Sorry for my bad english, hope you can help me find a solution