Skip to content

Commit

Permalink
fx: save real ip to notes table
Browse files Browse the repository at this point in the history
  • Loading branch information
shivanshs9 committed Nov 11, 2024
1 parent 337edc8 commit ec7fa60
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
1 change: 1 addition & 0 deletions backend/src/db/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ export const InitializeDb = () => {
console.log("Successful DB connection.")
}).catch((err) => {
console.error("Error in DB connection: ", err)
process.exit(1)
})
}
7 changes: 2 additions & 5 deletions backend/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@ const NoteService: NoteServiceHandlers = {
) => {
console.log("create a new note...");
const { audio, transcription } = call.request;
console.log(call.getPeer());
console.log(call.metadata.toJSON());

const userIp = call.getPeer().split(":")[0];
const xForwardedFor = call.metadata.get("x-forwarded-for")[0] as string;
const userIp = xForwardedFor ? xForwardedFor.split(",")[0].trim() : call.getPeer().split(":")[0];

if (!transcription) {
callback(null, {
Expand Down Expand Up @@ -77,8 +76,6 @@ const NoteService: NoteServiceHandlers = {
callback: grpc.sendUnaryData<ListNotesResponse>
) => {
console.log("fetching all notes...");
console.log(call.getPeer());
console.log(call.metadata.toJSON());
DB.getRepository(DBNote)
.find()
.then((allNotes) =>
Expand Down

0 comments on commit ec7fa60

Please sign in to comment.