-
Notifications
You must be signed in to change notification settings - Fork 387
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add submission-relevant events to database via LIO endpoints #11741
Merged
+94
−15
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,19 +88,14 @@ public static function generate($type, $options) | |
|
||
case 'beatmapsetApprove': | ||
$beatmapset = $options['beatmapset']; | ||
|
||
$beatmapsetUrl = e(route('beatmapsets.show', $beatmapset, false)); | ||
$beatmapsetTitle = e($beatmapset->artist.' - '.$beatmapset->title); | ||
$userName = e($beatmapset->user->username); | ||
$userUrl = e(route('users.show', $beatmapset->user, false)); | ||
$beatmapsetParams = static::beatmapsetParams($beatmapset); | ||
$userParams = static::userParams($options['beatmapset']->user); | ||
$approval = e($beatmapset->status()); | ||
|
||
$textCleanBeatmapsetUrl = $GLOBALS['cfg']['app']['url'].$beatmapsetUrl; | ||
$textCleanUserUrl = $GLOBALS['cfg']['app']['url'].$userUrl; | ||
$textClean = "[{$textCleanBeatmapsetUrl} {$beatmapsetTitle}] by [{$textCleanUserUrl} {$userName}] has just been {$approval}!"; | ||
$textClean = "[{$beatmapsetParams['url_clean']} {$beatmapsetParams['title']}] by [{$userParams['url_clean']} {$userParams['username']}] has just been {$approval}!"; | ||
|
||
$params = [ | ||
'text' => "<a href='{$beatmapsetUrl}'>{$beatmapsetTitle}</a> by <b><a href='{$userUrl}'>{$userName}</a></b> has just been {$approval}!", | ||
'text' => "<a href='{$beatmapsetParams['url']}'>{$beatmapsetParams['title']}</a> by <b><a href='{$userParams['url']}'>{$userParams['username']}</a></b> has just been {$approval}!", | ||
'text_clean' => $textClean, | ||
'beatmap_id' => 0, | ||
'beatmapset_id' => $beatmapset->getKey(), | ||
|
@@ -113,11 +108,10 @@ public static function generate($type, $options) | |
|
||
case 'beatmapsetDelete': | ||
$beatmapset = $options['beatmapset']; | ||
$beatmapsetUrl = e(route('beatmapsets.show', $beatmapset, false)); | ||
$beatmapsetTitle = e($beatmapset->artist.' - '.$beatmapset->title); | ||
$beatmapsetParams = static::beatmapsetParams($beatmapset); | ||
|
||
$params = [ | ||
'text' => "<a href='{$beatmapsetUrl}'>{$beatmapsetTitle}</a> has been deleted.", | ||
'text' => "<a href='{$beatmapsetParams['url']}'>{$beatmapsetParams['title']}</a> has been deleted.", | ||
'beatmapset_id' => $beatmapset->getKey(), | ||
'user_id' => $options['user']->getKey(), | ||
'private' => false, | ||
|
@@ -126,6 +120,63 @@ public static function generate($type, $options) | |
|
||
break; | ||
|
||
case 'beatmapsetRevive': | ||
$beatmapset = $options['beatmapset']; | ||
$beatmapsetParams = static::beatmapsetParams($beatmapset); | ||
$userParams = static::userParams($beatmapset->user); | ||
|
||
$textClean = "[{$beatmapsetParams['url_clean']} {$beatmapsetParams['title']}] has been revived from eternal slumber by [{$userParams['url_clean']} {$userParams['username']}]"; | ||
|
||
$params = [ | ||
'text' => "<a href='{$beatmapsetParams['url']}'>{$beatmapsetParams['title']}</a> has been revived from eternal slumber by <b><a href='{$userParams['url']}'>{$userParams['username']}</a></b>", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing period |
||
'text_clean' => $textClean, | ||
'beatmapset_id' => $beatmapset->getKey(), | ||
'user_id' => $beatmapset->user->getKey(), | ||
'private' => false, | ||
'epicfactor' => 5, | ||
]; | ||
|
||
break; | ||
|
||
case 'beatmapsetUpdate': | ||
$beatmapset = $options['beatmapset']; | ||
$beatmapsetParams = static::beatmapsetParams($beatmapset); | ||
// retrieved separately from options because it doesn't necessarily need to be the same user | ||
// as $beatmapset->user in some cases (see: direct guest difficulty update) | ||
$user = $options['user']; | ||
$userParams = static::userParams($user); | ||
|
||
$textClean = "[{$userParams['url_clean']} {$userParams['username']}] has updated the beatmap [{$beatmapsetParams['url_clean']} {$beatmapsetParams['title']}]"; | ||
|
||
$params = [ | ||
'text' => "<b><a href='{$userParams['url']}'>{$userParams['username']}</a></b> has updated the beatmap \"<a href='{$beatmapsetParams['url']}'>{$beatmapsetParams['title']}</a>\"", | ||
'text_clean' => $textClean, | ||
'beatmapset_id' => $beatmapset->getKey(), | ||
'user_id' => $user->getKey(), | ||
'private' => false, | ||
'epicfactor' => 2, | ||
]; | ||
|
||
break; | ||
|
||
case 'beatmapsetUpload': | ||
$beatmapset = $options['beatmapset']; | ||
$beatmapsetParams = static::beatmapsetParams($beatmapset); | ||
$userParams = static::userParams($beatmapset->user); | ||
|
||
$textClean = "[{$userParams['url_clean']} {$userParams['username']}] has submitted a new beatmap [{$beatmapsetParams['url_clean']} {$beatmapsetParams['title']}]"; | ||
|
||
$params = [ | ||
'text' => "<b><a href='{$userParams['url']}'>{$userParams['username']}</a></b> has submitted a new beatmap \"<a href='{$beatmapsetParams['url']}'>{$beatmapsetParams['title']}\"</a>", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. closing quote should be after |
||
'text_clean' => $textClean, | ||
'beatmapset_id' => $beatmapset->getKey(), | ||
'user_id' => $beatmapset->user->getKey(), | ||
'private' => false, | ||
'epicfactor' => 4, | ||
]; | ||
|
||
break; | ||
|
||
case 'usernameChange': | ||
$user = static::userParams($options['user']); | ||
$oldUsername = e($options['history']->username_last); | ||
|
@@ -430,10 +481,22 @@ public function scopeRecent($query) | |
|
||
private static function userParams($user) | ||
{ | ||
$url = e(route('users.show', $user, false)); | ||
return [ | ||
'id' => $user->getKey(), | ||
'username' => e($user->username), | ||
'url' => e(route('users.show', $user, false)), | ||
'url' => $url, | ||
'url_clean' => $GLOBALS['cfg']['app']['url'].$url, | ||
]; | ||
} | ||
|
||
private static function beatmapsetParams($beatmapset) | ||
{ | ||
$url = e(route('beatmapsets.show', $beatmapset, false)); | ||
return [ | ||
'title' => e($beatmapset->artist.' - '.$beatmapset->title), | ||
'url' => $url, | ||
'url_clean' => $GLOBALS['cfg']['app']['url'].$url, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it's better to have same template string for both
text
andtextClean
and fill it up withsprintf
accordingly, kinda similar to how it was originally doneThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean like b2937ec?
I'd say it's a beneficial change yeah, because only thanks to it I noticed two of the events I added had quotes missing in the
text_clean
variant that should have been there 😅