-
友達を選択してください
+
);
}
}
+
export default ChatTalk;
diff --git a/routes/api/v2/client/friends/list.ts b/routes/api/v2/client/friends/list.ts
index 7afc8342..cd8bb2f0 100644
--- a/routes/api/v2/client/friends/list.ts
+++ b/routes/api/v2/client/friends/list.ts
@@ -12,7 +12,7 @@ const env = await load();
export const handler = {
async GET(req: any, ctx: any) {
if (!ctx.state.data.loggedIn) {
- return ctx.json({ status: false, message: "You are not logged in" });
+ return new Response(JSON.stringify({ status: false, message: "Not Logged In" }));
}
const userid = ctx.state.data.userid;
const roomsData = await rooms.find({ "users.userid": userid });
diff --git a/routes/api/v2/client/friends/request/list.ts b/routes/api/v2/client/friends/request/list.ts
index d1379c2c..6280641b 100644
--- a/routes/api/v2/client/friends/request/list.ts
+++ b/routes/api/v2/client/friends/request/list.ts
@@ -2,7 +2,7 @@ import requestAddFriend from "../../../../../../models/reqestAddFriend.ts";
export const handler = {
async GET(req: Request, ctx: any) {
if (!ctx.state.data.loggedIn) {
- return ctx.json({ status: false, message: "You are not logged in" });
+ return new Response(JSON.stringify({ status: false, message: "Not Logged In" }));
}
const sessionid = ctx.state.data.sessionid;
const userid = ctx.state.data.userid;
diff --git a/routes/api/v2/client/settings/privacy.ts b/routes/api/v2/client/settings/privacy.ts
index be7d651a..63dd837c 100644
--- a/routes/api/v2/client/settings/privacy.ts
+++ b/routes/api/v2/client/settings/privacy.ts
@@ -7,13 +7,19 @@ import userConfig from "../../../../../models/userConfig.ts";
export const handler = {
async POST(req: Request, ctx: any) {
if (!ctx.state.data.loggedIn) {
- return ctx.json({ status: false, message: "You are not logged in" });
+ return new Response(JSON.stringify({ status: false, message: "Not Logged In" }), {
+ headers: { "Content-Type": "application/json" },
+ status: 400,
+ });
}
let body;
try {
body = await req.json();
} catch (e) {
- return ctx.json({ status: false, message: "Invalid JSON" });
+ return new Response(JSON.stringify({ status: false, message: "Invalid Body" }), {
+ headers: { "Content-Type": "application/json" },
+ status: 400,
+ });
}
const userid = ctx.state.data.userid;
const setting = body.setting;
diff --git a/routes/api/v2/client/talks/friend/data.ts b/routes/api/v2/client/talks/friend/data.ts
index 997a8c85..31457ede 100644
--- a/routes/api/v2/client/talks/friend/data.ts
+++ b/routes/api/v2/client/talks/friend/data.ts
@@ -108,7 +108,7 @@ export const handler = {
if (message.messageType === "text") {
return {
messageid: message.messageid,
- userName: CacheUser.userName,
+ userName: CacheUser.userName + "@" + takos.splitUserName(message.userid).domain,
nickName: CacheUser.nickName,
message: message.message,
timestamp: message.timestamp,
@@ -142,7 +142,7 @@ export const handler = {
if (message.messageType === "text") {
return {
messageid: message.messageid,
- userName: userInfo?.userName,
+ userName: userInfo?.userName + "@" + takos.splitUserName(message.userid).domain,
nickName: userInfo?.nickName,
message: message.message,
timestamp: message.timestamp,
diff --git a/routes/api/v2/client/talks/friend/text.ts b/routes/api/v2/client/talks/friend/text.ts
index 39bf153c..e7c3ace6 100644
--- a/routes/api/v2/client/talks/friend/text.ts
+++ b/routes/api/v2/client/talks/friend/text.ts
@@ -17,7 +17,10 @@ export const handler = {
try {
body = await req.json();
} catch (e) {
- return ctx.json({ status: false, message: "Invalid JSON" });
+ return new Response(JSON.stringify({ status: false, message: "Invalid Body" }), {
+ headers: { "Content-Type": "application/json" },
+ status: 400,
+ });
}
const message = body.text;
const sessionid = body.sessionid;
diff --git a/routes/api/v2/client/users/friendkey.ts b/routes/api/v2/client/users/friendkey.ts
index d95bbaf3..2e51f4f3 100644
--- a/routes/api/v2/client/users/friendkey.ts
+++ b/routes/api/v2/client/users/friendkey.ts
@@ -4,7 +4,10 @@ import { getCookies } from "$std/http/cookie.ts";
export const handler = {
async GET(req: Request, ctx: any) {
if (!ctx.state.data.loggedIn) {
- return ctx.json({ status: false, message: "You are not logged in" });
+ return new Response(JSON.stringify({ status: false, message: "Not Logged In" }), {
+ headers: { "Content-Type": "application/json" },
+ status: 400,
+ });
}
const userid = ctx.state.data.userid;
const url = new URL(req.url);
diff --git a/routes/api/v2/client/users/icon.ts b/routes/api/v2/client/users/icon.ts
index 3dfe13bc..322f9076 100644
--- a/routes/api/v2/client/users/icon.ts
+++ b/routes/api/v2/client/users/icon.ts
@@ -5,7 +5,7 @@ import takos from "../../../../../util/takos.ts";
export const handler = {
async GET(req: Request, ctx: any) {
if (!ctx.state.data.loggedIn) {
- return ctx.json({ status: false, message: "You are not logged in" });
+ return new Response("Not Logged In", { status: 401 });
}
const userid = ctx.state.data.userid;
try {
diff --git a/routes/api/v2/client/users/settings.ts b/routes/api/v2/client/users/settings.ts
index 6df69df1..d52df396 100644
--- a/routes/api/v2/client/users/settings.ts
+++ b/routes/api/v2/client/users/settings.ts
@@ -6,7 +6,10 @@ import userConfig from "../../../../../models/userConfig.ts";
export const handler = {
async GET(req: Request, ctx: any) {
if (!ctx.state.data.loggedIn) {
- return ctx.json({ status: false, message: "You are not logged in" });
+ return new Response(JSON.stringify({ status: false, message: "Not Logged In" }), {
+ headers: { "Content-Type": "application/json" },
+ status: 400,
+ });
}
const userid = ctx.state.data.userid;
const config = await userConfig.findOne({ userid: userid });
diff --git a/routes/api/v2/server/information/users/changes.ts b/routes/api/v2/server/information/users/changes.ts
index 3f48d71a..cc580168 100644
--- a/routes/api/v2/server/information/users/changes.ts
+++ b/routes/api/v2/server/information/users/changes.ts
@@ -12,7 +12,10 @@ export const handler = {
const publickey = await fetch(`https://${host}/api/v2/server/pubkey`).then((res) => res.json()).then((data) => data.publickey);
const verify = await takos.verifySignature(publickey, body.signature, body.body);
if (!verify) {
- return ctx.json({ status: false });
+ return new Response(JSON.stringify({
+ status: false,
+ message: "Invalid Signature",
+ }));
}
const data = JSON.parse(body.body);
// 配列の中身が何個あるかを取得
diff --git a/routes/api/v2/server/information/users/profile.ts b/routes/api/v2/server/information/users/profile.ts
index 72872e5a..f0160318 100644
--- a/routes/api/v2/server/information/users/profile.ts
+++ b/routes/api/v2/server/information/users/profile.ts
@@ -14,20 +14,32 @@ export const handler = {
const publickey = await fetch(`https://${host}/api/v2/server/pubkey`).then((res) => res.json()).then((data) => data.publickey);
const verify = await takos.verifySignature(publickey, body.signature, body.body);
if (!verify) {
- return ctx.json({ status: false });
+ return new Response(JSON.stringify({
+ status: false,
+ message: "Invalid Signature",
+ }));
}
const data = JSON.parse(body.body);
const friend = await users.findOne({ uuid: data.friendid });
if (friend === null) {
- return ctx.json({ status: false });
+ return new Response(JSON.stringify({
+ status: false,
+ message: "Invalid Signature",
+ }));
}
const FriendFriendData = await friends.findOne({ user: data.friendid });
if (FriendFriendData === null) {
- return ctx.json({ status: false });
+ return new Response(JSON.stringify({
+ status: false,
+ message: "Invalid Signature",
+ }));
}
const isFriend = FriendFriendData.friends.find((friend: any) => friend.userid === data.userid);
if (isFriend === undefined) {
- return ctx.json({ status: false });
+ return new Response(JSON.stringify({
+ status: false,
+ message: "Invalid Signature",
+ }));
}
return new Response(JSON.stringify({
status: true,
diff --git a/static/logo.png b/static/logo.png
new file mode 100644
index 00000000..463cab2b
Binary files /dev/null and b/static/logo.png differ
diff --git a/util/takosClient.ts b/util/takosClient.ts
index 8702bc0b..9df1aac7 100644
--- a/util/takosClient.ts
+++ b/util/takosClient.ts
@@ -27,3 +27,10 @@ export function checkEmail(email: string) {
const emailPattern = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
return emailPattern.test(email);
}
+export function splitUserName(userName: string) {
+ const split = userName.split("@");
+ return {
+ userName: split[0],
+ domain: split[1],
+ };
+}