likes do not have content, separate out the type
This commit is contained in:
parent
336f05bbb2
commit
ff1bd9b2c9
|
@ -72,7 +72,7 @@ function publishedNow() {
|
||||||
|
|
||||||
function parseBodyAsIndiewebSite(source, target, hEntry) {
|
function parseBodyAsIndiewebSite(source, target, hEntry) {
|
||||||
function shorten(txt) {
|
function shorten(txt) {
|
||||||
if(txt.length <= 250) return txt
|
if(!txt || txt.length <= 250) return txt
|
||||||
return txt.substring(0, 250) + "..."
|
return txt.substring(0, 250) + "..."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,6 +85,7 @@ function parseBodyAsIndiewebSite(source, target, hEntry) {
|
||||||
const publishedDate = hEntry.properties?.published?.[0]
|
const publishedDate = hEntry.properties?.published?.[0]
|
||||||
const uid = hEntry.properties?.uid?.[0]
|
const uid = hEntry.properties?.uid?.[0]
|
||||||
const url = hEntry.properties?.url?.[0]
|
const url = hEntry.properties?.url?.[0]
|
||||||
|
const type = hEntry.properties?.["like-of"]?.length ? "like" : "mention"
|
||||||
|
|
||||||
return {
|
return {
|
||||||
author: {
|
author: {
|
||||||
|
@ -94,6 +95,7 @@ function parseBodyAsIndiewebSite(source, target, hEntry) {
|
||||||
name: name,
|
name: name,
|
||||||
content: summary ? shorten(summary) : shorten(contentEntry),
|
content: summary ? shorten(summary) : shorten(contentEntry),
|
||||||
published: publishedDate ? publishedDate : publishedNow(),
|
published: publishedDate ? publishedDate : publishedNow(),
|
||||||
|
type,
|
||||||
// Mastodon uids start with "tag:server", but we do want indieweb uids from other sources
|
// Mastodon uids start with "tag:server", but we do want indieweb uids from other sources
|
||||||
url: uid && uid.startsWith("http") ? uid : (url ? url : source),
|
url: uid && uid.startsWith("http") ? uid : (url ? url : source),
|
||||||
source,
|
source,
|
||||||
|
@ -112,6 +114,7 @@ function parseBodyAsNonIndiewebSite(source, target, body) {
|
||||||
content: title,
|
content: title,
|
||||||
published: publishedNow(),
|
published: publishedNow(),
|
||||||
url: source,
|
url: source,
|
||||||
|
type: "mention",
|
||||||
source,
|
source,
|
||||||
target
|
target
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta http-equiv="refresh" content="0;url=https://chat.brainbaking.com/notice/A4nx1rFwKUJYSe4TqK#favorited-by-A4nwg4LYyh4WgrJOXg">
|
||||||
|
<title>Stampeding Longhorn</title>
|
||||||
|
<style type="text/css">
|
||||||
|
body {
|
||||||
|
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
|
||||||
|
}
|
||||||
|
.p-uid {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.u-photo {
|
||||||
|
max-width: 50px;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
.e-content {
|
||||||
|
margin-top: 10px;
|
||||||
|
font-size: 1.3em;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<article class="h-entry">
|
||||||
|
<span class="p-uid">tag:chat.brainbaking.com,2013:A4nx1rFwKUJYSe4TqK_favorited_by_A4nwg4LYyh4WgrJOXg</span>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<span class="p-author h-card">
|
||||||
|
<data class="p-uid" value="tag:social.linux.pizza,2013:StampedingLonghorn"></data>
|
||||||
|
<data class="p-numeric-id" value="A4nwg4LYyh4WgrJOXg"></data>
|
||||||
|
<a class="p-name u-url" href="https://social.linux.pizza/@StampedingLonghorn">Stampeding Longhorn</a>
|
||||||
|
<a class="u-url" href="https://chat.brainbaking.com/@StampedingLonghorn"></a>
|
||||||
|
<span class="p-nickname">StampedingLonghorn</span>
|
||||||
|
<img class="u-photo" src="https://cdn.social.linux.pizza/v1/AUTH_91eb37814936490c95da7b85993cc2ff/sociallinuxpizza/accounts/avatars/000/185/996/original/9e36da0c093cfc9b.png" alt="" />
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<a class="p-name u-url" href="https://chat.brainbaking.com/notice/A4nx1rFwKUJYSe4TqK#favorited-by-A4nwg4LYyh4WgrJOXg"></a>
|
||||||
|
<div class="">
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a class="u-like-of" href="https://chat.brainbaking.com/notice/A4nx1rFwKUJYSe4TqK"></a>
|
||||||
|
<a class="u-like-of" href="https://brainbaking.com/valid-indieweb-target.html"></a>
|
||||||
|
|
||||||
|
</article>
|
||||||
|
|
||||||
|
</html>
|
|
@ -26,6 +26,32 @@ describe("receive webmention process tests happy path", () => {
|
||||||
return `${dumpdir}/` + md5(`source=${body.source},target=${body.target}`)
|
return `${dumpdir}/` + md5(`source=${body.source},target=${body.target}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test("receive a brid.gy webmention like", async () => {
|
||||||
|
const body = {
|
||||||
|
source: "https://brainbaking.com/valid-bridgy-like.html",
|
||||||
|
// wrapped in a a class="u-like-of" tag
|
||||||
|
target: "https://brainbaking.com/valid-indieweb-target.html"
|
||||||
|
}
|
||||||
|
await receive(body)
|
||||||
|
|
||||||
|
const result = await fsp.readFile(`${asFilename(body)}.json`, 'utf-8')
|
||||||
|
const data = JSON.parse(result)
|
||||||
|
|
||||||
|
expect(data).toEqual({
|
||||||
|
author: {
|
||||||
|
name: "Stampeding Longhorn",
|
||||||
|
picture: "https://cdn.social.linux.pizza/v1/AUTH_91eb37814936490c95da7b85993cc2ff/sociallinuxpizza/accounts/avatars/000/185/996/original/9e36da0c093cfc9b.png"
|
||||||
|
},
|
||||||
|
url: "https://chat.brainbaking.com/notice/A4nx1rFwKUJYSe4TqK#favorited-by-A4nwg4LYyh4WgrJOXg",
|
||||||
|
name: "",
|
||||||
|
type: "like",
|
||||||
|
source: body.source,
|
||||||
|
target: body.target,
|
||||||
|
// no dates in bridgy-to-mastodon likes...
|
||||||
|
published: "2020-01-01T01:00:00"
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
test("receive a brid.gy webmention that has a url and photo without value", async () => {
|
test("receive a brid.gy webmention that has a url and photo without value", async () => {
|
||||||
const body = {
|
const body = {
|
||||||
source: "https://brainbaking.com/valid-bridgy-source.html",
|
source: "https://brainbaking.com/valid-bridgy-source.html",
|
||||||
|
@ -44,12 +70,12 @@ describe("receive webmention process tests happy path", () => {
|
||||||
url: "https://social.linux.pizza/@StampedingLonghorn/105821099684887793",
|
url: "https://social.linux.pizza/@StampedingLonghorn/105821099684887793",
|
||||||
content: "@wouter The cat pictures are awesome. for jest tests!",
|
content: "@wouter The cat pictures are awesome. for jest tests!",
|
||||||
name: "@wouter The cat pictures are awesome. for jest tests!",
|
name: "@wouter The cat pictures are awesome. for jest tests!",
|
||||||
|
type: "mention",
|
||||||
source: body.source,
|
source: body.source,
|
||||||
target: body.target,
|
target: body.target,
|
||||||
published: "2021-03-02T16:17:18.000Z"
|
published: "2021-03-02T16:17:18.000Z"
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
test("receive saves a JSON file of indieweb-metadata if all is valid", async () => {
|
test("receive saves a JSON file of indieweb-metadata if all is valid", async () => {
|
||||||
const body = {
|
const body = {
|
||||||
source: "https://brainbaking.com/valid-indieweb-source.html",
|
source: "https://brainbaking.com/valid-indieweb-source.html",
|
||||||
|
@ -68,6 +94,7 @@ describe("receive webmention process tests happy path", () => {
|
||||||
url: "https://brainbaking.com/notes/2021/03/06h12m41s48/",
|
url: "https://brainbaking.com/notes/2021/03/06h12m41s48/",
|
||||||
content: "This is cool, I just found out about valid indieweb target - so cool",
|
content: "This is cool, I just found out about valid indieweb target - so cool",
|
||||||
name: "I just learned about https://www.inklestudios.com/...",
|
name: "I just learned about https://www.inklestudios.com/...",
|
||||||
|
type: "mention",
|
||||||
source: body.source,
|
source: body.source,
|
||||||
target: body.target,
|
target: body.target,
|
||||||
published: "2021-03-06T12:41:00"
|
published: "2021-03-06T12:41:00"
|
||||||
|
@ -92,6 +119,7 @@ describe("receive webmention process tests happy path", () => {
|
||||||
url: "https://brainbaking.com/notes/2021/03/06h12m41s48/",
|
url: "https://brainbaking.com/notes/2021/03/06h12m41s48/",
|
||||||
name: "I just learned about https://www.inklestudios.com/...",
|
name: "I just learned about https://www.inklestudios.com/...",
|
||||||
content: "This is cool, this is a summary!",
|
content: "This is cool, this is a summary!",
|
||||||
|
type: "mention",
|
||||||
source: body.source,
|
source: body.source,
|
||||||
target: body.target,
|
target: body.target,
|
||||||
published: "2021-03-06T12:41:00"
|
published: "2021-03-06T12:41:00"
|
||||||
|
@ -114,6 +142,7 @@ describe("receive webmention process tests happy path", () => {
|
||||||
},
|
},
|
||||||
content: "Diablo 2 Twenty Years Later: A Retrospective | Jefklaks Codex",
|
content: "Diablo 2 Twenty Years Later: A Retrospective | Jefklaks Codex",
|
||||||
name: "Diablo 2 Twenty Years Later: A Retrospective | Jefklaks Codex",
|
name: "Diablo 2 Twenty Years Later: A Retrospective | Jefklaks Codex",
|
||||||
|
type: "mention",
|
||||||
url: body.source,
|
url: body.source,
|
||||||
source: body.source,
|
source: body.source,
|
||||||
target: body.target,
|
target: body.target,
|
||||||
|
|
Loading…
Reference in New Issue