<?php

namespace App\Classes\FTN\Process\Netmail;

use Illuminate\Support\Facades\Notification;
use Illuminate\Support\Facades\Log;

use App\Classes\FTN\Process;
use App\Models\{Echomail,Netmail};
use App\Notifications\Netmails\Ping as PingNotification;

/**
 * Process messages to Ping
 *
 * @package App\Classes\FTN\Process
 */
final class Ping extends Process
{
	private const LOGKEY = 'RP-';

	public static function handle(Echomail|Netmail $mo): bool
	{
		if (strtolower($mo->to) !== 'ping')
			return FALSE;

		Log::info(sprintf('%s:- Processing PING message from (%s) [%s]',self::LOGKEY,$mo->from,$mo->fftn->ftn));

		Notification::route('netmail',$mo->fftn)->notify(new PingNotification($mo));

		return TRUE;
	}
}