Skip to content

Commit

Permalink
Merge pull request #3295 from HDInnovations/7.x.x
Browse files Browse the repository at this point in the history
(Release) v7.1.3
  • Loading branch information
HDVinnie committed Dec 14, 2023
2 parents c904aea + a9cb692 commit cb1f6c2
Show file tree
Hide file tree
Showing 31 changed files with 1,055 additions and 597 deletions.
81 changes: 0 additions & 81 deletions app/Console/Commands/AutoCheckPeerConnectivity.php

This file was deleted.

7 changes: 5 additions & 2 deletions app/Console/Commands/AutoGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,11 @@ public function handle(ByteUnits $byteUnits): void
$user->save();
}

cache()->forget('user:'.$user->passkey);
Unit3dAnnounce::addUser($user);
if ($user->wasChanged()) {
cache()->forget('user:'.$user->passkey);

Unit3dAnnounce::addUser($user);
}
}

$this->comment('Automated User Group Command Complete');
Expand Down
3 changes: 3 additions & 0 deletions app/Console/Commands/AutoRemoveFeaturedTorrent.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use App\Models\FeaturedTorrent;
use App\Models\Torrent;
use App\Repositories\ChatRepository;
use App\Services\Unit3dAnnounce;
use Illuminate\Console\Command;
use Illuminate\Support\Carbon;

Expand Down Expand Up @@ -70,6 +71,8 @@ public function handle(): void
$this->chatRepository->systemMessage(
sprintf('Ladies and Gents, [url=%s/torrents/%s]%s[/url] is no longer featured. :poop:', $appurl, $torrent->id, $torrent->name)
);

Unit3dAnnounce::addTorrent($torrent);
}

// Delete The Record From DB
Expand Down
5 changes: 5 additions & 0 deletions app/Console/Commands/AutoRemoveTimedTorrentBuffs.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

use App\Models\Torrent;
use App\Repositories\ChatRepository;
use App\Services\Unit3dAnnounce;
use Illuminate\Console\Command;
use Illuminate\Support\Carbon;

Expand Down Expand Up @@ -63,6 +64,8 @@ public function handle(): void
$this->chatRepository->systemMessage(
sprintf('Ladies and Gents, [url=%s/torrents/%s]%s[/url] timed freeleech buff has expired.', $appurl, $torrent->id, $torrent->name)
);

Unit3dAnnounce::addTorrent($torrent);
}

$duTorrents = Torrent::whereNotNull('du_until')->where('du_until', '<', Carbon::now()->toDateTimeString())->get();
Expand All @@ -76,6 +79,8 @@ public function handle(): void
$this->chatRepository->systemMessage(
sprintf('Ladies and Gents, [url=%s/torrents/%s]%s[/url] timed double upload buff has expired.', $appurl, $torrent->id, $torrent->name)
);

Unit3dAnnounce::addTorrent($torrent);
}

$this->comment('Automated Removal Of Expired Torrent Buffs Command Complete');
Expand Down
3 changes: 3 additions & 0 deletions app/Console/Commands/AutoRewardResurrection.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use App\Models\Torrent;
use App\Models\User;
use App\Repositories\ChatRepository;
use App\Services\Unit3dAnnounce;
use Illuminate\Console\Command;
use Illuminate\Support\Carbon;

Expand Down Expand Up @@ -90,6 +91,8 @@ public function handle(): void
);
$torrent->save();

Unit3dAnnounce::addTorrent($torrent);

// Send Private Message
$pm = new PrivateMessage();
$pm->sender_id = 1;
Expand Down
5 changes: 3 additions & 2 deletions app/Console/Commands/AutoUpsertPeers.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ public function handle(): void
/**
* MySql can handle a max of 65k placeholders per query,
* and there are 15 fields on each peer that are updated.
* (`active`, `agent`, `created_at`, `downloaded`, `id`, `ip`, `left`, `peer_id`, `port`, `seeder`, `torrent_id`, `updated_at`, `uploaded`, `user_id`).
* (`active`, `agent`, `connectable`, `created_at`, `downloaded`, `id`, `ip`, `left`, `peer_id`, `port`, `seeder`, `torrent_id`, `updated_at`, `uploaded`, `user_id`).
*/
$peerPerCycle = intdiv(65_000, 14);
$peerPerCycle = intdiv(65_000, 15);

$key = config('cache.prefix').':peers:batch';
$peerCount = Redis::connection('announce')->command('LLEN', [$key]);
Expand Down Expand Up @@ -79,6 +79,7 @@ public function handle(): void
'seeder',
'torrent_id',
'user_id',
'connectable',
'active'
],
);
Expand Down
1 change: 0 additions & 1 deletion app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ protected function schedule(Schedule $schedule): void
$schedule->command('auto:update_user_last_actions')->everyFiveSeconds();
$schedule->command('auto:delete_stopped_peers')->everyTwoMinutes();
$schedule->command('auto:cache_user_leech_counts')->everyThirtyMinutes();
$schedule->command('auto:check_peer_connectivity')->everyThirtyMinutes()->runInBackground();
$schedule->command('auto:group ')->daily();
$schedule->command('auto:nerdstat ')->hourly();
$schedule->command('auto:reward_resurrection')->daily();
Expand Down
7 changes: 7 additions & 0 deletions app/Helpers/Bbcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,13 @@ class Bbcode
'closeHtml' => '</tr>',
'block' => true,
],
'table-header' => [
'openBbcode' => '/^\[th\]/i',
'closeBbcode' => '[/th]',
'openHtml' => '<th>',
'closeHtml' => '</th>',
'block' => true,
],
'table-data' => [
'openBbcode' => '/^\[td\]/i',
'closeBbcode' => '[/td]',
Expand Down
36 changes: 15 additions & 21 deletions app/Http/Controllers/AnnounceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
namespace App\Http\Controllers;

use App\Exceptions\TrackerException;
use App\Jobs\ProcessAnnounce;
use App\Models\BlacklistClient;
use App\Models\FreeleechToken;
use App\Models\Group;
Expand Down Expand Up @@ -717,27 +718,20 @@ private function processAnnounceJob(array $queries, object $user, object $group,
]);
}

