fedimbed: nullcheck postData, misskey mastoapi emoji fix
This commit is contained in:
		
							parent
							
								
									9fba9d2c9e
								
							
						
					
					
						commit
						134f417b91
					
				
					 1 changed files with 8 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -786,7 +786,9 @@ async function processUrl(msg, url, spoiler = false, command = false) {
 | 
			
		|||
  // Fetch post
 | 
			
		||||
  const postData = await fetchPost(url, platform);
 | 
			
		||||
 | 
			
		||||
  if (postData._fedimbed_mastoapi) {
 | 
			
		||||
  if (!postData) {
 | 
			
		||||
    return {};
 | 
			
		||||
  } else if (postData._fedimbed_mastoapi) {
 | 
			
		||||
    if (postData.url) {
 | 
			
		||||
      const realUrlObj = new URL(postData.url);
 | 
			
		||||
      if (realUrlObj.origin != urlObj.origin) {
 | 
			
		||||
| 
						 | 
				
			
			@ -812,7 +814,9 @@ async function processUrl(msg, url, spoiler = false, command = false) {
 | 
			
		|||
      avatar: postData.account?.avatar ?? postData.user?.avatarUrl,
 | 
			
		||||
    };
 | 
			
		||||
    timestamp = postData.created_at ?? postData.createdAt;
 | 
			
		||||
    emotes = postData.emojis.filter((x) => !x.name.endsWith("#.")).map((x) => ({name: `:${x.name}:`, url: x.url}));
 | 
			
		||||
    emotes = postData.emojis
 | 
			
		||||
      .filter((x) => !(x.name ?? x.shortcode)?.endsWith("#."))
 | 
			
		||||
      .map((x) => ({name: `:${x.name ?? x.shortcode}:`, url: x.url}));
 | 
			
		||||
    sensitive = postData.sensitive;
 | 
			
		||||
 | 
			
		||||
    if (postData.in_reply_to_id) {
 | 
			
		||||
| 
						 | 
				
			
			@ -1487,6 +1491,7 @@ events.add("messageCreate", "fedimbed", async function (msg) {
 | 
			
		|||
          logger.verbose("fedimbed", `Hit "${service}" for "${url}", processing now.`);
 | 
			
		||||
          try {
 | 
			
		||||
            const {response, sendWait} = await processUrl(msg, url, hasSpoiler);
 | 
			
		||||
            if (!response) return;
 | 
			
		||||
            await msg.channel.createMessage(response).then(() => {
 | 
			
		||||
              if (sendWait) {
 | 
			
		||||
                msg.removeReaction("\uD83D\uDCE4");
 | 
			
		||||
| 
						 | 
				
			
			@ -1497,7 +1502,7 @@ events.add("messageCreate", "fedimbed", async function (msg) {
 | 
			
		|||
              }
 | 
			
		||||
            });
 | 
			
		||||
          } catch (err) {
 | 
			
		||||
            logger.error("fedimbed", `Error processing "${url}":\n` + err.stack);
 | 
			
		||||
            logger.error("fedimbed", `Error processing "${url}":\n${err.stack}`);
 | 
			
		||||
          }
 | 
			
		||||
          break;
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue