a tool for shared writing and social publishing
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

remove extra merge conflict

-135
-135
actions/publishToPublication.ts
··· 359 359 } 360 360 return; 361 361 } 362 - <<<<<<< HEAD 363 - ======= 364 - 365 - if (b.type === "blockquote") { 366 - let [stringValue, facets] = getBlockContent(b.value); 367 - let block: $Typed<PubLeafletBlocksBlockquote.Main> = { 368 - $type: ids.PubLeafletBlocksBlockquote, 369 - plaintext: stringValue, 370 - facets, 371 - }; 372 - return block; 373 - } 374 - 375 - if (b.type == "text") { 376 - let [stringValue, facets] = getBlockContent(b.value); 377 - let block: $Typed<PubLeafletBlocksText.Main> = { 378 - $type: ids.PubLeafletBlocksText, 379 - plaintext: stringValue, 380 - facets, 381 - }; 382 - return block; 383 - } 384 - if (b.type === "embed") { 385 - let [url] = scan.eav(b.value, "embed/url"); 386 - let [height] = scan.eav(b.value, "embed/height"); 387 - if (!url) return; 388 - let block: $Typed<PubLeafletBlocksIframe.Main> = { 389 - $type: "pub.leaflet.blocks.iframe", 390 - url: url.data.value, 391 - height: Math.floor(height?.data.value || 600), 392 - }; 393 - return block; 394 - } 395 - if (b.type == "image") { 396 - let [image] = scan.eav(b.value, "block/image"); 397 - if (!image) return; 398 - let [altText] = scan.eav(b.value, "image/alt"); 399 - let blobref = imageMap.get(image.data.src); 400 - if (!blobref) return; 401 - let block: $Typed<PubLeafletBlocksImage.Main> = { 402 - $type: "pub.leaflet.blocks.image", 403 - image: blobref, 404 - aspectRatio: { 405 - height: image.data.height, 406 - width: image.data.width, 407 - }, 408 - alt: altText ? altText.data.value : undefined, 409 - }; 410 - return block; 411 - } 412 - if (b.type === "link") { 413 - let [previewImage] = scan.eav(b.value, "link/preview"); 414 - let [description] = scan.eav(b.value, "link/description"); 415 - let [src] = scan.eav(b.value, "link/url"); 416 - if (!src) return; 417 - let blobref = previewImage 418 - ? imageMap.get(previewImage?.data.src) 419 - : undefined; 420 - let [title] = scan.eav(b.value, "link/title"); 421 - let block: $Typed<PubLeafletBlocksWebsite.Main> = { 422 - $type: "pub.leaflet.blocks.website", 423 - previewImage: blobref, 424 - src: src.data.value, 425 - description: description?.data.value, 426 - title: title?.data.value, 427 - }; 428 - return block; 429 - } 430 - if (b.type === "code") { 431 - let [language] = scan.eav(b.value, "block/code-language"); 432 - let [code] = scan.eav(b.value, "block/code"); 433 - let [theme] = scan.eav(root_entity, "theme/code-theme"); 434 - let block: $Typed<PubLeafletBlocksCode.Main> = { 435 - $type: "pub.leaflet.blocks.code", 436 - language: language?.data.value, 437 - plaintext: code?.data.value || "", 438 - syntaxHighlightingTheme: theme?.data.value, 439 - }; 440 - return block; 441 - } 442 - if (b.type === "math") { 443 - let [math] = scan.eav(b.value, "block/math"); 444 - let block: $Typed<PubLeafletBlocksMath.Main> = { 445 - $type: "pub.leaflet.blocks.math", 446 - tex: math?.data.value || "", 447 - }; 448 - return block; 449 - } 450 - return; 451 - } 452 - 453 - async function sendPostToEmailSubscribers( 454 - publication_uri: string, 455 - post: { content: string; title: string }, 456 - ) { 457 - let { data: publication } = await supabaseServerClient 458 - .from("publications") 459 - .select("*, subscribers_to_publications(*)") 460 - .eq("uri", publication_uri) 461 - .single(); 462 - 463 - let res = await fetch("https://api.postmarkapp.com/email/batch", { 464 - method: "POST", 465 - headers: { 466 - "Content-Type": "application/json", 467 - "X-Postmark-Server-Token": process.env.POSTMARK_API_KEY!, 468 - }, 469 - body: JSON.stringify( 470 - publication?.subscribers_to_publications.map((sub) => ({ 471 - Headers: [ 472 - { 473 - Name: "List-Unsubscribe-Post", 474 - Value: "List-Unsubscribe=One-Click", 475 - }, 476 - { 477 - Name: "List-Unsubscribe", 478 - Value: `<${"TODO"}/mail/unsubscribe?sub_id=${sub.identity}>`, 479 - }, 480 - ], 481 - MessageStream: "broadcast", 482 - From: `${publication.name} <mailbox@leaflet.pub>`, 483 - Subject: post.title, 484 - To: sub.identity, 485 - HtmlBody: ` 486 - <h1>${publication.name}</h1> 487 - <hr style="margin-top: 1em; margin-bottom: 1em;"> 488 - ${post.content} 489 - <hr style="margin-top: 1em; margin-bottom: 1em;"> 490 - This is a super alpha release! Ask Jared if you want to unsubscribe (sorry) 491 - `, 492 - TextBody: post.content, 493 - })), 494 - ), 495 - }); 496 - >>>>>>> main 497 362 } 498 363 499 364 function YJSFragmentToFacets(