diff --git a/app/mf/microformats.go b/app/mf/microformats.go index 9198c69..4d22217 100644 --- a/app/mf/microformats.go +++ b/app/mf/microformats.go @@ -233,20 +233,25 @@ type MfType string const ( TypeLink MfType = "link" TypeReply MfType = "reply" + TypeRepost MfType = "repost" TypeLike MfType = "like" TypeBookmark MfType = "bookmark" TypeMention MfType = "mention" ) func Type(hEntry *microformats.Microformat) MfType { - likeOf := Str(hEntry, "like-of") - if likeOf != "" { + hType := Str(hEntry, "like-of") + if hType != "" { return TypeLike } - bookmarkOf := Str(hEntry, "bookmark-of") - if bookmarkOf != "" { + hType = Str(hEntry, "bookmark-of") + if hType != "" { return TypeBookmark } + hType = Str(hEntry, "repost-of") + if hType != "" { + return TypeRepost + } return TypeMention } diff --git a/app/webmention/recv/receive_test.go b/app/webmention/recv/receive_test.go index 375ff0e..c6c1263 100644 --- a/app/webmention/recv/receive_test.go +++ b/app/webmention/recv/receive_test.go @@ -145,7 +145,7 @@ func TestReceive(t *testing.T) { json: `{"author":{"name":"Jamie Tanna","picture":"/pictures/brainbaking.com"},"name":"","content":"Recommended read:\nThe IndieWeb Mixed Bag - Thoughts about the (d)evolution of blog interactions\nhttps://brainbaking.com/post/2021/03/the-indieweb-mixed-bag/","published":"2021-03-15T12:42:00+00:00","url":"https://brainbaking.com/mf2/2021/03/1bkre/","type":"bookmark","source":"https://brainbaking.com/valid-bridgy-twitter-source.html","target":"https://brainbaking.com/post/2021/03/the-indieweb-mixed-bag"}`, }, { - label: "receive a brid.gy Webmention like", + label: "receive a brid.gy (Mastodon) Webmention like", wm: mf.Mention{ Source: "https://brainbaking.com/valid-bridgy-like.html", // wrapped in a a class="u-like-of" tag @@ -155,7 +155,17 @@ func TestReceive(t *testing.T) { json: `{"author":{"name":"Stampeding Longhorn","picture":"/pictures/brainbaking.com"},"name":"","content":"","published":"2020-01-01T12:30:00+00:00","url":"https://chat.brainbaking.com/notice/A4nx1rFwKUJYSe4TqK#favorited-by-A4nwg4LYyh4WgrJOXg","type":"like","source":"https://brainbaking.com/valid-bridgy-like.html","target":"https://brainbaking.com/valid-indieweb-target.html"}`, }, { - label: "receive a brid.gy Webmention that has a url and photo without value", + label: "receive a brid.gy (Twitter) Webmention repost", + wm: mf.Mention{ + Source: "https://brainbaking.com/valid-bridgy-twitter-repost.html", + // wrapped in a a class="u-like-of" tag + Target: "https://brainbaking.com/valid-indieweb-target.html", + }, + // no dates in bridgy-to-mastodon likes... + json: `{"author":{"name":"cartocalypse.tif","picture":"/pictures/brainbaking.com"},"name":"My quest in creating a Google Maps clone\n\n chringel.dev/2022/06/creati…","content":"My quest in creating a Google Maps clone\n\n chringel.dev/2022/06/creati…","published":"2022-06-21T06:23:53+00:00","url":"https://twitter.com/cartocalypse/status/1539131976879308800","type":"repost","source":"https://brainbaking.com/valid-bridgy-twitter-repost.html","target":"https://brainbaking.com/valid-indieweb-target.html"}`, + }, + { + label: "receive a brid.gy (Mastodon) Webmention that has a url and photo without value", wm: mf.Mention{ Source: "https://brainbaking.com/valid-bridgy-source.html", Target: "https://brainbaking.com/valid-indieweb-target.html", @@ -201,6 +211,7 @@ func TestReceive(t *testing.T) { RestClient: &mocks.RestClientMock{ GetBodyFunc: mocks.RelPathGetBodyFunc("../../../mocks/"), }, + Notifier: ¬ifier.StringNotifier{}, } receiver.Receive(tc.wm) diff --git a/mocks/valid-bridgy-twitter-repost.html b/mocks/valid-bridgy-twitter-repost.html new file mode 100644 index 0000000..6d1c9c2 --- /dev/null +++ b/mocks/valid-bridgy-twitter-repost.html @@ -0,0 +1,60 @@ + + + + + + My quest in creating a Google Maps clone + + chringel.dev/2022/06/creati… + + +
+ tag:twitter.com,2013:1539131976879308800 + + + + + + + cartocalypse.tif + + + cartocalypse + + + + https://twitter.com/cartocalypse/status/1539131976879308800 +
+ +
My quest in creating a Google Maps clone + + chringel.dev/2022/06/creati…
+
+ + + + + + + + + +
+ + \ No newline at end of file