Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions app/Bots/IRCAnnounceBotExternal.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public static function postAnnounceMsg(Torrent $torrent): bool
return false;
}

$appurl = config('app.url');
$announceTypeEnum = 0; // 0 NEW

$originEnum = match (true) {
Expand Down Expand Up @@ -73,7 +72,7 @@ public static function postAnnounceMsg(Torrent $torrent): bool

return self::post([
'id' => $torrent->id,
'url' => \sprintf('%s/torrents/%d', $appurl, $torrent->id),
'url' => href_torrent($torrent),
'name' => $torrent->name,
'uploader' => $torrent->anon ? 'Anonymous' : $torrent->user->username,
'size' => $torrent->getSize(),
Expand Down
4 changes: 1 addition & 3 deletions app/Console/Commands/AutoRemoveFeaturedTorrent.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,8 @@ final public function handle(): void
$featuredTorrent->delete();

// Auto Announce Featured Expired
$appurl = config('app.url');

$this->chatRepository->systemMessage(
\sprintf('Ladies and Gents, [url=%s/torrents/%s]%s[/url] is no longer featured.', $appurl, $featuredTorrent->torrent_id, $featuredTorrent->torrent->name)
\sprintf('Ladies and Gents, [url=%s]%s[/url] is no longer featured.', route('torrents.show', ['id' => $featuredTorrent->torrent_id]), $featuredTorrent->torrent->name)
);

Unit3dAnnounce::removeFeaturedTorrent($featuredTorrent->torrent_id);
Expand Down
4 changes: 1 addition & 3 deletions app/Console/Commands/AutoRewardResurrection.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,8 @@ final public function handle(): void
$resurrection->user->increment('fl_tokens', (int) config('graveyard.reward'));

// Auto Shout
$appurl = config('app.url');

$this->chatRepository->systemMessage(
\sprintf('Ladies and Gents, [url=%s/users/%s]%s[/url] has successfully resurrected [url=%s/torrents/%s]%s[/url].', $appurl, $resurrection->user->username, $resurrection->user->username, $appurl, $resurrection->torrent->id, $resurrection->torrent->name)
\sprintf('Ladies and Gents, [url=%s]%s[/url] has successfully resurrected [url=%s]%s[/url].', href_profile($resurrection->user), $resurrection->user->username, href_torrent($resurrection->torrent), $resurrection->torrent->name)
);

// Bump Torrent With FL
Expand Down
47 changes: 10 additions & 37 deletions app/Helpers/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,46 +13,31 @@
* @author HDVinnie <[email protected]>
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
*/
if (!\function_exists('appurl')) {
function appurl(): string
{
return config('app.url');
}
}

if (!\function_exists('href_profile')) {
function href_profile(App\Models\User $user): string
{
$appurl = appurl();

return \sprintf('%s/users/%s', $appurl, $user->username);
return route('users.show', ['user' => $user]);
}
}

if (!\function_exists('href_article')) {
function href_article(App\Models\Article $article): string
{
$appurl = appurl();

return \sprintf('%s/articles/%s', $appurl, $article->id);
return route('articles.show', ['article' => $article]);
}
}

if (!\function_exists('href_torrent')) {
function href_torrent(App\Models\Torrent $torrent): string
{
$appurl = appurl();

return \sprintf('%s/torrents/%s', $appurl, $torrent->id);
return route('torrents.show', ['id' => $torrent]);
}
}

if (!\function_exists('href_request')) {
function href_request(App\Models\TorrentRequest $torrentRequest): string
{
$appurl = appurl();

return \sprintf('%s/requests/%s', $appurl, $torrentRequest->id);
return route('requests.show', ['torrentRequest' => $torrentRequest]);
}
}

Expand All @@ -69,54 +54,42 @@ function href_rottentomatoes(string|null $title, string|null $date): string
if (!\function_exists('href_poll')) {
function href_poll(App\Models\Poll $poll): string
{
$appurl = appurl();

return \sprintf('%s/polls/%s', $appurl, $poll->id);
return route('polls.show', ['poll' => $poll]);
}
}

if (!\function_exists('href_playlist')) {
function href_playlist(App\Models\Playlist $playlist): string
{
$appurl = appurl();

return \sprintf('%s/playlists/%s', $appurl, $playlist->id);
return route('playlists.show', ['playlist' => $playlist]);
}
}

if (!\function_exists('href_collection')) {
function href_collection(App\Models\TmdbCollection $collection): string
{
$appurl = appurl();

return \sprintf('%s/mediahub/collections/%s', $appurl, $collection->id);
return route('mediahub.collections.show', ['id' => $collection]);
}
}

if (!\function_exists('href_movie')) {
function href_movie(App\Models\TmdbMovie $movie, App\Models\Category $category): string
{
$appurl = appurl();

return \sprintf('%s/torrents/similar/%s.%s', $appurl, $category->id, $movie->id);
return route('torrents.similar', ['tmdb' => $movie->id, 'category_id' => $category->id]);
}
}

if (!\function_exists('href_tv')) {
function href_tv(App\Models\TmdbTv $tv, App\Models\Category $category): string
{
$appurl = appurl();

return \sprintf('%s/torrents/similar/%s.%s', $appurl, $category->id, $tv->id);
return route('torrents.similar', ['tmdb' => $tv->id, 'category_id' => $category->id]);
}
}

if (!\function_exists('href_game')) {
function href_game(App\Models\IgdbGame $game, App\Models\Category $category): string
{
$appurl = appurl();

return \sprintf('%s/torrents/similar/%s.%s', $appurl, $category->id, $game->id);
return route('torrents.similar', ['tmdb' => $game->id, 'category_id' => $category->id]);
}
}

Expand Down
4 changes: 1 addition & 3 deletions app/Helpers/TorrentHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ class TorrentHelper
{
public static function approveHelper(int $id): void
{
$appurl = config('app.url');

$torrent = Torrent::query()->with('user')->withoutGlobalScope(ApprovedScope::class)->findOrFail($id);
$torrent->created_at = now();
$torrent->bumped_at = now();
Expand Down Expand Up @@ -144,7 +142,7 @@ public static function approveHelper(int $id): void
.'[TMDB vote average: '.($meta->vote_average ?? 0).'] '
.'[TMDB vote count: '.($meta->vote_count ?? 0).']'
)
->say(\sprintf('[Link: %s/torrents/', $appurl).$id.']');
->say(\sprintf('[Link: %s]', href_torrent($torrent)));
}

// Announce to external IRC service
Expand Down
29 changes: 8 additions & 21 deletions app/Http/Controllers/API/TorrentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,6 @@ public function store(Request $request): \Illuminate\Http\JsonResponse

// check for trusted user & mod queue isn't opted in and update torrent
if ($user->group->is_trusted && !$request->boolean('mod_queue_opt_in')) {
$appurl = config('app.url');
$user = $torrent->user;
$username = $user->username;
$anon = $torrent->anon;
Expand All @@ -437,56 +436,44 @@ public function store(Request $request): \Illuminate\Http\JsonResponse
// Announce To Shoutbox
if (!$anon) {
$this->chatRepository->systemMessage(
\sprintf('User [url=%s/users/', $appurl).$username.']'.$username.\sprintf('[/url] has uploaded a new '.$torrent->category->name.'. [url=%s/torrents/', $appurl).$torrent->id.']'.$torrent->name.'[/url], grab it now!'
'User [url='.href_profile($user).']'.$username.'[/url] has uploaded a new '.$torrent->category->name.'. [url='.href_torrent($torrent).']'.$torrent->name.'[/url], grab it now!'
);
} else {
$this->chatRepository->systemMessage(
\sprintf('An anonymous user has uploaded a new '.$torrent->category->name.'. [url=%s/torrents/', $appurl).$torrent->id.']'.$torrent->name.'[/url], grab it now!'
'An anonymous user has uploaded a new '.$torrent->category->name.'. [url='.href_torrent($torrent).']'.$torrent->name.'[/url], grab it now!'
);
}

if ($anon && $featured == 1) {
$this->chatRepository->systemMessage(
\sprintf('Ladies and Gents, [url=%s/torrents/', $appurl).$torrent->id.']'.$torrent->name.'[/url] has been added to the Featured Torrents Slider by an anonymous user! Grab It While You Can!'
'Ladies and Gents, [url='.href_torrent($torrent).$torrent->id.']'.$torrent->name.'[/url] has been added to the Featured Torrents Slider by an anonymous user! Grab It While You Can!'
);
} elseif (!$anon && $featured == 1) {
$this->chatRepository->systemMessage(
\sprintf('Ladies and Gents, [url=%s/torrents/', $appurl).$torrent->id.']'.$torrent->name.\sprintf('[/url] has been added to the Featured Torrents Slider by [url=%s/users/', $appurl).$username.']'.$username.'[/url]! Grab It While You Can!'
'Ladies and Gents, [url='.href_torrent($torrent).']'.$torrent->name.'[/url] has been added to the Featured Torrents Slider by [url='.href_profile($user).']'.$username.'[/url]! Grab It While You Can!'
);
}

if ($free >= 1 && $featured == 0) {
if ($torrent->fl_until === null) {
$this->chatRepository->systemMessage(
\sprintf(
'Ladies and Gents, [url=%s/torrents/',
$appurl
).$torrent->id.']'.$torrent->name.'[/url] has been granted '.$free.'% FreeLeech! Grab It While You Can!'
'Ladies and Gents, [url='.href_torrent($torrent).']'.$torrent->name.'[/url] has been granted '.$free.'% FreeLeech! Grab It While You Can!'
);
} else {
$this->chatRepository->systemMessage(
\sprintf(
'Ladies and Gents, [url=%s/torrents/',
$appurl
).$torrent->id.']'.$torrent->name.'[/url] has been granted '.$free.'% FreeLeech for '.$request->input('fl_until').' days.'
'Ladies and Gents, [url='.href_torrent($torrent).']'.$torrent->name.'[/url] has been granted '.$free.'% FreeLeech for '.$request->input('fl_until').' days.'
);
}
}

if ($doubleup == 1 && $featured == 0) {
if ($torrent->du_until === null) {
$this->chatRepository->systemMessage(
\sprintf(
'Ladies and Gents, [url=%s/torrents/',
$appurl
).$torrent->id.']'.$torrent->name.'[/url] has been granted Double Upload! Grab It While You Can!'
'Ladies and Gents, [url='.href_torrent($torrent).']'.$torrent->name.'[/url] has been granted Double Upload! Grab It While You Can!'
);
} else {
$this->chatRepository->systemMessage(
\sprintf(
'Ladies and Gents, [url=%s/torrents/',
$appurl
).$torrent->id.']'.$torrent->name.'[/url] has been granted Double Upload for '.$request->input('du_until').' days.'
'Ladies and Gents, [url='.href_torrent($torrent).']'.$torrent->name.'[/url] has been granted Double Upload for '.$request->input('du_until').' days.'
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/PlaylistController.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function store(StorePlaylistRequest $request): \Illuminate\Http\RedirectR
// Announce To Shoutbox
if (!$playlist->is_private) {
$this->chatRepository->systemMessage(
\sprintf('User [url=%s/', config('app.url')).$request->user()->username.'.'.$request->user()->id.']'.$request->user()->username.\sprintf('[/url] has created a new playlist [url=%s/playlists/', config('app.url')).$playlist->id.']'.$playlist->name.'[/url] check it out now!'
'User [url='.href_profile($request->user()).']'.$request->user()->username.'[/url] has created a new playlist [url='.href_playlist($playlist).']'.$playlist->name.'[/url] check it out now!'
);
}

Expand Down
9 changes: 4 additions & 5 deletions app/Http/Controllers/PostController.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,9 @@ public function store(Request $request): \Illuminate\Http\RedirectResponse
]);

// Post To Chatbox and Notify Subscribers
$appUrl = config('app.url');
$postUrl = \sprintf('%s/forums/topics/%s/posts/%s', $appUrl, $topic->id, $post->id);
$realUrl = \sprintf('/forums/topics/%s/posts/%s', $topic->id, $post->id);
$profileUrl = \sprintf('%s/users/%s', $appUrl, $user->username);
$postUrl = route('topics.permalink', ['topicId' => $topic->id, 'postId' => $post->id]);
$realUrl = route('topics.permalink', ['topicId' => $topic->id, 'postId' => $post->id], false);
$profileUrl = href_profile($user);

if (config('other.staff-forum-notify') && ($forum->id == config('other.staff-forum-id') || $forum->forum_category_id == config('other.staff-forum-id'))) {
$staffers = User::query()
Expand Down Expand Up @@ -212,7 +211,7 @@ public function update(Request $request, int $id): \Illuminate\Http\RedirectResp
$user = $request->user();

$post = Post::query()->findOrFail($id);
$postUrl = \sprintf('forums/topics/%s/posts/%s', $post->topic->id, $id);
$postUrl = route('topics.permalink', ['topicId' => $post->topic->id, 'postId' => $id], false);

abort_unless($user->group->is_modo || $user->id === $post->user_id, 403);

Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/Staff/ModerationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ public function update(UpdateModerationRequest $request, int $id): \Illuminate\H
// Announce To Shoutbox
if (!$torrent->anon) {
$this->chatRepository->systemMessage(
\sprintf('User [url=%s/users/', config('app.url')).$torrent->user->username.']'.$torrent->user->username.\sprintf('[/url] has uploaded a new '.$torrent->category->name.'. [url=%s/torrents/', config('app.url')).$id.']'.$torrent->name.'[/url], grab it now!'
'User [url='.href_profile($torrent->user).']'.$torrent->user->username.'[/url] has uploaded a new '.$torrent->category->name.'. [url='.href_torrent($torrent).']'.$torrent->name.'[/url], grab it now!'
);
} else {
$this->chatRepository->systemMessage(
\sprintf('An anonymous user has uploaded a new '.$torrent->category->name.'. [url=%s/torrents/', config('app.url')).$id.']'.$torrent->name.'[/url], grab it now!'
'An anonymous user has uploaded a new '.$torrent->category->name.'. [url='.href_torrent($torrent).']'.$torrent->name.'[/url], grab it now!'
);
}

Expand Down
5 changes: 2 additions & 3 deletions app/Http/Controllers/TopicController.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,8 @@ public function store(Request $request, int $id): \Illuminate\Http\RedirectRespo
]);

// Post To ShoutBox
$appUrl = config('app.url');
$topicUrl = \sprintf('%s/forums/topics/%s', $appUrl, $topic->id);
$profileUrl = \sprintf('%s/users/%s', $appUrl, $user->username);
$topicUrl = route('topics.show', ['id' => $topic->id]);
$profileUrl = href_profile($user);

if (config('other.staff-forum-notify') && ($forum->id == config('other.staff-forum-id') || $forum->forum_category_id == config('other.staff-forum-id'))) {
$staffers = User::query()
Expand Down
4 changes: 1 addition & 3 deletions app/Http/Controllers/TorrentBuffController.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,8 @@ public function revokeFeatured(Request $request, int $id): \Illuminate\Http\Redi

Unit3dAnnounce::removeFeaturedTorrent($torrent->id);

$appurl = config('app.url');

$this->chatRepository->systemMessage(
\sprintf('Ladies and Gents, [url=%s/torrents/%s]%s[/url] is no longer featured.', $appurl, $torrent->id, $torrent->name)
\sprintf('Ladies and Gents, [url=%s]%s[/url] is no longer featured.', href_torrent($torrent), $torrent->name)
);

$featured_torrent->delete();
Expand Down
7 changes: 3 additions & 4 deletions app/Http/Controllers/TorrentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -628,25 +628,24 @@ public function store(StoreTorrentRequest $request): \Illuminate\Http\RedirectRe

// check for trusted user and update torrent
if ($user->group->is_trusted && !$request->boolean('mod_queue_opt_in')) {
$appurl = config('app.url');
$user = $torrent->user;
$username = $user->username;
$anon = $torrent->anon;

// Announce To Shoutbox
if (!$anon) {
$this->chatRepository->systemMessage(
\sprintf('User [url=%s/users/', $appurl).$username.']'.$username.\sprintf('[/url] has uploaded a new '.$torrent->category->name.'. [url=%s/torrents/', $appurl).$torrent->id.']'.$torrent->name.'[/url], grab it now!'
'User [url='.href_profile($user).']'.$username.'[/url] has uploaded a new '.$torrent->category->name.'. [url='.href_torrent($torrent).']'.$torrent->name.'[/url], grab it now!'
);
} else {
$this->chatRepository->systemMessage(
\sprintf('An anonymous user has uploaded a new '.$torrent->category->name.'. [url=%s/torrents/', $appurl).$torrent->id.']'.$torrent->name.'[/url], grab it now!'
'An anonymous user has uploaded a new '.$torrent->category->name.'. [url='.href_torrent($torrent).']'.$torrent->name.'[/url], grab it now!'
);
}

if ($torrent->free >= 1) {
$this->chatRepository->systemMessage(
\sprintf('Ladies and Gents, [url=%s/torrents/', $appurl).$torrent->id.']'.$torrent->name.'[/url] has been granted '.$torrent->free.'% FreeLeech! Grab It While You Can!'
'Ladies and Gents, [url='.href_torrent($torrent).']'.$torrent->name.'[/url] has been granted '.$torrent->free.'% FreeLeech! Grab It While You Can!'
);
}

Expand Down
2 changes: 1 addition & 1 deletion app/Notifications/NewBon.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function toArray(object $notifiable): array
return [
'title' => $this->gift->sender->username.' gifted you '.$this->gift->bon.' BON',
'body' => $this->gift->sender->username.' gifted you '.$this->gift->bon.' BON. Note: '.$this->gift->message,
'url' => \sprintf('/users/%s', $this->gift->sender->username),
'url' => route('users.show', ['user' => $this->gift->sender], false),
];
}
}
6 changes: 3 additions & 3 deletions app/Notifications/NewPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,22 +98,22 @@ public function toArray(User $notifiable): array
return [
'title' => $username.' posted in a subscribed topic',
'body' => $username.' posted in subscribed topic: '.$this->post->topic->name,
'url' => \sprintf('/forums/topics/%s/posts/%s', $this->post->topic->id, $this->post->id),
'url' => route('topics.permalink', ['topicId' => $this->post->topic->id, 'postId' => $this->post->id], false),
];
}

if ($this->type == 'staff') {
return [
'title' => $username.' posted in a staff forum topic',
'body' => $username.' posted in staff topic: '.$this->post->topic->name,
'url' => \sprintf('%s/posts/%s', route('topics.show', ['id' => $this->post->topic->id]), $this->post->id),
'url' => route('topics.permalink', ['topicId' => $this->post->topic->id, 'postId' => $this->post->id], false),
];
}

return [
'title' => $username.' posted in a topic you started',
'body' => $username.' posted in your topic: '.$this->post->topic->name,
'url' => \sprintf('/forums/topics/%s/posts/%s', $this->post->topic->id, $this->post->id),
'url' => route('topics.permalink', ['topicId' => $this->post->topic->id, 'postId' => $this->post->id], false),
];
}
}
Loading
Loading