Skip to content

Commit

Permalink
recaptureやめる
Browse files Browse the repository at this point in the history
  • Loading branch information
eatski committed Aug 13, 2024
1 parent 15bd33a commit eb3b431
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 69 deletions.
7 changes: 0 additions & 7 deletions __test__/story.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { test, expect } from '@playwright/test';
import { PrismaClient } from '@prisma/client';
import { resolveFixturePath } from '../fixtures';
import { generateId } from '@/common/util/id';
import { RECAPTCHA_COOKIE_KEY } from '@/common/util/grecaptcha';

const BASE_URL = 'http://localhost:3000';

Expand Down Expand Up @@ -58,12 +57,6 @@ test('質問の送信', async ({ page }) => {
})

await page.goto(BASE_URL + "/stories/" + storyId);
process.env.MACHINE_TOKEN && await page.context().addCookies([{
name: RECAPTCHA_COOKIE_KEY,
value: process.env.MACHINE_TOKEN,
url: BASE_URL,
httpOnly: true
}]);
await page.waitForLoadState("networkidle")
const input = await page.getByRole('textbox', { name: "AIへの質問" });
await input.fill("あなたはAIですか?");
Expand Down
3 changes: 0 additions & 3 deletions src/app/stories/[storyId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { getUserSession } from "@/server/serverComponent/getUserSession";
import { setupABTestValue } from "@/server/serverComponent/setupABTestingVariant";
import { checkAnswer } from "@/server/services/answer";
import { askQuestion } from "@/server/services/question";
import { verifyRecaptcha } from "@/server/services/recaptcha";
import { getStories, getStory } from "@/server/services/story";
import { deleteStory } from "@/server/services/story/deleteStory";
import {
Expand Down Expand Up @@ -187,12 +186,10 @@ export default async function StoryPage({ params: { storyId } }: StoryProps) {
}}
sendQuestion={async (input) => {
"use server";
await verifyRecaptcha(input.recaptchaToken);
return askQuestion(input.text, story, setupABTestValue());
}}
checkAnswer={async (input) => {
"use server";
await verifyRecaptcha(input.recaptchaToken);
return checkAnswer(input.text, story);
}}
postStoryEvalution={async () => {
Expand Down
21 changes: 0 additions & 21 deletions src/common/util/grecaptcha.ts

This file was deleted.

10 changes: 0 additions & 10 deletions src/components/play/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"use client";
import { CLIENT_KEY, getRecaptchaToken } from "@/common/util/grecaptcha";
import { gtagEvent } from "@/common/util/gtag";
import { Button } from "@/designSystem/components/button";
import type {
Expand All @@ -8,7 +7,6 @@ import type {
answer as answerSchema,
} from "@/server/model/story";
import { useMutation, useQuery } from "@tanstack/react-query";
import Script from "next/script";
import { useCallback, useState } from "react";
import { z } from "zod";
import { useConfirmModal } from "../confirmModal";
Expand All @@ -35,14 +33,12 @@ type Props = {
>;
sendQuestion: (args: {
text: string;
recaptchaToken: string;
}) => Promise<{
answer: z.infer<typeof answerSchema>;
hitQuestionExample: QuestionExampleWithCustomMessage | null;
}>;
checkAnswer: (args: {
text: string;
recaptchaToken: string;
}) => Promise<{
isCorrect: boolean;
distance: number;
Expand All @@ -55,7 +51,6 @@ const AnswerFormContainer: React.FC<{
changeMode: (mode: Mode) => void;
checkAnswer: (args: {
text: string;
recaptchaToken: string;
}) => Promise<{
isCorrect: boolean;
distance: number;
Expand All @@ -66,7 +61,6 @@ const AnswerFormContainer: React.FC<{
async (text: string) => {
const response = await checkAnswer({
text: text,
recaptchaToken: await getRecaptchaToken(),
});
return {
...response,
Expand Down Expand Up @@ -162,10 +156,6 @@ export function Play({

return (
<>
<Script
strategy="lazyOnload"
src={`https://www.google.com/recaptcha/api.js?render=${CLIENT_KEY}`}
/>
{mode === "question" && (
<div className={styles.sectionWrapper}>
<QuestionForm
Expand Down
7 changes: 0 additions & 7 deletions src/components/play/useQuestion.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import {
vitest,
} from "vitest";

import * as recapcha from "../../common/util/grecaptcha";

const Provider: React.FC<PropsWithChildren> = ({ children }) => {
const queryClient = useMemo(() => new QueryClient(), []);
return (
Expand All @@ -30,9 +28,6 @@ describe("useQuestion", () => {

beforeEach(() => {
server.listen();
vi.spyOn(recapcha, "getRecaptchaToken").mockReturnValue(
Promise.resolve("test"),
);
});

afterEach(() => {
Expand Down Expand Up @@ -115,13 +110,11 @@ describe("useQuestion", () => {
[
[
{
"recaptchaToken": "test",
"text": "太郎は犬ですか?",
},
],
[
{
"recaptchaToken": "test",
"text": "太郎は猫ですか?",
},
],
Expand Down
3 changes: 0 additions & 3 deletions src/components/play/useQuestion.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useMutation } from "@tanstack/react-query";
import { useRef, useState } from "react";
import { z } from "zod";
import { getRecaptchaToken } from "../../common/util/grecaptcha";
import type {
Answer,
QuestionExampleWithCustomMessage,
Expand Down Expand Up @@ -48,7 +47,6 @@ const useMutableHistory = () => {
export const useQuestion = (
sendQuestion: (args: {
text: string;
recaptchaToken: string;
}) => Promise<{
answer: z.infer<typeof answer>;
hitQuestionExample: QuestionExampleWithCustomMessage | null;
Expand All @@ -69,7 +67,6 @@ export const useQuestion = (
const id = pushHistory({ input: text, result: null });
const result = await mutateAsync({
text,
recaptchaToken: await getRecaptchaToken(),
});
const simpleMessage = (
{
Expand Down
18 changes: 0 additions & 18 deletions src/server/services/recaptcha/index.ts

This file was deleted.

0 comments on commit eb3b431

Please sign in to comment.