Telegram notifications tmp fix
This commit is contained in:
parent
633aaa381f
commit
1e1a224531
|
@ -81,12 +81,18 @@ class UpdateAvailabilityWithSchedulesJob implements ShouldQueue
|
|||
$text = "🚒 Distaccamento operativo con squadra completa";
|
||||
}
|
||||
if(!is_null($text)) {
|
||||
//Find message hash
|
||||
$hash = md5($text);
|
||||
|
||||
$chat_ids = TelegramBotNotifications::where("type_team_state", true)
|
||||
->whereNot("last_message_hash", $hash)
|
||||
->get()->pluck('chat_id')->toArray();
|
||||
|
||||
foreach ($chat_ids as $chat_id) {
|
||||
$chat = Telegraph::chat($chat_id);
|
||||
$chat->message($text)->send();
|
||||
TelegramBotNotifications::where("chat_id", $chat_id)
|
||||
->update(["last_message_hash" => $hash]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ class TelegramBotNotifications extends Model
|
|||
*/
|
||||
protected $fillable = [
|
||||
'chat_id',
|
||||
'type_team_state'
|
||||
'type_team_state',
|
||||
'last_message_hash'
|
||||
];
|
||||
}
|
||||
|
|
|
@ -44,12 +44,18 @@ class Availability {
|
|||
$text = "🧯 Distaccamento operativo per supporto";
|
||||
}
|
||||
if(!is_null($text)) {
|
||||
//Find message hash
|
||||
$hash = md5($text);
|
||||
|
||||
$chat_ids = TelegramBotNotifications::where("type_team_state", true)
|
||||
->whereNot("last_message_hash", $hash)
|
||||
->get()->pluck('chat_id')->toArray();
|
||||
|
||||
foreach ($chat_ids as $chat_id) {
|
||||
$chat = Telegraph::chat($chat_id);
|
||||
$chat->message($text)->send();
|
||||
TelegramBotNotifications::where("chat_id", $chat_id)
|
||||
->update(["last_message_hash" => $hash]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ return new class extends Migration
|
|||
$table->id();
|
||||
$table->string('chat_id')->unique();
|
||||
$table->boolean('type_team_state')->default(true);
|
||||
$table->varchar('last_message_hash')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue