the browser-facing portion of osu!
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #11706 from bdach/bss2-editable-description

Automatically create beatmap set description topic on edit if missing

authored by

Edho Arief and committed by
GitHub
f80b526a 4a1d92a5

+34 -23
+1
.env.example
··· 101 # INITIAL_HELP_FORUM_IDS="5 47 85" 102 # ISSUE_FORUM_IDS= 103 # FORUM_POST_MINIMUM_PLAYS=200 104 105 PUSHER_APP_ID= 106 PUSHER_KEY=
··· 101 # INITIAL_HELP_FORUM_IDS="5 47 85" 102 # ISSUE_FORUM_IDS= 103 # FORUM_POST_MINIMUM_PLAYS=200 104 + # BEATMAP_DESCRIPTION_FORUM_ID=6 105 106 PUSHER_APP_ID= 107 PUSHER_KEY=
+32 -23
app/Models/Beatmapset.php
··· 29 use App\Libraries\ImageProcessorService; 30 use App\Libraries\StorageUrl; 31 use App\Libraries\Transactions\AfterCommit; 32 use App\Traits\Memoizes; 33 use App\Traits\Validatable; 34 use App\Transformers\BeatmapsetTransformer; ··· 1406 1407 public function updateDescription($bbcode, $user) 1408 { 1409 - $post = $this->descriptionPost; 1410 - if ($post === null) { 1411 - return; 1412 - } 1413 1414 - $split = preg_split('/-{15}/', $post->post_text, 2); 1415 1416 - $options = [ 1417 - 'withGallery' => true, 1418 - 'ignoreLineHeight' => true, 1419 - ]; 1420 1421 - $header = new BBCodeFromDB($split[0], $post->bbcode_uid, $options); 1422 - $newBody = $header->toEditor()."---------------\n".ltrim($bbcode); 1423 1424 - return $post 1425 - ->skipBeatmapPostRestrictions() 1426 - ->update([ 1427 - 'post_text' => $newBody, 1428 - 'post_edit_user' => $user === null ? null : $user->getKey(), 1429 - ]); 1430 } 1431 1432 private function extractDescription($post) ··· 1443 1444 private function getBBCode() 1445 { 1446 - $post = $this->descriptionPost; 1447 - 1448 - if ($post === null) { 1449 - return; 1450 - } 1451 - 1452 $description = $this->extractDescription($post); 1453 1454 $options = [
··· 29 use App\Libraries\ImageProcessorService; 30 use App\Libraries\StorageUrl; 31 use App\Libraries\Transactions\AfterCommit; 32 + use App\Models\Forum\Post; 33 use App\Traits\Memoizes; 34 use App\Traits\Validatable; 35 use App\Transformers\BeatmapsetTransformer; ··· 1407 1408 public function updateDescription($bbcode, $user) 1409 { 1410 + return DB::transaction(function () use ($bbcode, $user) { 1411 + $post = $this->descriptionPost; 1412 1413 + if ($post === null) { 1414 + $forum = Forum\Forum::findOrFail($GLOBALS['cfg']['osu']['forum']['beatmap_description_forum_id']); 1415 + $title = $this->artist.' - '.$this->title; 1416 1417 + $topic = Forum\Topic::createNew($forum, [ 1418 + 'title' => $title, 1419 + 'user' => $user, 1420 + 'body' => '---------------', 1421 + ]); 1422 + $topic->lock(); 1423 + $this->update(['thread_id' => $topic->getKey()]); 1424 + $post = $topic->firstPost; 1425 + } 1426 1427 + $split = preg_split('/-{15}/', $post->post_text, 2); 1428 1429 + $options = [ 1430 + 'withGallery' => true, 1431 + 'ignoreLineHeight' => true, 1432 + ]; 1433 + 1434 + $header = new BBCodeFromDB($split[0], $post->bbcode_uid, $options); 1435 + $newBody = $header->toEditor()."---------------\n".ltrim($bbcode); 1436 + 1437 + return $post 1438 + ->skipBeatmapPostRestrictions() 1439 + ->update([ 1440 + 'post_text' => $newBody, 1441 + 'post_edit_user' => $user === null ? null : $user->getKey(), 1442 + ]); 1443 + }); 1444 } 1445 1446 private function extractDescription($post) ··· 1457 1458 private function getBBCode() 1459 { 1460 + $post = $this->descriptionPost ?? new Post(); 1461 $description = $this->extractDescription($post); 1462 1463 $options = [
+1
config/osu.php
··· 127 'issue_forum_ids' => array_map('intval', explode(' ', env('ISSUE_FORUM_IDS', '4 5 29 30 101'))), 128 'max_post_length' => get_int(env('FORUM_POST_MAX_LENGTH')) ?? 60000, 129 'minimum_plays' => get_int(env('FORUM_POST_MINIMUM_PLAYS')) ?? 200, 130 'necropost_months' => 6, 131 'old_months' => 1, 132 'poll_edit_hours' => get_int(env('FORUM_POLL_EDIT_HOURS')) ?? 1,
··· 127 'issue_forum_ids' => array_map('intval', explode(' ', env('ISSUE_FORUM_IDS', '4 5 29 30 101'))), 128 'max_post_length' => get_int(env('FORUM_POST_MAX_LENGTH')) ?? 60000, 129 'minimum_plays' => get_int(env('FORUM_POST_MINIMUM_PLAYS')) ?? 200, 130 + 'beatmap_description_forum_id' => get_int(env('BEATMAP_DESCRIPTION_FORUM_ID')) ?? 6, 131 'necropost_months' => 6, 132 'old_months' => 1, 133 'poll_edit_hours' => get_int(env('FORUM_POLL_EDIT_HOURS')) ?? 1,