feat: fix posting for lemmy

This commit is contained in:
Nevo David 2025-11-26 15:02:33 +07:00
parent 518d76e972
commit 0c74bb4250
1 changed files with 18 additions and 1 deletions

View File

@ -149,13 +149,30 @@ export class LemmyProvider extends SocialAbstract implements SocialProvider {
const valueArray: PostResponse[] = [];
for (const lemmy of firstPost.settings.subreddit) {
console.log({
community_id: +lemmy.value.id,
name: lemmy.value.title,
body: firstPost.message,
...(lemmy.value.url ? { url: lemmy.value.url } : {}),
...(firstPost.media?.length
? { custom_thumbnail: firstPost.media[0].path }
: {}),
nsfw: false,
});
const { post_view, ...all } = await (
await fetch(body.service + '/api/v3/post', {
body: JSON.stringify({
community_id: +lemmy.value.id,
name: lemmy.value.title,
body: firstPost.message,
...(lemmy.value.url ? { url: lemmy.value.url } : {}),
...(lemmy.value.url
? {
url:
lemmy.value.url.indexOf('http') === -1
? `https://${lemmy.value.url}`
: lemmy.value.url,
}
: {}),
...(firstPost.media?.length
? { custom_thumbnail: firstPost.media[0].path }
: {}),