feat: add embedUri to note create
This commit is contained in:
parent
b2490bb337
commit
ab37a70708
@ -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")
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user