<?php

namespace App\Classes\FTN\Process\Netmail;

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

use App\Classes\FTN\{Message,Process};
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(Message $msg): bool
	{
		if (strtolower($msg->user_to) !== 'ping')
			return FALSE;

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

		Notification::route('netmail',$msg->fftn_o)->notify(new PingNotification($msg));

		return TRUE;
	}
}