diff --git a/packages/agent/src/index.ts b/packages/agent/src/index.ts index 9cf5cf0..af1b4d2 100644 --- a/packages/agent/src/index.ts +++ b/packages/agent/src/index.ts @@ -343,11 +343,15 @@ const routes: Route[] = [ const accountData = await runtime.databaseAdapter.getAccountById(message.user_id) + console.log('accountData', accountData) + if (!accountData) { return new Response('Account not found', { status: 404 }) } - const userName = accountData[0].name || 'the user' + const userName = accountData.name || 'the user' + + console.log('userName', userName) const newGoal: Goal = { name: 'First Time User Introduction (HIGH PRIORITY)', @@ -402,6 +406,8 @@ const routes: Route[] = [ room_id }) + console.log('handling message', newMessage) + event.waitUntil(handleMessage(runtime, newMessage)) return new Response('ok', { status: 200 }) diff --git a/packages/app/src/pages/app/FriendProfile/index.tsx b/packages/app/src/pages/app/FriendProfile/index.tsx index fd39f43..98e8c73 100644 --- a/packages/app/src/pages/app/FriendProfile/index.tsx +++ b/packages/app/src/pages/app/FriendProfile/index.tsx @@ -1,8 +1,9 @@ import { Button, Container, Group, Text, useMantineTheme } from "@mantine/core" import { showNotification } from "@mantine/notifications" -import { useSupabaseClient } from "@supabase/auth-helpers-react" +import { useSession, useSupabaseClient } from "@supabase/auth-helpers-react" import React from "react" import { useNavigate } from "react-router-dom" +import { type JSX } from "react/jsx-runtime" import { type Database } from "../../../../types/database.types" import useHandleFriendsRequests from "../../../Hooks/relationships/useHandleFriendRequests" import UserAvatar from "../../../components/UserAvatar" @@ -10,7 +11,6 @@ import { getAvatarImage } from "../../../helpers/getAvatarImage" import useGlobalStore from "../../../store/useGlobalStore" import MainLayout from "../MainLayout.tsx" import useRoomStyles from "../Room/useRoomStyles" -import { type JSX } from "react/jsx-runtime" export default function Profile (): JSX.Element { const navigate = useNavigate() @@ -18,6 +18,7 @@ export default function Profile (): JSX.Element { const supabase = useSupabaseClient() const { classes: roomClasses } = useRoomStyles() const { user } = useGlobalStore() + const session = useSession() const { currentRoom: { @@ -63,6 +64,20 @@ export default function Profile (): JSX.Element { const { error: goalsError } = await supabase.from("goals").delete().eq("user_ids", userIdsArray) if (goalsError) console.error(goalsError) + const serverUrl = import.meta?.env?.REACT_APP_SERVER_URL || import.meta?.env?.VITE_SERVER_URL || "https://cojourney.shawmakesmagic.workers.dev/api/agents/newuser" + + await fetch(serverUrl as string, { + method: "POST", + headers: { + "Content-Type": "application/json", + Authorization: "Bearer " + session?.access_token + }, + body: JSON.stringify({ + user_id: userId, + token: session?.access_token + }) + }) + showNotification({ title: "Memories reset", message: "Memories have been reset successfully",