diff --git a/gazebot/src/main.rs b/gazebot/src/main.rs index 5bb4223..ea5e11e 100644 --- a/gazebot/src/main.rs +++ b/gazebot/src/main.rs @@ -1,4 +1,6 @@ -use reqwest::header::AUTHORIZATION; +use std::str::FromStr; + +use reqwest::{header::AUTHORIZATION, Url}; use scc::HashMap as ConcurrentHashMap; use serenity::{ all::ActivityData, @@ -52,6 +54,13 @@ impl EventHandler for Handler { note_data.insert("replyTo".to_string(), JsonValue::String(reply_note_id)); } } + // add embed uri + if let Some(uri) = note_content + .split(&[' ', '(', ')'][..]) + .find_map(|s| Url::from_str(s).ok()) + { + note_data.insert("embedUri".to_string(), JsonValue::String(uri.to_string())); + } let resp = self .http .post("https://gaze.systems/log/create") diff --git a/src/routes/log/create/+server.ts b/src/routes/log/create/+server.ts index 0e60410..c4370ee 100644 --- a/src/routes/log/create/+server.ts +++ b/src/routes/log/create/+server.ts @@ -7,6 +7,7 @@ import type { Post, ReplyRef } from '@skyware/bot'; interface NoteData { content: string, replyTo?: string, + embedUri?: string, bskyPosse: boolean, } @@ -61,7 +62,8 @@ export const POST = async ({ request }) => { const postRef = await bot.post({ text: postContent, createdAt: new Date(note.published), - replyRef: replyRef ?? undefined + replyRef: replyRef ?? undefined, + external: noteData.embedUri, }) note.outgoingLinks?.push({name: "bsky", link: postRef.uri}) } catch(why) {