the browser-facing portion of osu!
at master 45 lines 1.4 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\Beatmap; 9use App\Models\Notification; 10use App\Models\UserNotificationOption; 11 12class BeatmapsetDiscussionQualifiedProblem extends BeatmapsetDiscussionPostNotification 13{ 14 const NOTIFICATION_OPTION_NAME = UserNotificationOption::BEATMAPSET_MODDING; 15 16 public function getListeningUserIds(): array 17 { 18 $beatmap = $this->beatmapsetDiscussionPost->beatmap; 19 20 if ($beatmap === null) { 21 $modes = $this->beatmapsetDiscussionPost->beatmapset->playmodes()->all(); 22 } else { 23 $modes = [$beatmap->playmode]; 24 } 25 26 $modes = array_map(function ($modeInt) { 27 return Beatmap::modeStr($modeInt); 28 }, $modes); 29 30 $ids = []; 31 32 UserNotificationOption 33 ::where(['name' => Notification::BEATMAPSET_DISCUSSION_QUALIFIED_PROBLEM]) 34 ->whereNotNull('details') 35 ->chunkById(1000, function ($options) use (&$ids, $modes) { 36 foreach ($options as $option) { 37 if (count(array_intersect($option->details['modes'] ?? [], $modes)) > 0) { 38 $ids[] = $option->user_id; 39 } 40 } 41 }); 42 43 return $ids; 44 } 45}