fix: use interface for note create, actually remove tag in bot
All checks were successful
create archive with lfs / tag (push) Successful in 9s
All checks were successful
create archive with lfs / tag (push) Successful in 9s
This commit is contained in:
parent
f4a74a0113
commit
04006bda91
@ -22,12 +22,12 @@ impl EventHandler for Handler {
|
||||
let mut note_content = msg.content.clone();
|
||||
|
||||
const BSKY_TAG: &str = ".nobsky";
|
||||
let post_to_bsky = !note_content.contains(BSKY_TAG);
|
||||
if post_to_bsky {
|
||||
let no_bsky_posse = note_content.contains(BSKY_TAG);
|
||||
if no_bsky_posse {
|
||||
note_content = note_content.replace(BSKY_TAG, "");
|
||||
}
|
||||
|
||||
let note_data = json!({"content": note_content.trim(), "bskyPosse": post_to_bsky});
|
||||
let note_data = json!({"content": note_content.trim(), "bskyPosse": !no_bsky_posse});
|
||||
let resp = self
|
||||
.http
|
||||
.post("https://gaze.systems/log/create")
|
||||
|
@ -4,6 +4,10 @@ import { bskyClient, loginToBsky } from '$lib';
|
||||
import { createNote } from '$lib/notes.js';
|
||||
import { get } from 'svelte/store';
|
||||
|
||||
interface NoteData {
|
||||
content: string,
|
||||
bskyPosse: boolean,
|
||||
}
|
||||
|
||||
export const POST = async ({ request }) => {
|
||||
const token = request.headers.get('authorization')
|
||||
@ -11,16 +15,13 @@ export const POST = async ({ request }) => {
|
||||
return new Response("rizz failed", { status: 403 })
|
||||
}
|
||||
// get note data
|
||||
const noteData = await request.json()
|
||||
const noteData: NoteData = await request.json()
|
||||
console.log("want to create note with data: ", noteData)
|
||||
if (noteData.content ?? null === null) {
|
||||
return new Response("no rizz :(", { status: 400 })
|
||||
}
|
||||
// create note
|
||||
const published = Date.now()
|
||||
const noteId = createNote({ content: noteData.content, published })
|
||||
// bridge to bsky if want to bridge
|
||||
if (noteData.bskyPosse ?? false) {
|
||||
if (noteData.bskyPosse) {
|
||||
let client = get(bskyClient)
|
||||
if (client === null) {
|
||||
client = await loginToBsky()
|
||||
|
Loading…
Reference in New Issue
Block a user