fix: crosspost problems/cleanup for instance hosts
This commit is contained in:
4 files changed
+46
-44
No files matched your search
@@ -38,7 +38,7 @@
|
|||||||
<EntityHeader
|
<EntityHeader
|
||||||
name={site.site.name}
|
name={site.site.name}
|
||||||
avatar={site.site.icon}
|
avatar={site.site.icon}
|
||||||
banner={site.site.banner}
|
banner={site.site.banner ?? null}
|
||||||
compact="always"
|
compact="always"
|
||||||
avatarCircle={false}
|
avatarCircle={false}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
Trash,
|
Trash,
|
||||||
XMark,
|
XMark,
|
||||||
} from 'svelte-hero-icons/dist'
|
} from 'svelte-hero-icons/dist'
|
||||||
import type { PostFormInit } from '../form/postform.svelte'
|
import { type PostFormInit } from '../form/postform.svelte'
|
||||||
import { hidePost } from '../helpers'
|
import { hidePost } from '../helpers'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -27,6 +27,21 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
let { post = $bindable(), onhide, editing = $bindable() }: Props = $props()
|
let { post = $bindable(), onhide, editing = $bindable() }: Props = $props()
|
||||||
|
|
||||||
|
function crosspostB64() {
|
||||||
|
return JSON.stringify({
|
||||||
|
body: `${
|
||||||
|
settings.crosspostOriginalLink
|
||||||
|
? `cross-posted from: ${post.post.ap_id}`
|
||||||
|
: ``
|
||||||
|
}\n${
|
||||||
|
post.post.body ? '>' + post.post.body.split('\n').join('\n> ') : ''
|
||||||
|
}`,
|
||||||
|
name: post.post.name,
|
||||||
|
url: post.post.url,
|
||||||
|
nsfw: post.post.nsfw,
|
||||||
|
} as PostFormInit)
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if profile.current?.user && profile.current?.jwt && profile.current.user.local_user_view.person.id == post.creator.id}
|
{#if profile.current?.user && profile.current?.jwt && profile.current.user.local_user_view.person.id == post.creator.id}
|
||||||
@@ -49,20 +64,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
{#if profile.current?.jwt}
|
{#if profile.current?.jwt}
|
||||||
<MenuButton
|
<MenuButton
|
||||||
href="/create/post?crosspost={btoa(
|
href="/create/post?crosspost={crosspostB64()}"
|
||||||
JSON.stringify({
|
|
||||||
body: `${
|
|
||||||
settings.crosspostOriginalLink
|
|
||||||
? `cross-posted from: ${post.post.ap_id}`
|
|
||||||
: ``
|
|
||||||
}\n${
|
|
||||||
post.post.body ? '>' + post.post.body.split('\n').join('\n> ') : ''
|
|
||||||
}`,
|
|
||||||
name: post.post.name,
|
|
||||||
url: post.post.url,
|
|
||||||
nsfw: post.post.nsfw,
|
|
||||||
} as PostFormInit),
|
|
||||||
)}"
|
|
||||||
icon={ArrowTopRightOnSquare}
|
icon={ArrowTopRightOnSquare}
|
||||||
>
|
>
|
||||||
{$t('post.actions.more.crosspost')}
|
{$t('post.actions.more.crosspost')}
|
||||||
|
|||||||
@@ -8,11 +8,11 @@
|
|||||||
import Blobs from './Blobs.svelte'
|
import Blobs from './Blobs.svelte'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
avatar?: string | undefined
|
avatar?: string
|
||||||
name: string
|
name: string
|
||||||
bio?: string | undefined
|
bio?: string
|
||||||
banner?: string | undefined
|
banner?: string | null
|
||||||
url?: string | undefined
|
url?: string
|
||||||
stats?: {
|
stats?: {
|
||||||
name: string
|
name: string
|
||||||
value: string | number
|
value: string | number
|
||||||
@@ -27,11 +27,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
avatar = undefined,
|
avatar,
|
||||||
name,
|
name,
|
||||||
bio = undefined,
|
bio,
|
||||||
banner = undefined,
|
banner,
|
||||||
url = undefined,
|
url,
|
||||||
stats = [],
|
stats = [],
|
||||||
class: clazz = '',
|
class: clazz = '',
|
||||||
nameDetail,
|
nameDetail,
|
||||||
@@ -45,22 +45,24 @@
|
|||||||
|
|
||||||
<div {...rest} class={['z-10 text-sm w-full space-y-4 @container', clazz]}>
|
<div {...rest} class={['z-10 text-sm w-full space-y-4 @container', clazz]}>
|
||||||
<Material padding="xl" rounding="3xl" class="flex flex-col gap-2 @lg:gap-4">
|
<Material padding="xl" rounding="3xl" class="flex flex-col gap-2 @lg:gap-4">
|
||||||
<div
|
{#if banner !== null}
|
||||||
class="relative overflow-hidden rounded-t-[inherit] -m-6 mask-b-from-0 h-32 @lg:h-48"
|
<div
|
||||||
>
|
class="relative overflow-hidden rounded-t-[inherit] -m-6 mask-b-from-0 h-32 @lg:h-48"
|
||||||
{#if banner}
|
>
|
||||||
<img
|
{#if banner}
|
||||||
src={banner}
|
<img
|
||||||
class="w-full object-cover h-full bg-white dark:bg-zinc-900"
|
src={banner}
|
||||||
height="192"
|
class="w-full object-cover h-full bg-white dark:bg-zinc-900"
|
||||||
alt="User banner"
|
height="192"
|
||||||
/>
|
alt="User banner"
|
||||||
{:else}
|
/>
|
||||||
<div class="scale-150 h-full">
|
{:else}
|
||||||
<Blobs seed={name} />
|
<div class="scale-150 h-full">
|
||||||
</div>
|
<Blobs seed={name} />
|
||||||
{/if}
|
</div>
|
||||||
</div>
|
{/if}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
{#snippet icon(width: number)}
|
{#snippet icon(width: number)}
|
||||||
<Avatar
|
<Avatar
|
||||||
@@ -70,7 +72,7 @@
|
|||||||
circle={avatarCircle}
|
circle={avatarCircle}
|
||||||
class={[
|
class={[
|
||||||
'relative',
|
'relative',
|
||||||
'-mt-4 @md:-mt-8',
|
banner !== null && '-mt-4 @md:-mt-8',
|
||||||
!avatarCircle && 'rounded-xl @md:rounded-3xl!',
|
!avatarCircle && 'rounded-xl @md:rounded-3xl!',
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -23,9 +23,7 @@
|
|||||||
let crosspost = $derived.by<PostFormInit>(() => {
|
let crosspost = $derived.by<PostFormInit>(() => {
|
||||||
const crosspostParam = page.url.searchParams.get('crosspost')
|
const crosspostParam = page.url.searchParams.get('crosspost')
|
||||||
try {
|
try {
|
||||||
return crosspostParam
|
return crosspostParam ? JSON.parse(crosspostParam || '{}') : undefined
|
||||||
? JSON.parse(atob(crosspostParam) || '{}')
|
|
||||||
: undefined
|
|
||||||
} catch {
|
} catch {
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user