Skip to content

Commit

Permalink
Refactor server domain variable names to use consistent casing
Browse files Browse the repository at this point in the history
  • Loading branch information
tako0614 committed Jun 16, 2024
1 parent 67e9eea commit d11b5c4
Show file tree
Hide file tree
Showing 23 changed files with 49 additions and 49 deletions.
2 changes: 1 addition & 1 deletion routes/addFriend/[roomid].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export default function Home({ data }: { data: any }) {
roomid={data.roomid}
settings={settings}
userNickName={data.nickName}
userName={data.userName + "@" + env["serverDomain"]}
userName={data.userName + "@" + env["SERVER_DOMAIN"]}
>
</Chat>
</>
Expand Down
2 changes: 1 addition & 1 deletion routes/addFriend/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export default function Home({ data }: { data: any }) {
page={2}
isAddFriendForm={false}
userNickName={data.nickName}
userName={data.userName + "@" + env["serverDomain"]}
userName={data.userName + "@" + env["SERVER_DOMAIN"]}
>
</Chat>
</>
Expand Down
6 changes: 3 additions & 3 deletions routes/api/v1/chats/friendList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ export const handler = {
latestMessageTime: latestmessage?.timestamp,
roomIcon: `/api/v1/friends/${
friendName?.userName + "@" +
env["serverDomain"]
env["SERVER_DOMAIN"]
}/icon`,
type: "localfriend",
userName: friendName?.userName + "@" +
env["serverDomain"],
env["SERVER_DOMAIN"],
isNewMessage: isNewMessage === undefined,
}
return friendResult
Expand Down Expand Up @@ -157,7 +157,7 @@ export const handler = {
`${OtherServerUserDomain}/api/v1/server/friends/${
OtherServerUser[0].userid
}/profile?token=${takosToken}&serverDomain=${
env["serverDomain"]
env["SERVER_DOMAIN"]
}&type=id&reqUser=${ctx.state.data.userid}`,
)
console.log(OtherServerUserInfo.url)
Expand Down
6 changes: 3 additions & 3 deletions routes/api/v1/chats/talkdata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export const handler = {
) !== -1
return {
sender: sender.userName + "@" +
env["serverDomain"],
env["SERVER_DOMAIN"],
senderNickName: sender.nickName,
message: message.message,
timestamp: message.timestamp,
Expand Down Expand Up @@ -265,7 +265,7 @@ export const handler = {
`${OtherServerUserDomain}/api/v1/server/friends/${
friendId[0]
}/profile?token=${takosToken}&serverDomain=${
env["serverDomain"]
env["SERVER_DOMAIN"]
}&type=id&reqUser=${ctx.state.data.userid}`,
)
if (!OtherServerUserInfo) {
Expand Down Expand Up @@ -310,7 +310,7 @@ export const handler = {
if (message.userid === ctx.state.data.userid) {
sender = {
userName: userName.userName + "@" +
env["serverDomain"],
env["SERVER_DOMAIN"],
nickName: userName.nickName,
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion routes/api/v1/friends/[ID]/icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export const handler = {
})
}

if (friendDomain === env["serverDomain"]) {
if (friendDomain === env["SERVER_DOMAIN"]) {
const friend: Friend | null = await friends.findOne({
user: ctx.state.data.userid,
})
Expand Down
2 changes: 1 addition & 1 deletion routes/api/v1/friends/reqLists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const handler = {
}
return {
userName: userInfo.userName + "@" +
env["serverDomain"],
env["SERVER_DOMAIN"],
icon:
`/api/v1/friends/${userInfo.userName}/icon?isRequestList=true`,
timestamp: obj.timestamp,
Expand Down
18 changes: 9 additions & 9 deletions routes/api/v1/friends/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const handler = {
const splitFriendName = splitUserName(friendName)
if (
!splitFriendName ||
splitFriendName.domain !== env["serverDomain"]
splitFriendName.domain !== env["SERVER_DOMAIN"]
) {
const ApplientedUserInfo = await requestAddFriend.findOne({
userID: ctx.state.data.userid,
Expand Down Expand Up @@ -129,7 +129,7 @@ export const handler = {
},
body: JSON.stringify({
requesterUserName: ctx.state.data.userName + "@" +
env["serverDomain"],
env["SERVER_DOMAIN"],
requesterUserUUID: ctx.state.data.userid,
requirement: "acceptReqFriend",
recipientUserName: friendName,
Expand Down Expand Up @@ -171,9 +171,9 @@ export const handler = {
{
username: ctx.state.data.userName,
userid: userid,
host: env["serverDomain"],
host: env["SERVER_DOMAIN"],
type: "local",
domain: env["serverDomain"],
domain: env["SERVER_DOMAIN"],
},
{
username: splitFriendName?.name,
Expand Down Expand Up @@ -287,7 +287,7 @@ export const handler = {
userid: userid,
host: "local",
type: "local",
domain: env["serverDomain"],
domain: env["SERVER_DOMAIN"],
},
{
username: friendInfo.userName,
Expand Down Expand Up @@ -353,7 +353,7 @@ export const handler = {
Applicant: [{
userID: userid,
userName: ApplcienterInfo.userName,
host: env["serverDomain"],
host: env["SERVER_DOMAIN"],
type: "local",
}],
})
Expand All @@ -363,7 +363,7 @@ export const handler = {
AppliedUser: [{
userID: addFriendUserInfo.uuid,
userName: addFriendUserInfo.userName,
host: env["serverDomain"],
host: env["SERVER_DOMAIN"],
type: "local",
}],
})
Expand Down Expand Up @@ -408,7 +408,7 @@ export const handler = {
})
}
try {
if (friendDomain == env["serverDomain"]) {
if (friendDomain == env["SERVER_DOMAIN"]) {
const friendInfo = await users.findOne({
userName: splitUserName(friendName)?.name,
})
Expand Down Expand Up @@ -582,7 +582,7 @@ export const handler = {
body: JSON.stringify({
requesterUserName: ctx.state.data.userName +
"@" +
env["serverDomain"],
env["SERVER_DOMAIN"],
requesterUserUUID: ctx.state.data.userid,
requirement: "reqFriend",
recipientUserName: friendName,
Expand Down
2 changes: 1 addition & 1 deletion routes/api/v1/logins/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ export const handler = {
(byte) => byte.toString(16).padStart(2, "0"),
).join("")
//ユーザーを登録
const uuid = crypto.randomUUID() + "@" + env["serverDomain"]
const uuid = crypto.randomUUID() + "@" + env["SERVER_DOMAIN"]
const result = await users.create({
uuid: uuid,
userName,
Expand Down
8 changes: 4 additions & 4 deletions routes/api/v1/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ async function sendConecctingUserMessage(
sessions.forEach(async (session, key) => {
if (session.talkingRoom === roomid) {
isFindUser = true
if (splitUserName(sender).domain !== env["serverDomain"]) {
if (splitUserName(sender).domain !== env["SERVER_DOMAIN"]) {
const takosTokenArray = new Uint8Array(16)
const randomarray = crypto.getRandomValues(takosTokenArray)
const takosToken = Array.from(
Expand All @@ -404,7 +404,7 @@ async function sendConecctingUserMessage(
`${
splitUserName(sender).domain
}/api/v1/server/friends/${sender}/profile?token=${takosToken}&serverDomain=${
env["serverDomain"]
env["SERVER_DOMAIN"]
}&type=id&reqUser=${session.uuid}`,
)
if (!remoteFriendInfo) {
Expand Down Expand Up @@ -473,7 +473,7 @@ async function sendConecctingUserMessage(
JSON.stringify({
type: "message",
message: message,
sender: userInfo?.userName + "@" + env["serverDomain"] ||
sender: userInfo?.userName + "@" + env["SERVER_DOMAIN"] ||
"unknown",
senderNickName: userInfo?.nickName || "unknown",
time: time,
Expand Down Expand Up @@ -562,7 +562,7 @@ async function readMessage(messageids: [string], sender: string) {
}),
)
//送信元サーバーにreadしたことを送信
if (splitUserName(sender).domain !== env["serverDomain"]) {
if (splitUserName(sender).domain !== env["SERVER_DOMAIN"]) {
const takosTokenArray = new Uint8Array(16)
const randomarray = crypto.getRandomValues(takosTokenArray)
const takosToken = Array.from(
Expand Down
4 changes: 2 additions & 2 deletions routes/api/v1/server/friends/[ID]/icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ export const handler = {
status: 400,
})
}
if (userserverDomain == env["serverDomain"]) {
if (userserverDomain == env["SERVER_DOMAIN"]) {
return new Response(JSON.stringify({ "status": false }), {
status: 400,
})
}
const isTrueToken = await takosfetch(
`${userserverDomain}/api/v1/server/token?token=${token}&origin=${
env["serverDomain"]
env["SERVER_DOMAIN"]
}`,
)
//userが存在するか確認
Expand Down
8 changes: 4 additions & 4 deletions routes/api/v1/server/friends/[ID]/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const handler = {
status: 400,
})
}
if (serverDomain == env["serverDomain"]) {
if (serverDomain == env["SERVER_DOMAIN"]) {
return new Response(JSON.stringify({ "status": false }), {
status: 400,
})
Expand All @@ -42,7 +42,7 @@ export const handler = {
}
const isTrueToken = await takosfetch(
`${serverDomain}/api/v1/server/token?token=${token}&origin=${
env["serverDomain"]
env["SERVER_DOMAIN"]
}`,
)
if (!isTrueToken) {
Expand Down Expand Up @@ -83,7 +83,7 @@ export const handler = {
}
const result = {
userName: friendUserInfo.userName + "@" +
env["serverDomain"],
env["SERVER_DOMAIN"],
nickName: friendUserInfo.nickName,
}
return new Response(
Expand All @@ -98,7 +98,7 @@ export const handler = {
})
}
const result = {
userName: userInfo.userName + "@" + env["serverDomain"],
userName: userInfo.userName + "@" + env["SERVER_DOMAIN"],
nickName: userInfo.nickName,
}
return new Response(
Expand Down
12 changes: 6 additions & 6 deletions routes/api/v1/server/friends/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const handler = {
const friendDomain = splitUserName(recipientUserName).domain
const userDomain = splitUserName(requesterUserName).domain
if (
userDomain == env["serverDomain"] || friendDomain == userDomain
userDomain == env["SERVER_DOMAIN"] || friendDomain == userDomain
) {
console.log("userDomain" + userDomain)
return new Response(JSON.stringify({ status: false }), {
Expand All @@ -48,7 +48,7 @@ export const handler = {
}
const isTrueToken = await takosfetch(
`${userDomain}/api/v1/server/token?token=` + token +
"&origin=" + env["serverDomain"],
"&origin=" + env["SERVER_DOMAIN"],
)
if (!isTrueToken) {
console.log("isTrueToken")
Expand Down Expand Up @@ -220,22 +220,22 @@ export const handler = {
const friendDomain = splitUserName(recipientUserName).domain
const userDomain = splitUserName(requesterUserUUID).domain
if (
userDomain == env["serverDomain"] || friendDomain == userDomain
userDomain == env["SERVER_DOMAIN"] || friendDomain == userDomain
) {
console.log(
"reci" + recipientUserName,
"uuid" + requesterUserUUID,
)
console.log(userDomain, env["serverDomain"], friendDomain)
console.log(userDomain, env["SERVER_DOMAIN"], friendDomain)
return new Response(JSON.stringify({ status: false }), {
status: 400,
})
}
console.log(userDomain, env["serverDomain"], friendDomain)
console.log(userDomain, env["SERVER_DOMAIN"], friendDomain)
console.log("3")
const isTrueToken = await takosfetch(
`${userDomain}/api/v1/server/token?token=` + token +
"&origin=" + env["serverDomain"],
"&origin=" + env["SERVER_DOMAIN"],
)
if (!isTrueToken) {
return new Response(JSON.stringify({ status: false }), {
Expand Down
4 changes: 2 additions & 2 deletions routes/api/v1/server/talk/read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ export const handler = {
})
}
const { domain, userName } = splitUserName(reader)
if (domain == env["serverDomain"]) {
if (domain == env["SERVER_DOMAIN"]) {
return new Response(JSON.stringify({ status: false }), {
status: 400,
})
}
const isTrueToken = await takosfetch(
`${domain}/api/v1/server/token?token=` + token + "&origin=" +
env["serverDomain"],
env["SERVER_DOMAIN"],
)
if (isTrueToken === null || isTrueToken === undefined) {
return new Response(JSON.stringify({ status: false }), {
Expand Down
2 changes: 1 addition & 1 deletion routes/api/v1/server/talk/send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const handler = {
const { domain, userName } = splitUserName(sender)
const isTrueToken = await takosfetch(
`${domain}/api/v1/server/token?token=` + token + "&origin=" +
env["serverDomain"],
env["SERVER_DOMAIN"],
)
if (isTrueToken === null || isTrueToken === undefined) {
return new Response(JSON.stringify({ status: false }), {
Expand Down
2 changes: 1 addition & 1 deletion routes/api/v1/server/users/[ID]/name.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const handler = {
return new Response(
JSON.stringify({
"status": true,
"userName": user.userName + "@" + env["serverDomain"],
"userName": user.userName + "@" + env["SERVER_DOMAIN"],
}),
{
status: 200,
Expand Down
2 changes: 1 addition & 1 deletion routes/api/v1/server/users/[ID]/uuid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const handler = {
status: 400,
})
}
if (splitUserName(ID).domain !== env["serverDomain"]) {
if (splitUserName(ID).domain !== env["SERVER_DOMAIN"]) {
return new Response(JSON.stringify({ "status": false }), {
status: 400,
})
Expand Down
2 changes: 1 addition & 1 deletion routes/home/[roomid].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export default function Home({ data }: { data: any }) {
roomid={data.roomid}
settings={settings}
userNickName={data.nickName}
userName={data.userName + "@" + env["serverDomain"]}
userName={data.userName + "@" + env["SERVER_DOMAIN"]}
>
</Chat>
</>
Expand Down
2 changes: 1 addition & 1 deletion routes/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export default function Home({ data }: { data: any }) {
page={0}
isAddFriendForm={false}
userNickName={data.nickName}
userName={data.userName + "@" + env["serverDomain"]}
userName={data.userName + "@" + env["SERVER_DOMAIN"]}
>
</Chat>
</>
Expand Down
4 changes: 2 additions & 2 deletions routes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export default function Home({ data }: { data: any }) {
isAddFriendForm={true}
AddFriendKey={data.key}
userNickName={data.nickName}
userName={data.userName + "@" + env["serverDomain"]}
userName={data.userName + "@" + env["SERVER_DOMAIN"]}
>
</Chat>
)
Expand All @@ -98,7 +98,7 @@ export default function Home({ data }: { data: any }) {
isAddFriendForm={false}
index={true}
userNickName={data.nickName}
userName={data.userName + "@" + env["serverDomain"]}
userName={data.userName + "@" + env["SERVER_DOMAIN"]}
>
</Chat>
)}
Expand Down
2 changes: 1 addition & 1 deletion routes/setting/[roomid].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export default function Home({ data }: { data: any }) {
roomid={data.roomid}
settings={settings}
userNickName={data.nickName}
userName={data.userName + "@" + env["serverDomain"]}
userName={data.userName + "@" + env["SERVER_DOMAIN"]}
>
</Chat>
</>
Expand Down
Loading

0 comments on commit d11b5c4

Please sign in to comment.