From 478620dbf82417c62fb9567f788a3048be570dfe Mon Sep 17 00:00:00 2001 From: Michael Jolley Date: Sun, 1 Dec 2024 15:45:07 -0600 Subject: [PATCH] Removing sub check --- src/components/giving/Giving.astro | 9 +--- src/components/giving/GivingForm.astro | 5 +- src/components/giving/NotSubbed.astro | 74 -------------------------- src/pages/api/auth/signin.ts | 2 +- src/scripts/twitch.ts | 34 ------------ 5 files changed, 5 insertions(+), 119 deletions(-) delete mode 100644 src/components/giving/NotSubbed.astro diff --git a/src/components/giving/Giving.astro b/src/components/giving/Giving.astro index ae5c4de..8af8ad4 100644 --- a/src/components/giving/Giving.astro +++ b/src/components/giving/Giving.astro @@ -1,11 +1,9 @@ --- export const prerender = false; import GivingForm from './GivingForm.astro'; -import NotSubbed from './NotSubbed.astro'; import Registered from './Registered.astro'; import SignIn from './SignIn.astro'; import { getSub } from '@lib/supabase'; -import { subCheck } from '@scripts/twitch'; export interface Props { user: { @@ -16,7 +14,6 @@ export interface Props { }; } const { user } = Astro.props; -const check = user ? await subCheck(user.user_id) : null; const registered = user ? await getSub(user.id) : null; --- @@ -27,11 +24,7 @@ const registered = user ? await getSub(user.id) : null; {!user && } - {user && !check?.isSub && - - - } - {user && check?.isSub && !registered && + {user && !registered && } {user && registered && diff --git a/src/components/giving/GivingForm.astro b/src/components/giving/GivingForm.astro index 12f82c3..caf3371 100644 --- a/src/components/giving/GivingForm.astro +++ b/src/components/giving/GivingForm.astro @@ -16,8 +16,9 @@ const { user } = Astro.props; {user.nickname}!

- We made a subscriber list, checked it twice, and you're on it! Register - below to receive your Season of Gifting gifts. 🎁 + We're making a subscriber list and checking it twice, so make sure you're on + it by December 19th, 2024! And be sure to register below to receive your + Season of Gifting gifts. 🎁

- Heyo - {`${user.nickname}'s - {user.nickname}! - -

- We looked at the current subscriber list and couldn't find your name. -

-

- Don't worry, you have until December 19th, 2024 to subscribe or - possibly receive a gifted sub. Once you have a subscription, be sure - to come back and register to receive your Season of Gifting gifts. 🎁 -

-

- Heck, we may even be online now. Check below - to join in! -

- - diff --git a/src/pages/api/auth/signin.ts b/src/pages/api/auth/signin.ts index 5674a7a..21086a3 100644 --- a/src/pages/api/auth/signin.ts +++ b/src/pages/api/auth/signin.ts @@ -10,7 +10,7 @@ export const GET: APIRoute = async ({ request, cookies, redirect }) => { const { data, error } = await supabase.auth.signInWithOAuth({ provider: 'twitch', options: { - redirectTo: `https://baldbeardedbuilder.com/api/auth/callback/` + redirectTo: `https://baldbeardedbuilder.com/api/auth/callback/`, }, }); diff --git a/src/scripts/twitch.ts b/src/scripts/twitch.ts index e2fd588..04f5697 100644 --- a/src/scripts/twitch.ts +++ b/src/scripts/twitch.ts @@ -29,15 +29,6 @@ const getHeaders = async (): Promise => { }; }; -const getATHeaders = async (): Promise => { - const accessToken = await getAccessToken(); - - return { - "Client-ID": import.meta.env.TWITCH_CLIENT_ID, - Authorization: `Bearer ${import.meta.env.TWITCH_ACCESS_TOKEN}`, - }; -}; - export async function getLastStream(): Promise<{ lastStreamUrl: string; lastThumbnail: string; @@ -86,28 +77,3 @@ export async function isOnline(): Promise { return thumbnail; } -export async function subCheck(userId: string): Promise<{isSub: boolean, err: any}> { - const headers = await getATHeaders(); - const response = await fetch( - `https://api.twitch.tv/helix/subscriptions?broadcaster_id=${import.meta.env.TWITCH_CHANNEL_ID}&user_id=${userId}`, - { - headers, - }, - ); - - - const body = await response.text(); - const { data: subscribers } = JSON.parse(body); - - if (subscribers && subscribers.length > 0) { - return { - isSub: true, - err: null - }; - } - - return { - isSub: false, - err: {status: response.status, message: response.statusText} - }; -}