Added handling of the "playerId" parameter to InitOrGetGroups.

This commit is contained in:
Vari
2024-03-06 21:40:32 +01:00
parent 80e736d878
commit d1b8e65624
2 changed files with 14 additions and 1 deletions

View File

@@ -14,6 +14,7 @@
use App\Http\Responses\Api\Player\InitOrGetGroupsResponse;
use App\Http\Responses\Api\Player\UpdateMetadataResponse;
use App\Models\Game\PickedChallenge;
use App\Models\User\User;
use Illuminate\Support\Facades\Auth;
use Ramsey\Uuid\Type\Hexadecimal;
use Ramsey\Uuid\Uuid;
@@ -23,7 +24,15 @@ class MetadataController extends Controller
public function initOrGetGroups(InitOrGetGroupsRequest $request)
{
$response = new InitOrGetGroupsResponse();
$user = Auth::user();
// If the request has set a player Id, use it.
// if not use the current authenticated user from this session.
// This is important because the hosts requests the progression and metadata groups for the other players
// for tracking challenges and so on.
if($request->playerId !== null)
$user = User::find($request->playerId);
else
$user = Auth::user();
foreach (ItemGroupType::cases() as $group) {
if ($group == ItemGroupType::None)