fedimbed: quoted fix, forgot bsky quotes
This commit is contained in:
		
							parent
							
								
									37c09e1944
								
							
						
					
					
						commit
						e9ad6e570d
					
				
					 1 changed files with 54 additions and 35 deletions
				
			
		| 
						 | 
					@ -325,7 +325,7 @@ function getStatsBluesky(post) {
 | 
				
			||||||
  return stats.join("\u3000");
 | 
					  return stats.join("\u3000");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
async function blueskyQuoteEmbed(quote) {
 | 
					async function blueskyQuoteEmbed(quote, minimal = false) {
 | 
				
			||||||
  const images = [];
 | 
					  const images = [];
 | 
				
			||||||
  const videos = [];
 | 
					  const videos = [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -349,6 +349,10 @@ async function blueskyQuoteEmbed(quote) {
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  const quoteUrl = `https://bsky.app/profile/${quote.author.did}/post/${quote.uri.substring(
 | 
				
			||||||
 | 
					    quote.uri.lastIndexOf("/") + 1
 | 
				
			||||||
 | 
					  )}`;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  for (const label of quote.labels) {
 | 
					  for (const label of quote.labels) {
 | 
				
			||||||
    if (label.val === "!hide") {
 | 
					    if (label.val === "!hide") {
 | 
				
			||||||
      hidden = true;
 | 
					      hidden = true;
 | 
				
			||||||
| 
						 | 
					@ -373,7 +377,14 @@ async function blueskyQuoteEmbed(quote) {
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  content = content.replaceAll("`", "\u02cb").replaceAll("*", "\u2217").replaceAll("||", "|\u200b|");
 | 
					  content = content.replaceAll("`", "\u02cb").replaceAll("*", "\u2217").replaceAll("||", "|\u200b|");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const header = [
 | 
					  const header = minimal
 | 
				
			||||||
 | 
					    ? [
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          type: 10,
 | 
				
			||||||
 | 
					          content: `### ${Icons.fedimbed.quote} [${quote.author.displayName} (@${quote.author.handle})](${quoteUrl})`,
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					      ]
 | 
				
			||||||
 | 
					    : [
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
          type: 10,
 | 
					          type: 10,
 | 
				
			||||||
          content: `-# ${Icons.fedimbed.quote} Quoted Post`,
 | 
					          content: `-# ${Icons.fedimbed.quote} Quoted Post`,
 | 
				
			||||||
| 
						 | 
					@ -445,7 +456,14 @@ async function blueskyQuoteEmbed(quote) {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const footer = {
 | 
					  const footer = minimal
 | 
				
			||||||
 | 
					    ? {
 | 
				
			||||||
 | 
					        type: 10,
 | 
				
			||||||
 | 
					        content: `${Icons.fedimbed.bluesky} Bluesky \u2022 <t:${Math.floor(
 | 
				
			||||||
 | 
					          new Date(quote.value.createdAt).getTime() / 1000
 | 
				
			||||||
 | 
					        )}:F>`,
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    : {
 | 
				
			||||||
        type: 9,
 | 
					        type: 9,
 | 
				
			||||||
        components: [
 | 
					        components: [
 | 
				
			||||||
          {
 | 
					          {
 | 
				
			||||||
| 
						 | 
					@ -459,7 +477,7 @@ async function blueskyQuoteEmbed(quote) {
 | 
				
			||||||
          type: 2,
 | 
					          type: 2,
 | 
				
			||||||
          style: 5,
 | 
					          style: 5,
 | 
				
			||||||
          label: "View Post",
 | 
					          label: "View Post",
 | 
				
			||||||
      url: `https://bsky.app/profile/${quote.author.did}/post/${quote.uri.substring(quote.uri.lastIndexOf("/") + 1)}`,
 | 
					          url: quoteUrl,
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
      };
 | 
					      };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -565,7 +583,7 @@ async function bluesky(msg, url, spoiler = false, minimal = false) {
 | 
				
			||||||
      case "app.bsky.embed.record#view": {
 | 
					      case "app.bsky.embed.record#view": {
 | 
				
			||||||
        hasQuote = true;
 | 
					        hasQuote = true;
 | 
				
			||||||
        const quote = post.embed.record;
 | 
					        const quote = post.embed.record;
 | 
				
			||||||
        quoteData = await blueskyQuoteEmbed(quote);
 | 
					        quoteData = await blueskyQuoteEmbed(quote, minimal);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (quoteData.adult) adult = true;
 | 
					        if (quoteData.adult) adult = true;
 | 
				
			||||||
        if (quoteData.hidden) hidden = true;
 | 
					        if (quoteData.hidden) hidden = true;
 | 
				
			||||||
| 
						 | 
					@ -1551,8 +1569,9 @@ async function processUrl(msg, url, spoiler = false, command = false, inQuote =
 | 
				
			||||||
    const quoteComponents = quoteRes.response.components[0].components;
 | 
					    const quoteComponents = quoteRes.response.components[0].components;
 | 
				
			||||||
    const quoteContext = `-# ${Icons.fedimbed.quote} Quoted Post`;
 | 
					    const quoteContext = `-# ${Icons.fedimbed.quote} Quoted Post`;
 | 
				
			||||||
    if (quoteComponents[0].type == 10) {
 | 
					    if (quoteComponents[0].type == 10) {
 | 
				
			||||||
      quoteComponents[0].content =
 | 
					      quoteComponents[0].content = minimal
 | 
				
			||||||
        (minimal ? Icons.fedimbed.quote + " " : quoteContext + "\n") + quoteComponents[0].content;
 | 
					        ? quoteComponents[0].content.replace(/^### /, "$& " + Icons.fedimbed.quote)
 | 
				
			||||||
 | 
					        : quoteContext + "\n" + quoteComponents[0].content;
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      quoteComponents.splice(0, 0, {type: 10, content: quoteContext});
 | 
					      quoteComponents.splice(0, 0, {type: 10, content: quoteContext});
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue