the browser-facing portion of osu!
at master 54 lines 1.5 kB view raw
1<?php 2 3// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0. 4// See the LICENCE file in the repository root for full licence text. 5 6namespace App\Jobs\Notifications; 7 8use App\Models\Chat\Message; 9use App\Models\Notification; 10use App\Models\User; 11 12class ChannelMessage extends BroadcastNotificationBase 13{ 14 const NOTIFICATION_OPTION_NAME = Notification::CHANNEL_MESSAGE; 15 16 protected $message; 17 18 public static function getBaseKey(Notification $notification): string 19 { 20 return "channel.channel.{$notification->details['type']}"; 21 } 22 23 public static function getMailLink(Notification $notification): string 24 { 25 // TODO: probably should enable linking to a channel directly... 26 return route('chat.index', ['sendto' => $notification->source_user_id]); 27 } 28 29 public function __construct(Message $message, User $source) 30 { 31 parent::__construct($source); 32 33 $this->message = $message; 34 } 35 36 public function getDetails(): array 37 { 38 return [ 39 'title' => truncate($this->message->content, static::CONTENT_TRUNCATE), 40 'type' => strtolower($this->message->channel->type), 41 'cover_url' => $this->source->user_avatar, 42 ]; 43 } 44 45 public function getListeningUserIds(): array 46 { 47 return $this->message->channel->userIds(); 48 } 49 50 public function getNotifiable() 51 { 52 return $this->message->channel; 53 } 54}