Browse Source

fix(webmention): Allow any page on the site.

jackyalcine 8 months ago
parent
commit
ee2404d2a1
Signed by: Jacky Alciné <yo@jacky.wtf> GPG Key ID: 537A4F904B15268D
1 changed files with 8 additions and 1 deletions
  1. 8
    1
      lib/webmention.ex

+ 8
- 1
lib/webmention.ex View File

@@ -39,7 +39,7 @@ defmodule Koype.Webmention do
39 39
     @impl true
40 40
     def from_source_url(target_url) do
41 41
       Enum.reduce_while(
42
-        [&do_resolve_homepage_for_target/1, &do_resolve_model_for_target/1],
42
+        [&do_resolve_homepage_for_target/1, &do_resolve_model_for_target/1, &do_resolve_if_on_site/1],
43 43
         nil,
44 44
         fn approach, acc ->
45 45
           case approach.(target_url) do
@@ -50,6 +50,13 @@ defmodule Koype.Webmention do
50 50
       )
51 51
     end
52 52
 
53
+    defp do_resolve_if_on_site(target_url) when is_binary(target_url) do
54
+      current_host = URI.parse(Koype.host()).host
55
+      target_host = URI.parse(target_url).host
56
+
57
+      target_host == current_host
58
+    end
59
+
53 60
     defp do_resolve_homepage_for_target(target_url) when is_binary(target_url) do
54 61
       current_host = Koype.host()
55 62
 

Loading…
Cancel
Save