the browser-facing portion of osu!
at master 61 lines 1.6 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\Notification; 10use App\Models\User; 11use App\Models\UserNotificationOption; 12 13abstract class BeatmapsetNotification extends BroadcastNotificationBase 14{ 15 const NOTIFICATION_OPTION_NAME = UserNotificationOption::BEATMAPSET_MODDING; 16 17 protected $beatmapset; 18 19 public static function getMailLink(Notification $notification): string 20 { 21 return route('beatmapsets.show', $notification->notifiable_id); 22 } 23 24 public function __construct(Beatmapset $beatmapset, ?User $source = null) 25 { 26 parent::__construct($source); 27 28 $this->beatmapset = $beatmapset; 29 } 30 31 public function displayName() 32 { 33 return static::class." (Beatmapset {$this->beatmapset->getKey()})"; 34 } 35 36 public function getDetails(): array 37 { 38 return [ 39 'title' => $this->beatmapset->title, 40 'title_unicode' => $this->beatmapset->title_unicode, 41 'cover_url' => $this->beatmapset->coverURL('card'), 42 ]; 43 } 44 45 public function getListeningUserIds(): array 46 { 47 return $this->beatmapset->watches()->pluck('user_id')->all(); 48 } 49 50 public function getNotifiable() 51 { 52 return $this->beatmapset; 53 } 54 55 public function handle() 56 { 57 $this->beatmapset->watches()->update(['last_notified' => $this->getTimestamp()]); 58 59 parent::handle(); 60 } 61}