This commit is contained in:
syuilo 2024-09-23 14:56:24 +09:00
parent fba5ffec46
commit bd3f8cb19c
2 changed files with 28 additions and 14 deletions

View File

@ -807,6 +807,29 @@ export class ClientServerService {
});
});
fastify.get<{ Params: { note: string; } }>('/embed/notes/:note', async (request, reply) => {
reply.removeHeader('X-Frame-Options');
const note = await this.notesRepository.findOneBy({
id: request.params.note,
});
if (note == null) return;
if (note.visibility !== 'public') return;
if (note.userHost != null) return;
const _note = await this.noteEntityService.pack(note, null, { detail: true });
reply.header('Cache-Control', 'public, max-age=3600');
return await reply.view('base-embed', {
title: this.meta.name ?? 'Misskey',
...await this.generateCommonPugData(this.meta),
embedCtx: htmlSafeJsonStringify({
note: _note,
}),
});
});
fastify.get<{ Params: { clip: string; } }>('/embed/clips/:clip', async (request, reply) => {
reply.removeHeader('X-Frame-Options');

View File

@ -5,8 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<template>
<div :class="$style.noteEmbedRoot">
<EmLoading v-if="loading"/>
<EmNoteDetailed v-else-if="note" :note="note"/>
<EmNoteDetailed v-if="note" :note="note"/>
<XNotFound v-else/>
</div>
</template>
@ -24,20 +23,12 @@ const props = defineProps<{
}>();
const note = ref<Misskey.entities.Note | null>(null);
const loading = ref(true);
// TODO: APIHTML
misskeyApi('notes/show', {
const embedCtxEl = document.getElementById('misskey_embedCtx');
const embedCtx = (embedCtxEl && embedCtxEl.textContent) ? JSON.parse(embedCtxEl.textContent) : null;
// NOTE: dev embedCtx null
note.value = embedCtx != null ? embedCtx.note : await misskeyApi('notes/show', {
noteId: props.noteId,
}).then(res => {
//
if (res.url == null && res.uri == null) {
note.value = res;
}
loading.value = false;
}).catch(err => {
console.error(err);
loading.value = false;
});
</script>