Spaces:
Build error
Build error
Store IP in messageEvents
Browse files
src/lib/types/MessageEvent.ts
CHANGED
@@ -3,4 +3,5 @@ import type { User } from "./User";
|
|
3 |
|
4 |
export interface MessageEvent extends Pick<Timestamps, "createdAt"> {
|
5 |
userId: User["_id"] | User["sessionId"];
|
|
|
6 |
}
|
|
|
3 |
|
4 |
export interface MessageEvent extends Pick<Timestamps, "createdAt"> {
|
5 |
userId: User["_id"] | User["sessionId"];
|
6 |
+
ip?: string;
|
7 |
}
|
src/routes/conversation/[id]/+server.ts
CHANGED
@@ -18,7 +18,7 @@ import { ObjectId } from "mongodb";
|
|
18 |
import { z } from "zod";
|
19 |
import { AwsClient } from "aws4fetch";
|
20 |
|
21 |
-
export async function POST({ request, fetch, locals, params }) {
|
22 |
const id = z.string().parse(params.id);
|
23 |
const convId = new ObjectId(id);
|
24 |
const date = new Date();
|
@@ -184,6 +184,7 @@ export async function POST({ request, fetch, locals, params }) {
|
|
184 |
await collections.messageEvents.insertOne({
|
185 |
userId: userId,
|
186 |
createdAt: new Date(),
|
|
|
187 |
});
|
188 |
|
189 |
await collections.conversations.updateOne(
|
|
|
18 |
import { z } from "zod";
|
19 |
import { AwsClient } from "aws4fetch";
|
20 |
|
21 |
+
export async function POST({ request, fetch, locals, params, getClientAddress }) {
|
22 |
const id = z.string().parse(params.id);
|
23 |
const convId = new ObjectId(id);
|
24 |
const date = new Date();
|
|
|
184 |
await collections.messageEvents.insertOne({
|
185 |
userId: userId,
|
186 |
createdAt: new Date(),
|
187 |
+
ip: getClientAddress(),
|
188 |
});
|
189 |
|
190 |
await collections.conversations.updateOne(
|