/**
* Peer batch upsert.
*
* @see \App\Console\Commands\AutoUpsertPeers
*/
Redis::connection('announce')->command('RPUSH', [
config('cache.prefix').':peers:batch',
serialize([
'peer_id' => $queries['peer_id'],
'ip' => $queries['ip-address'],
'port' => $queries['port'],
'agent' => $queries['user-agent'],
'uploaded' => $queries['uploaded'],
'downloaded' => $queries['downloaded'],
'left' => $queries['left'],
'seeder' => $queries['left'] == 0,
'torrent_id' => $torrent->id,
'user_id' => $user->id,
'active' => $event !== 'stopped',
])
]);
// Peer update
ProcessAnnounce::dispatch(
bin2hex($queries['peer_id']),
bin2hex($queries['ip-address']),
$queries['port'],
bin2hex($queries['user-agent']),
$queries['uploaded'],
$queries['downloaded'],
$queries['left'],
$queries['left'] == 0,
$torrent->id,
$user->id,
$event !== 'stopped',
);

/**
* History batch upsert.
Expand Down
32 changes: 32 additions & 0 deletions app/Http/Controllers/ExternalTorrentController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
/**
* NOTICE OF LICENSE.
*
* UNIT3D Community Edition is open-sourced software licensed under the GNU Affero General Public License v3.0
* The details is bundled with this project in the file LICENSE.txt.
*
* @project UNIT3D Community Edition
*
* @author Roardom <roardom@protonmail.com>
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
*/

namespace App\Http\Controllers;

use App\Models\Torrent;
use App\Services\Unit3dAnnounce;

class ExternalTorrentController extends Controller
{
/**
* Display the torrent stored on the external tracker.
*/
public function show(int $id): \Illuminate\Contracts\View\Factory|\Illuminate\View\View
{
return view('torrent.external-tracker', [
'id' => $id,
'torrent' => Torrent::find($id),
'externalTorrent' => Unit3dAnnounce::getTorrent($id),
]);
}
}
7 changes: 3 additions & 4 deletions app/Http/Controllers/Staff/GroupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
use App\Models\Forum;
use App\Models\Group;
use App\Models\Permission;
use App\Models\User;
use App\Services\Unit3dAnnounce;
use Illuminate\Support\Str;

Expand Down Expand Up @@ -64,6 +63,8 @@ public function store(StoreGroupRequest $request): \Illuminate\Http\RedirectResp
]);
}

Unit3dAnnounce::addGroup($group);

return to_route('staff.groups.index')
->withSuccess('Group Was Created Successfully!');
}
Expand All @@ -87,9 +88,7 @@ public function update(UpdateGroupRequest $request, Group $group): \Illuminate\H

cache()->forget('group:'.$group->id);

foreach (User::whereBelongsTo($group)->get() as $user) {
Unit3dAnnounce::addUser($user);
}
Unit3dAnnounce::addGroup($group);

return to_route('staff.groups.index')
->withSuccess('Group Was Updated Successfully!');
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/User/PasskeyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ protected function update(Request $request, User $user): \Illuminate\Http\Redire

cache()->forget('user:'.$user->passkey);

Unit3dAnnounce::removeUser($user);

DB::transaction(static function () use ($user, $changedByStaff): void {
$user->passkeys()->latest()->first()?->update(['deleted_at' => now()]);

Expand All @@ -68,7 +70,6 @@ protected function update(Request $request, User $user): \Illuminate\Http\Redire
}
});

Unit3dAnnounce::removeUser($user);
Unit3dAnnounce::addUser($user);

return to_route('users.passkeys.index', ['user' => $user])
Expand Down
4 changes: 3 additions & 1 deletion app/Http/Controllers/User/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use App\Models\Invite;
use App\Models\Peer;
use App\Models\User;
use App\Services\Unit3dAnnounce;
use Assada\Achievements\Model\AchievementProgress;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
Expand Down Expand Up @@ -102,7 +103,8 @@ public function show(User $user): \Illuminate\Contracts\View\Factory|\Illuminate
->selectRaw('SUM(active = 0) as inactive')
->where('user_id', '=', $user->id)
->first(),
'watch' => $user->watchlist,
'watch' => $user->watchlist,
'externalUser' => $user->group->is_modo ? Unit3dAnnounce::getUser($user->id) : null,
]);
}

Expand Down
Loading

0 comments on commit cb1f6c2

Please sign in to comment.