Skip to content

Commit

Permalink
Refactor Chat.tsx to initialize addFriendInfo with empty data and icon
Browse files Browse the repository at this point in the history
  • Loading branch information
tako0614 committed Jun 22, 2024
1 parent 8f27cd5 commit ddd5346
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 151 deletions.
142 changes: 0 additions & 142 deletions routes/about.tsx

This file was deleted.

18 changes: 15 additions & 3 deletions routes/api/v1/csrftoken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,31 @@ export const handler = {
const cookies = getCookies(req.headers)
if (cookies.sessionid === undefined) {
return new Response(
JSON.stringify({ "csrftoken": "No sessionid" }),
JSON.stringify({
status : false,
message : "No sessionid",
"csrftoken": "" }),
{
headers: {
"Content-Type": "application/json",
},
status: 403,
},
)
}
const sessionid = cookies.sessionid
const result = await sessionID.findOne({ sessionID: sessionid })
if (result === null || result === undefined) {
return new Response(
JSON.stringify({ "csrftoken": "Invalid sessionid" }),
JSON.stringify({ "csrftoken": ""
,tatus : false,
message : "No sessionid"
}),
{
headers: {
"Content-Type": "application/json",
},
status: 403,
},
)
}
Expand All @@ -40,7 +48,10 @@ export const handler = {
(byte) => byte.toString(16).padStart(2, "0"),
).join("")
await csrfToken.create({ token: csrftoken, sessionID: sessionid })
return new Response(JSON.stringify({ "csrftoken": csrftoken }), {
return new Response(JSON.stringify({ "csrftoken": csrftoken,
status : true,
message : "Success"
}), {
headers: {
"Content-Type": "application/json",
"Access-Control-Allow-Origin": origin,
Expand All @@ -54,6 +65,7 @@ export const handler = {
"Content-Type": "application/json",
"Access-Control-Allow-Origin": origin,
},
status: 200,
},
)
}
Expand Down
4 changes: 3 additions & 1 deletion routes/api/v1/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ setInterval(invalidateOldSessions, 5 * 60 * 1000)
export const handler = {
GET(req: Request, ctx: any) {
if (!ctx.state.data.loggedIn) {
return new Response(JSON.stringify({ "status": "Please Login" }), {
return new Response(JSON.stringify({ "status": false,
"message": "No sessionid",
}), {
headers: { "Content-Type": "application/json" },
status: 401,
})
Expand Down
Empty file removed routes/api/v1/setting/icon.ts
Empty file.
2 changes: 1 addition & 1 deletion routes/api/v1/setting/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const handler = {
nickName: null,
icon: null,
}
if (!requirementjson || !requirementjson.icon) {
if (!requirementjson && !requirementjson.icon) {
return result
}
if (requirementjson.nickName) {
Expand Down
4 changes: 0 additions & 4 deletions routes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@ import Welcom from "../islands/Welcome.tsx"
import users from "../models/users.ts"
import { load } from "$std/dotenv/mod.ts"
import Chat from "../islands/Chats/Chat.tsx"
import { useSignal } from "@preact/signals"
import User from "../components/Chats/ChatUserList.jsx"
const env = await load()
const sitekey = env["recaptcha_site_key"]
const wsSSL = env["wsSSL"]
const url = `https://www.google.com/recaptcha/api.js?render=${sitekey}`
export const handler = {
async GET(req: any, ctx: any) {
if (!ctx.state.data.loggedIn) {
Expand Down Expand Up @@ -53,7 +50,6 @@ export const handler = {
},
}
export default function Home({ data }: { data: any }) {
const page = useSignal("index")
if (!data.loggedIn) {
return (
<>
Expand Down

0 comments on commit ddd5346

Please sign in to comment.