<commit_before><?php namespace App\Jobs;

use App\Jobs\Job;
use App\Notification;
use Httpful\Request;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Bus\SelfHandling;
use Illuminate\Contracts\Queue\ShouldQueue;

/**
 * Sends notification to slack
 */
class Notify extends Job implements SelfHandling, ShouldQueue
{
    use InteractsWithQueue, SerializesModels;

    private $payload;
    private $notification;

    /**
     * Create a new command instance.
     *
     * @param Notification $notification
     * @param array $payload
     * @return Notify
     */
    public function __construct(Notification $notification, array $payload)
    {
        $this->notification = $notification;
        $this->payload = $payload;
    }

    /**
     * Execute the command.
     *
     * @return void
     */
    public function handle()
    {
        $payload = [
            'channel' => $this->notification->channel
        ];

        if (!empty($this->notification->icon)) {
            $icon_field = 'icon_url';
            if (preg_match('/:(.*):/', $this->notification->icon)) {
                $icon_field = 'icon_emoji';
            }

            $payload[$icon_field] = $this->notification->icon;
        }

        $payload = array_merge($payload, $this->payload);

        Request::post($this->notification->webhook)
               ->sendsJson()
               ->body($payload)
               ->send();
    }
}<commit_msg>Update Notify.php<commit_after><?php namespace App\Listeners\Events;

use App\Jobs\Notify as SlackNotify;
use App\Jobs\MailDeployNotification;
use App\Jobs\RequestProjectCheckUrl;
use App\Events\DeployFinished;

use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\DispatchesJobs;

/**
 * When a deploy finished, notify the followed user.
 */
class Notify implements ShouldQueue
{
    use InteractsWithQueue, DispatchesJobs;

    /**
     * Create the event handler.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Handle the event.
     *
     * @param  DeployFinished  $event
     * @return void
     */
    public function handle(DeployFinished $event)
    {
        $project = $event->project;
        $deployment = $event->deployment;

        foreach ($project->notifications as $notification) {
            $this->dispatch(new SlackNotify($notification, $deployment->notificationPayload()));
        }

        //Send email notification
        $this->dispatch(new MailDeployNotification($project, $deployment));

        //Trigger to check the project urls
        foreach ($project->checkUrls as $url) {
            $this->dispatch(new RequestProjectCheckUrl($url));
        }
    }
}
{'fraction_non_alphanumeric': 0.12081254454739843, 'fraction_numerical': 0.0, 'mean_word_length': 2.4912935323383083, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7177616', 'n_tokens_mistral': 791, 'n_tokens_neox': 790, 'n_words': 172}