the browser-facing portion of osu!
at master 57 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 ChannelAnnouncement extends BroadcastNotificationBase 13{ 14 const DELIVERY_MODE_DEFAULTS = ['mail' => true, 'push' => true]; 15 16 protected $message; 17 18 public static function getBaseKey(Notification $notification): string 19 { 20 return 'channel.announcement.announce'; 21 } 22 23 public static function getMailLink(Notification $notification): string 24 { 25 return route('chat.index', ['channel_id' => $notification->notifiable_id]); 26 } 27 28 public function __construct(Message $message, User $source) 29 { 30 parent::__construct($source); 31 32 $this->message = $message; 33 } 34 35 public function getDetails(): array 36 { 37 $channel = $this->message->channel; 38 39 return [ 40 'channel_id' => $channel->getKey(), 41 'name' => $channel->name, 42 'title' => truncate($this->message->content, static::CONTENT_TRUNCATE), 43 'type' => strtolower($channel->type), 44 'cover_url' => $this->source->user_avatar, 45 ]; 46 } 47 48 public function getListeningUserIds(): array 49 { 50 return $this->message->channel->userIds(); 51 } 52 53 public function getNotifiable() 54 { 55 return $this->message->channel; 56 } 57}