Skip to content

Commit

Permalink
Refactor code to fix default value typo in userConfig model
Browse files Browse the repository at this point in the history
  • Loading branch information
tako0614 committed Jul 18, 2024
1 parent 201ee77 commit 6e94384
Show file tree
Hide file tree
Showing 10 changed files with 101 additions and 44 deletions.
52 changes: 26 additions & 26 deletions components/welcome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,38 +145,38 @@ function welcome() {
<div class="mt-4">
<div class="bg-white text-black rounded-lg shadow-[0_12px_32px_#00000040] p-6 max-w-[472px] lg:ml-[100px] lg:mt-[20px] mx-auto">
<div class="text-center">
<p class="text-sm text-gray-700">© 2024 Tomiyama Shota.</p>
<p class="text-sm text-gray-700">© 2024 Tomiyama Shota.</p>
<p class="text-base text-gray-600">
Operat By takoserver
Operat By takoserver
</p>

<p class="text-sm text-gray-700">
This site is protected by reCAPTCHA and the Google
<a href="https://policies.google.com/privacy">Privacy Policy</a> and
<a href="https://policies.google.com/terms">Terms of Service</a> apply.
This site is protected by reCAPTCHA and the Google
<a href="https://policies.google.com/privacy">Privacy Policy</a> and
<a href="https://policies.google.com/terms">Terms of Service</a> apply.
</p>
<div class="flex justify-between w-5/6 mx-auto">
<p>
<a href="https://www.takos.jp/privacypolicy">
プライバシーポリシー
</a>
</p>
<p class="ml-4">
<a href="https://www.takos.jp/terms">
利用規約
</a>
</p>
<p class="ml-4">
<a href="https://x.com/takoserver_com">
SNS
</a>
</p>
<p class="ml-4">
<a href="https://line.me/ti/g2/Q0c8YJlkh5f_hkDuODxp39XF9A7BOCFqezaAHA?utm_source=invitation&utm_medium=link_copy&utm_campaign=default">
コミュニティー
</a>
</p>
</div>
<p>
<a href="https://www.takos.jp/privacypolicy">
プライバシーポリシー
</a>
</p>
<p class="ml-4">
<a href="https://www.takos.jp/terms">
利用規約
</a>
</p>
<p class="ml-4">
<a href="https://x.com/takoserver_com">
SNS
</a>
</p>
<p class="ml-4">
<a href="https://line.me/ti/g2/Q0c8YJlkh5f_hkDuODxp39XF9A7BOCFqezaAHA?utm_source=invitation&utm_medium=link_copy&utm_campaign=default">
コミュニティー
</a>
</p>
</div>
</div>
</div>
</div>
Expand Down
2 changes: 2 additions & 0 deletions fresh.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import * as $api_v2_client_friends_info_ID_profile_friend from "./routes/api/v2/
import * as $api_v2_client_friends_info_ID_profile_friendcode from "./routes/api/v2/client/friends/info/[ID]/profile/friendcode.ts";
import * as $api_v2_client_friends_info_ID_profile_group from "./routes/api/v2/client/friends/info/[ID]/profile/group.ts";
import * as $api_v2_client_friends_list from "./routes/api/v2/client/friends/list.ts";
import * as $api_v2_client_friends_request_friend from "./routes/api/v2/client/friends/request/friend.ts";
import * as $api_v2_client_friends_request_list from "./routes/api/v2/client/friends/request/list.ts";
import * as $api_v2_client_main from "./routes/api/v2/client/main.ts";
import * as $api_v2_client_sessions_login from "./routes/api/v2/client/sessions/login.ts";
Expand Down Expand Up @@ -133,6 +134,7 @@ const manifest = {
"./routes/api/v2/client/friends/info/[ID]/profile/friendcode.ts": $api_v2_client_friends_info_ID_profile_friendcode,
"./routes/api/v2/client/friends/info/[ID]/profile/group.ts": $api_v2_client_friends_info_ID_profile_group,
"./routes/api/v2/client/friends/list.ts": $api_v2_client_friends_list,
"./routes/api/v2/client/friends/request/friend.ts": $api_v2_client_friends_request_friend,
"./routes/api/v2/client/friends/request/list.ts": $api_v2_client_friends_request_list,
"./routes/api/v2/client/main.ts": $api_v2_client_main,
"./routes/api/v2/client/sessions/login.ts": $api_v2_client_sessions_login,
Expand Down
2 changes: 1 addition & 1 deletion islands/Register.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ function SendEmailRegisterRequest({ state, sitekeyv2, sitekeyv3 }: { state: any;
alert("reCAPTCHAが無効です");
break;
default:
alert("エラーが発生しました: "+ data.message);
alert("エラーが発生しました: " + data.message);
break;
}
}
Expand Down
15 changes: 9 additions & 6 deletions routes/api/v2/client/csrftoken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export const handler = {
const cookies = getCookies(req.headers);
const sessionid = cookies.sessionid;
const userid = ctx.state.data.userid;
const origin = req.headers.get('origin')
const origins = env["serverOrigin"].split(",")
const origin = req.headers.get("origin");
const origins = env["serverOrigin"].split(",");
//localhostだとoriginがnullになるので
/*
if(origin === null){
Expand All @@ -50,10 +50,13 @@ export const handler = {
status: true,
csrftoken: csrftoken,
}),
{ status: 200, headers: { "Content-Type": "application/json",
//cors
"Access-Control-Allow-Origin": origin,
} },
{
status: 200,
headers: {
"Content-Type": "application/json", //cors
//"Access-Control-Allow-Origin": origin,
},
},
);
},
};
54 changes: 54 additions & 0 deletions routes/api/v2/client/friends/request/friend.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import takos from "../../../../../../util/takos.ts";
import userConfig from "../../../../../../models/userConfig.ts";
import requestAddFriend from "../../../../../../models/reqestAddFriend.ts";
import { load } from "$std/dotenv/mod.ts";
const env = await load();
export const handler = {
async GET(req: Request, ctx: any) {
if (!ctx.state.data.loggedIn) {
return new Response(JSON.stringify({ status: false, message: "Not Logged In" }));
}
const userid = ctx.state.data.userid;
let body;
try {
body = await req.json();
} catch (e) {
return new Response(JSON.stringify({ status: false, message: "Invalid request" }), {
headers: { "Content-Type": "application/json" },
status: 400,
});
}
const { userName, csrftoken } = body;
if (typeof userName !== "string") {
return new Response(JSON.stringify({ status: false, message: "Invalid userName" }), {
headers: { "Content-Type": "application/json" },
status: 400,
});
}
if (typeof csrftoken !== "string") {
return new Response(JSON.stringify({ status: false, message: "Invalid csrftoken" }), {
headers: { "Content-Type": "application/json" },
status: 400,
});
}
if (takos.checkUserName(userName) === false) {
return new Response(JSON.stringify({ status: false, message: "Invalid" }), {
headers: { "Content-Type": "application/json" },
status: 400,
});
}
if (await takos.checkCsrfToken(csrftoken, userid) === false) {
return new Response(JSON.stringify({ status: false, message: "Invalid CSRF token" }), {
headers: { "Content-Type": "application/json" },
status: 400,
});
}
const userDomain = takos.splitUserName(userName).domain;
if (userDomain !== env["DOMAIN"]) {
//他のドメインのユーザーにリクエストを送る場合
return;
} else {
//自分のドメインのユーザーにリクエストを送る場合
}
},
};
4 changes: 2 additions & 2 deletions routes/api/v2/client/sessions/registers/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const handler = {
});
}
if (recaptchakind === "v3") {
const RECAPTCHA_SECRET_KEY = env["rechapcha_seecret_key_v3"]
const RECAPTCHA_SECRET_KEY = env["rechapcha_seecret_key_v3"];
const isSecsusRechapcha = await fetch(
`https://www.google.com/recaptcha/api/siteverify?secret=${RECAPTCHA_SECRET_KEY}&response=${recaptcha}`,
);
Expand All @@ -58,7 +58,7 @@ export const handler = {
);
}
} else if (recaptchakind === "v2") {
const RECAPTCHA_SECRET_KEY = env["rechapcha_seecret_key_v2"]
const RECAPTCHA_SECRET_KEY = env["rechapcha_seecret_key_v2"];
const response = await fetch(`https://www.google.com/recaptcha/api/siteverify`, {
method: "POST",
headers: {
Expand Down
4 changes: 2 additions & 2 deletions routes/api/v2/client/sessions/registers/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const handler = {
});
}
if (recaptchakind === "v3") {
const RECAPTCHA_SECRET_KEY = env["rechapcha_seecret_key_v3"]
const RECAPTCHA_SECRET_KEY = env["rechapcha_seecret_key_v3"];
const isSecsusRechapcha = await fetch(
`https://www.google.com/recaptcha/api/siteverify?secret=${RECAPTCHA_SECRET_KEY}&response=${recaptcha}`,
);
Expand All @@ -61,7 +61,7 @@ export const handler = {
);
}
} else if (recaptchakind === "v2") {
const RECAPTCHA_SECRET_KEY = env["rechapcha_seecret_key_v2"]
const RECAPTCHA_SECRET_KEY = env["rechapcha_seecret_key_v2"];
const response = await fetch(`https://www.google.com/recaptcha/api/siteverify`, {
method: "POST",
headers: {
Expand Down
4 changes: 2 additions & 2 deletions routes/api/v2/client/sessions/registers/temp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const handler = {
});
}
if (recaptchakind === "v3") {
const RECAPTCHA_SECRET_KEY = env["rechapcha_seecret_key_v3"]
const RECAPTCHA_SECRET_KEY = env["rechapcha_seecret_key_v3"];
const isSecsusRechapcha = await fetch(
`https://www.google.com/recaptcha/api/siteverify?secret=${RECAPTCHA_SECRET_KEY}&response=${recaptcha}`,
);
Expand All @@ -56,7 +56,7 @@ export const handler = {
);
}
} else if (recaptchakind === "v2") {
const RECAPTCHA_SECRET_KEY = env["rechapcha_seecret_key_v2"]
const RECAPTCHA_SECRET_KEY = env["rechapcha_seecret_key_v2"];
const response = await fetch(`https://www.google.com/recaptcha/api/siteverify`, {
method: "POST",
headers: {
Expand Down
4 changes: 2 additions & 2 deletions routes/api/v2/client/talks/friend/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export const handler = {
const result = await Promise.all(messagesData.map(async (message) => {
const CacheUser = usersCache.get(message.userid);
if (CacheUser) {
if(lastMessageTimestamp === undefined || new Date(lastMessageTimestamp) < new Date(message.timestamp)){
if (lastMessageTimestamp === undefined || new Date(lastMessageTimestamp) < new Date(message.timestamp)) {
lastMessageTimestamp = message.timestamp;
lastMessageId = message.messageid;
}
Expand Down Expand Up @@ -132,7 +132,7 @@ export const handler = {
};
}
}));
await rooms.updateOne({ uuid: roomid }, { $set: { "readInfo.latestMessageId": lastMessageId} })
await rooms.updateOne({ uuid: roomid }, { $set: { "readInfo.latestMessageId": lastMessageId } });
return new Response(JSON.stringify({ status: true, message: "Success", data: result }), { status: 200, headers: { "Content-Type": "application/json" } });
},
};
4 changes: 1 addition & 3 deletions routes/api/v2/client/talks/roomsInfo.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
export const handler = {

}
export const handler = {};

0 comments on commit 6e94384

Please sign in to comment.