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\Mail;
7
8use Illuminate\Bus\Queueable;
9use Illuminate\Contracts\Queue\ShouldQueue;
10use Illuminate\Mail\Mailable;
11use Illuminate\Queue\SerializesModels;
12
13class BeatmapsetUpdateNotice extends Mailable implements ShouldQueue
14{
15 use Queueable, SerializesModels;
16
17 public $tries = 5;
18
19 private $watch;
20
21 /**
22 * Create a new message instance.
23 *
24 * @return void
25 */
26 public function __construct($attributes)
27 {
28 $this->watch = $attributes['watch'];
29 }
30
31 /**
32 * Build the message.
33 *
34 * @return $this
35 */
36 public function build()
37 {
38 if ($this->watch === null) {
39 return;
40 }
41
42 $beatmapset = $this->watch->beatmapset;
43 $user = $this->watch->user;
44
45 if ($beatmapset === null || $user === null) {
46 return;
47 }
48
49 return $this
50 ->text('emails.beatmapset.update_notice')
51 ->subject(osu_trans('mail.beatmapset_update_notice.subject', [
52 'title' => $beatmapset->getDisplayTitle($user),
53 ]))
54 ->with(compact('beatmapset', 'user'));
55 }
56}