diff --git a/fresh.gen.ts b/fresh.gen.ts index df17ba04..1aa1f3f1 100644 --- a/fresh.gen.ts +++ b/fresh.gen.ts @@ -22,6 +22,7 @@ import * as $api_v1_main from "./routes/api/v1/main.ts" import * as $api_v1_server_friends_ID_icon from "./routes/api/v1/server/friends/[ID]/icon.ts" import * as $api_v1_server_friends_ID_profile from "./routes/api/v1/server/friends/[ID]/profile.ts" import * as $api_v1_server_friends_request from "./routes/api/v1/server/friends/request.ts" +import * as $api_v1_server_talk_image from "./routes/api/v1/server/talk/image.ts" import * as $api_v1_server_talk_read from "./routes/api/v1/server/talk/read.ts" import * as $api_v1_server_talk_send from "./routes/api/v1/server/talk/send.ts" import * as $api_v1_server_token from "./routes/api/v1/server/token.ts" @@ -87,6 +88,7 @@ const manifest = { "./routes/api/v1/server/friends/[ID]/icon.ts": $api_v1_server_friends_ID_icon, "./routes/api/v1/server/friends/[ID]/profile.ts": $api_v1_server_friends_ID_profile, "./routes/api/v1/server/friends/request.ts": $api_v1_server_friends_request, + "./routes/api/v1/server/talk/image.ts": $api_v1_server_talk_image, "./routes/api/v1/server/talk/read.ts": $api_v1_server_talk_read, "./routes/api/v1/server/talk/send.ts": $api_v1_server_talk_send, "./routes/api/v1/server/token.ts": $api_v1_server_token, diff --git a/models/images.ts b/models/images.ts new file mode 100644 index 00000000..c3db0461 --- /dev/null +++ b/models/images.ts @@ -0,0 +1,24 @@ +import mongoose from "mongoose" + +export const friendsSchema = new mongoose.Schema({ + imageId: { + type: String, + required: true, + }, + userId: { + type: String, + required: true, + }, + roomids: [String], + size : { + type: Number, + required: true, + }, + time : { + type: Date, + required: true, + default: Date.now + }, +}) +const friends = mongoose.model("images", friendsSchema) +export default friends \ No newline at end of file diff --git a/routes/api/v1/friends/[ID]/icon.ts b/routes/api/v1/friends/[ID]/icon.ts index 864a8c1b..ed75e8ef 100644 --- a/routes/api/v1/friends/[ID]/icon.ts +++ b/routes/api/v1/friends/[ID]/icon.ts @@ -63,7 +63,6 @@ export const handler = { status: 400, }) } - try { const filePath = `./files/userIcons/${mailSpilit(FriendInfo.uuid)}.jpeg` const result = await Deno.readFile(filePath) @@ -79,7 +78,6 @@ export const handler = { }) } } - if (isuseAddFriendKey === "true") { if (!friendName) { return new Response(JSON.stringify({ status: "No userName" }), { @@ -125,7 +123,6 @@ export const handler = { }) } } - if (!friendName) { return new Response(JSON.stringify({ status: "No userName" }), { headers: { "Content-Type": "application/json" }, diff --git a/routes/api/v1/main.ts b/routes/api/v1/main.ts index 85d17863..35912d8c 100644 --- a/routes/api/v1/main.ts +++ b/routes/api/v1/main.ts @@ -98,6 +98,7 @@ export const handler = { data.roomid, socket, data.messageType, + data.image, ) break case "login": @@ -226,6 +227,7 @@ async function sendMessage( roomID: string, ws: WebSocket, MessageType: string, + image?: string, ) { const session = sessions.get(sessionid) if (!session) { @@ -402,7 +404,34 @@ async function sendMessage( } } else if(MessageType == "image") { if(session.roomType === "friend") { - // + if(image === undefined) return + const result = await messages.create({ + userid: session.uuid, + roomid: roomID, + message, + read: [], + messageType: MessageType, + messageid: crypto.randomUUID(), + }) + const time = result.timestamp + pubClient.publish( + redisch, + JSON.stringify({ + roomid: roomID, + message: message, + type: "message", + sender: session.uuid, + time, + messageid: result.messageid, + messageType: MessageType, + }), + ) + updateActivity(sessionid) + ws.send( + JSON.stringify({ + status: true, + }), + ) } } } diff --git a/routes/api/v1/server/talk/image.ts b/routes/api/v1/server/talk/image.ts new file mode 100644 index 00000000..e69de29b diff --git a/static/stylesheet.css b/static/stylesheet.css index ce042360..1ba2a1af 100644 --- a/static/stylesheet.css +++ b/static/stylesheet.css @@ -5,6 +5,7 @@ html,body { position: relative; background-image: url("/main-bg2.png"); background-size: cover; + background-attachment: fixed; } @keyframes marquee { 0% { transform: translateX(100%); }