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\Beatmap;
9use App\Models\Notification;
10use App\Models\User;
11
12class BeatmapOwnerChange extends BroadcastNotificationBase
13{
14 const NOTIFICATION_OPTION_NAME = Notification::BEATMAP_OWNER_CHANGE;
15
16 protected $beatmap;
17 protected $beatmapset;
18
19 public static function getMailLink(Notification $notification): string
20 {
21 return route('beatmapsets.discussion', [
22 'beatmap' => '-',
23 'beatmapset' => $notification->notifiable_id,
24 'mode' => 'events',
25 ]);
26 }
27
28 public function __construct(Beatmap $beatmap, User $source)
29 {
30 parent::__construct($source);
31
32 $this->beatmap = $beatmap;
33 $this->beatmapset = $beatmap->beatmapset;
34 }
35
36 public function getDetails(): array
37 {
38 return [
39 'beatmap_id' => $this->beatmap->getKey(),
40 'cover_url' => $this->beatmapset->coverURL('card'),
41 'title' => $this->beatmapset->title,
42 'title_unicode' => $this->beatmapset->title_unicode,
43 'version' => $this->beatmap->version,
44 ];
45 }
46
47 public function getListeningUserIds(): array
48 {
49 return $this->beatmap->beatmapOwners()->pluck('user_id')->all();
50 }
51
52 public function getNotifiable()
53 {
54 return $this->beatmapset;
55 }
56
57 public function getReceiverIds(): array
58 {
59 return $this->getListeningUserIds();
60 }
61}