diff --git a/src/lib/backend/convex/conversations.ts b/src/lib/backend/convex/conversations.ts
index 946760b..243e7a2 100644
--- a/src/lib/backend/convex/conversations.ts
+++ b/src/lib/backend/convex/conversations.ts
@@ -304,6 +304,21 @@ export const remove = mutation({
},
});
+export const getPublicById = query({
+ args: {
+ conversation_id: v.id('conversations'),
+ },
+ handler: async (ctx, args) => {
+ const conversation = await ctx.db.get(args.conversation_id);
+
+ if (!conversation || !conversation.public) {
+ return null;
+ }
+
+ return conversation;
+ },
+});
+
export const search = query({
args: {
session_token: v.string(),
diff --git a/src/lib/backend/convex/messages.ts b/src/lib/backend/convex/messages.ts
index fc3a0b8..edb01f5 100644
--- a/src/lib/backend/convex/messages.ts
+++ b/src/lib/backend/convex/messages.ts
@@ -169,6 +169,28 @@ export const updateMessage = mutation({
},
});
+export const getByConversationPublic = query({
+ args: {
+ conversation_id: v.id('conversations'),
+ },
+ handler: async (ctx, args) => {
+ // First check if the conversation is public
+ const conversation = await ctx.db.get(args.conversation_id);
+
+ if (!conversation || !conversation.public) {
+ return null;
+ }
+
+ const messages = await ctx.db
+ .query('messages')
+ .withIndex('by_conversation', (q) => q.eq('conversation_id', args.conversation_id))
+ .order('asc')
+ .collect();
+
+ return messages;
+ },
+});
+
export const updateError = mutation({
args: {
session_token: v.string(),
diff --git a/src/lib/components/ui/share-button/index.ts b/src/lib/components/ui/share-button/index.ts
new file mode 100644
index 0000000..ee003e6
--- /dev/null
+++ b/src/lib/components/ui/share-button/index.ts
@@ -0,0 +1 @@
+export { default as ShareButton } from './share-button.svelte';
\ No newline at end of file
diff --git a/src/lib/components/ui/share-button/share-button.svelte b/src/lib/components/ui/share-button/share-button.svelte
new file mode 100644
index 0000000..aae5ced
--- /dev/null
+++ b/src/lib/components/ui/share-button/share-button.svelte
@@ -0,0 +1,145 @@
+
+
+
Public sharing
+Anyone with the link can view this conversation
++ Enable public sharing to generate a shareable link +
+ {/if} +