feat: add embedUri to note create

This commit is contained in:
dusk 2024-12-16 18:23:37 +03:00
parent b2490bb337
commit ab37a70708
Signed by: dusk
SSH Key Fingerprint: SHA256:Abmvag+juovVufZTxyWY8KcVgrznxvBjQpJesv071Aw
2 changed files with 13 additions and 2 deletions

View File

@ -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")

View File

@ -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) {