Initial commit
This commit is contained in:
22
app/Observers/ConversationObserver.php
Normal file
22
app/Observers/ConversationObserver.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Observers;
|
||||
|
||||
use Namu\WireChat\Models\Conversation;
|
||||
|
||||
class ConversationObserver
|
||||
{
|
||||
/**
|
||||
* Handle the Conversation "created" event.
|
||||
*/
|
||||
public function created(Conversation $conversation): void
|
||||
{
|
||||
// Automatically set disappearing fields (always enabled to prevent orphaned messages)
|
||||
$durationInDays = timebank_config('wirechat.disappearing_messages.duration', 30);
|
||||
$durationInSeconds = $durationInDays * 86400; // Convert days to seconds
|
||||
|
||||
$conversation->disappearing_started_at = now();
|
||||
$conversation->disappearing_duration = $durationInSeconds;
|
||||
$conversation->save();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user