the browser-facing portion of osu!
at master 53 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\Beatmapset; 9use App\Models\Follow; 10use App\Models\Notification; 11use App\Models\UserNotificationOption; 12 13abstract class UserBeatmapsetNewBase extends BroadcastNotificationBase 14{ 15 const NOTIFICATION_OPTION_NAME = UserNotificationOption::MAPPING; 16 17 protected $beatmapset; 18 19 public static function getMailLink(Notification $notification): string 20 { 21 return route('beatmapsets.show', $notification->details['beatmapset_id']); 22 } 23 24 public function __construct(Beatmapset $beatmapset) 25 { 26 parent::__construct($beatmapset->user); 27 28 $this->beatmapset = $beatmapset; 29 } 30 31 public function getDetails(): array 32 { 33 return [ 34 'beatmapset_id' => $this->beatmapset->getKey(), 35 'title' => $this->beatmapset->title, 36 'title_unicode' => $this->beatmapset->title_unicode, 37 'cover_url' => $this->beatmapset->coverURL('card'), 38 ]; 39 } 40 41 public function getListeningUserIds(): array 42 { 43 return Follow::whereNotifiable($this->beatmapset->user) 44 ->where(['subtype' => 'mapping']) 45 ->pluck('user_id') 46 ->all(); 47 } 48 49 public function getNotifiable() 50 { 51 return $this->beatmapset->user; 52 } 53}