diff --git a/app/Http/Controllers/ParticipantController.php b/app/Http/Controllers/ParticipantController.php index 26850c7..a3d9323 100644 --- a/app/Http/Controllers/ParticipantController.php +++ b/app/Http/Controllers/ParticipantController.php @@ -14,16 +14,16 @@ class ParticipantController extends Controller return response()->json(['message' => 'Unauthorized: Wrong password'], 401); } - if(!Participant::where('id', $id)->exists()) { + if(!Participant::where('user_id', $id)->exists()) { $participant = Participant::create([ 'user_id' => $id, - 'token' => (string) Str::ulid() + 'token' => uniqid() ]); return $participant->token; } else { - $participant = Participant::where('id', $id)->first(); + $participant = Participant::where('user_id', $id)->first(); return $participant->token; } } diff --git a/bot/main.py b/bot/main.py index a61756f..24e185e 100644 --- a/bot/main.py +++ b/bot/main.py @@ -64,17 +64,22 @@ async def make_new_json_request(user_id: int): async with aiohttp.ClientSession() as session: async with session.post(url, json=data, headers=headers) as response: response_text = await response.text() - return response_text + if(len(response_text) < 14): + return response_text + else: + return False async def post_chat_update(session: aiohttp.ClientSession, chat_object: Dict[str, Any], xsrf_token: str): pattern = r'/(\d+)/' match = re.search(pattern, chat_object.get('icon_url')) token = await make_new_json_request(match.group(1)) - form_data = aiohttp.FormData() - form_data.add_field('text', f"""You've signed up for the Secret Sketchers event, your link is http://localhost/profile/{token} - it is private and should only be used by you. - \nDon't want to be in it anymore? Go to http://localhost/withdraw/{token} - note that withdrawing is permanent and you cannot re-enter the event.""") + if(token): + form_data.add_field('text', f"""You've signed up for the Secret Sketchers event, your link is http://localhost/profile/{token} - it is private and should only be used by you. + \nDon't want to be in it anymore? Go to http://localhost/withdraw/{token} - note that withdrawing is permanent and you cannot re-enter the event.""") + else: + form_data.add_field('text', f"""Something went wrong, Sorry I will fix it sooner or later... maybe""") headers = get_post_headers(xsrf_token) diff --git a/database/factories/ParticipantFactory.php b/database/factories/ParticipantFactory.php index cc04f5c..1d1c086 100644 --- a/database/factories/ParticipantFactory.php +++ b/database/factories/ParticipantFactory.php @@ -24,7 +24,7 @@ class ParticipantFactory extends Factory public function definition(): array { return [ - 'token' => (string) Str::ulid(), + 'token' => uniqid(), ]; }