fedimbed: attempt to fix images
This commit is contained in:
		
							parent
							
								
									fd98ba3667
								
							
						
					
					
						commit
						6f8596a55f
					
				
					 1 changed files with 13 additions and 16 deletions
				
			
		| 
						 | 
				
			
			@ -1062,20 +1062,21 @@ async function processUrl(msg, url, spoiler = false, command = false) {
 | 
			
		|||
      for (const attachment of attachments) {
 | 
			
		||||
        const type = attachment.type?.toLowerCase();
 | 
			
		||||
 | 
			
		||||
        const attDesc = attachment.description ?? attachment.comment;
 | 
			
		||||
        if (type.startsWith("image")) {
 | 
			
		||||
          images.push({
 | 
			
		||||
            media: {url: attachment.url},
 | 
			
		||||
            description: attachment.description ?? attachment.comment,
 | 
			
		||||
            description: attDesc?.length > 0 ? attDesc : null,
 | 
			
		||||
          });
 | 
			
		||||
        } else if (type.startsWith("video")) {
 | 
			
		||||
          videos.push({
 | 
			
		||||
            media: {url: attachment.url},
 | 
			
		||||
            description: attachment.description ?? attachment.comment,
 | 
			
		||||
            description: attDesc?.length > 0 ? attDesc : null,
 | 
			
		||||
          });
 | 
			
		||||
        } else if (type.startsWith("audio")) {
 | 
			
		||||
          audios.push({
 | 
			
		||||
            url: attachment.url,
 | 
			
		||||
            description: attachment.description ?? attachment.comment,
 | 
			
		||||
            description: attDesc?.length > 0 ? attDesc : null,
 | 
			
		||||
          });
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
| 
						 | 
				
			
			@ -1142,7 +1143,7 @@ async function processUrl(msg, url, spoiler = false, command = false) {
 | 
			
		|||
          })
 | 
			
		||||
            .then((res) => res.json())
 | 
			
		||||
            .catch((err) => {
 | 
			
		||||
              /*if (platform !== "cohost")*/ logger.error("fedimbed", `Failed to get author for "${url}": ${err}`);
 | 
			
		||||
              logger.error("fedimbed", `Failed to get author for "${url}": ${err}`);
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
          if (authorData) {
 | 
			
		||||
| 
						 | 
				
			
			@ -1186,20 +1187,21 @@ async function processUrl(msg, url, spoiler = false, command = false) {
 | 
			
		|||
            }
 | 
			
		||||
          }
 | 
			
		||||
 | 
			
		||||
          const attDesc = attachment.name ?? attachment.description ?? attachment.comment;
 | 
			
		||||
          if (type.startsWith("image")) {
 | 
			
		||||
            images.push({
 | 
			
		||||
              media: {url: attUrl},
 | 
			
		||||
              description: attachment.name ?? attachment.description ?? attachment.comment,
 | 
			
		||||
              description: attDesc?.length > 0 ? attDesc : null,
 | 
			
		||||
            });
 | 
			
		||||
          } else if (type.startsWith("video")) {
 | 
			
		||||
            videos.push({
 | 
			
		||||
              media: {url: attUrl},
 | 
			
		||||
              description: attachment.name ?? attachment.description ?? attachment.comment,
 | 
			
		||||
              description: attDesc?.length > 0 ? attDesc : null,
 | 
			
		||||
            });
 | 
			
		||||
          } else if (type.startsWith("audio")) {
 | 
			
		||||
            audios.push({
 | 
			
		||||
              url: attUrl,
 | 
			
		||||
              description: attachment.name ?? attachment.description ?? attachment.comment,
 | 
			
		||||
              description: attDesc?.length > 0 ? attDesc : null,
 | 
			
		||||
            });
 | 
			
		||||
          }
 | 
			
		||||
        } else {
 | 
			
		||||
| 
						 | 
				
			
			@ -1403,10 +1405,10 @@ async function processUrl(msg, url, spoiler = false, command = false) {
 | 
			
		|||
 | 
			
		||||
            return `> **${o.name}** (${numberFormatter.format(o.count)}, ${Math.round(
 | 
			
		||||
              percent * 100
 | 
			
		||||
            )}%)> \n\`${"\u2588".repeat(bar)}${" ".repeat(32 - bar)}\``;
 | 
			
		||||
            )}%\n> \`${"\u2588".repeat(bar)}${" ".repeat(32 - bar)}\``;
 | 
			
		||||
          })
 | 
			
		||||
          .join("> \n> \n") +
 | 
			
		||||
        `> \n> \n${poll.total} votes \u2022 End${pollTime > now ? "s" : "ed"} <t:${Math.floor(pollTime / 1000)}:R>`,
 | 
			
		||||
          .join("\n> \n> ") +
 | 
			
		||||
        `\n> \n> ${poll.total} votes \u2022 End${pollTime > now ? "s" : "ed"} <t:${Math.floor(pollTime / 1000)}:R>`,
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1425,11 +1427,6 @@ async function processUrl(msg, url, spoiler = false, command = false) {
 | 
			
		|||
      url,
 | 
			
		||||
    },
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  for (const image in images) {
 | 
			
		||||
    if (image.description?.length === 0) image.description = null;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (images.length > 0) {
 | 
			
		||||
    if (images.length > 10) {
 | 
			
		||||
      while (images.length > 10) {
 | 
			
		||||
| 
						 | 
				
			
			@ -1491,7 +1488,7 @@ async function processUrl(msg, url, spoiler = false, command = false) {
 | 
			
		|||
  return {
 | 
			
		||||
    response: {
 | 
			
		||||
      flags: 1 << 15,
 | 
			
		||||
      components: [cw.length > 0 ? warningText : false, container].filter((x) => !!x),
 | 
			
		||||
      components: [cw.length > 0 && warningText, container].filter((x) => !!x),
 | 
			
		||||
      allowedMentions: {
 | 
			
		||||
        repliedUser: false,
 | 
			
		||||
      },
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue