Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve site without api #87

Merged
merged 5 commits into from
Apr 13, 2024
Merged

Conversation

Isti01
Copy link
Contributor

@Isti01 Isti01 commented Apr 13, 2024

No description provided.

@Isti01 Isti01 requested review from Tschonti and berenteb April 13, 2024 10:40
Copy link

vercel bot commented Apr 13, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
konf-web-2024 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 13, 2024 3:48pm

@Isti01 Isti01 changed the title Feature/preserve site without api Preserve site without api Apr 13, 2024
@berenteb berenteb merged commit 129f0b4 into main Apr 13, 2024
4 checks passed
@Isti01 Isti01 deleted the feature/preserve-site-without-api branch April 13, 2024 19:24
Copy link
Member

@Tschonti Tschonti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Comment on lines -38 to -78
export async function sendQuestion({
question,
slug,
recaptchaToken,
userId,
}: {
question: string;
slug: string;
recaptchaToken: string;
userId: string;
}) {
const isRecaptchaValid = await validateRecaptcha(recaptchaToken);
if (!isRecaptchaValid) {
console.error('Recaptcha validation failed');
return 400;
}
if (!question || !slug) {
return 400;
}
const res = await fetch(`https://konf-qna.kir-dev.hu/api/presentation/${slug}/question`, {
method: 'POST',
body: JSON.stringify({ content: question, userId }),
});
if (res.status === 200) {
return 201;
} else if (res.status === 400) {
return 400;
}
return 500;
}

async function validateRecaptcha(token: string) {
const res = await fetch('https://www.google.com/recaptcha/api/siteverify', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: `secret=${process.env.RECAPTCHA_SECRET}&response=${token}`,
});
const data = await res.json();
return data.success;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would've been better if this was left here as a comment, could be a big help next year.
Also at the network functions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants