@@ -72,18 +72,17 @@ export const conversationGroup = new Elysia().use(authPlugin).group("/conversati
7272} ,
7373( app ) => {
7474return app
75- . derive ( async ( { locals, params} ) => {
75+ . derive ( async ( { locals, params, query } ) => {
7676let conversation ;
7777let shared = false ;
7878
79- // if theconver
79+ // if theconversation is shared
8080if ( params . id . length === 7 ) {
8181// shared link of length 7
8282conversation = await collections . sharedConversations . findOne ( {
8383_id :params . id ,
8484} ) ;
8585shared = true ;
86-
8786if ( ! conversation ) {
8887throw new Error ( "Conversation not found" ) ;
8988}
@@ -113,6 +112,9 @@ export const conversationGroup = new Elysia().use(authPlugin).group("/conversati
113112
114113throw new Error ( "Conversation not found." ) ;
115114}
115+ if ( query . fromShare && conversation . meta ?. fromShareId === query . fromShare ) {
116+ shared = true ;
117+ }
116118}
117119
118120const convertedConv = {
@@ -123,19 +125,29 @@ export const conversationGroup = new Elysia().use(authPlugin).group("/conversati
123125
124126return { conversation :convertedConv } ;
125127} )
126- . get ( "" , async ( { conversation} ) => {
127- return {
128- messages :conversation . messages ,
129- title :conversation . title ,
130- model :conversation . model ,
131- preprompt :conversation . preprompt ,
132- rootMessageId :conversation . rootMessageId ,
133- id :conversation . _id . toString ( ) ,
134- updatedAt :conversation . updatedAt ,
135- modelId :conversation . model ,
136- shared :conversation . shared ,
137- } ;
138- } )
128+ . get (
129+ "" ,
130+ async ( { conversation} ) => {
131+ return {
132+ messages :conversation . messages ,
133+ title :conversation . title ,
134+ model :conversation . model ,
135+ preprompt :conversation . preprompt ,
136+ rootMessageId :conversation . rootMessageId ,
137+ id :conversation . _id . toString ( ) ,
138+ updatedAt :conversation . updatedAt ,
139+ modelId :conversation . model ,
140+ shared :conversation . shared ,
141+ } ;
142+ } ,
143+ {
144+ query :t . Optional (
145+ t . Object ( {
146+ fromShare :t . Optional ( t . String ( ) ) ,
147+ } )
148+ ) ,
149+ }
150+ )
139151. post ( "" , ( ) => {
140152// todo: post new message
141153throw new Error ( "Not implemented" ) ;