webmention-handler
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -229,13 +229,16 @@ 'use strict'; | ||
const { html, status, error } = await fetchHtml(mention.source); | ||
// Delete exisiting webmentions with the current source and target to avoid duplication | ||
await this.storageHandler.deleteMention(mention); | ||
// A status of 410 indicates that the webmention that previously existed was deleted | ||
// If we got an error or there was no html body, then the source is invalid and | ||
// we should delete any stored version of the webmention as per the specification | ||
// we should delete any stored version of the webmention as per the specification without | ||
// adding new ones | ||
if (error || !html || status === 410) | ||
return this.storageHandler.deleteMention(mention); | ||
return null; | ||
const hEntries = parseHtml(html, mention.source, mention.target); | ||
let mentionedUrls = hEntries.find(({ type }) => type && type.includes("mention-of")); | ||
// If the page does not include any mention of the target, then delete any previously | ||
// acknowledged mentions and retun null; | ||
// If the page does not include any mention of the target, then we can return | ||
// early as we have already deleted any stored mentions with this target and source | ||
if (!mentionedUrls) | ||
return this.storageHandler.deleteMention(mention); | ||
return null; | ||
let mentions = hEntries.map(h => convertHEntryToMention(h, mention.source, mention.target)); | ||
@@ -242,0 +245,0 @@ if (mentions.length > 1) |
{ | ||
"name": "webmention-handler", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "A handler for web mentions", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
94840
1059