diff --git a/src/main/clj/org/domaindrivenarchitecture/activity_pub_poc/core.clj b/src/main/clj/org/domaindrivenarchitecture/activity_pub_poc/core.clj index 1d72648..0aea4ac 100644 --- a/src/main/clj/org/domaindrivenarchitecture/activity_pub_poc/core.clj +++ b/src/main/clj/org/domaindrivenarchitecture/activity_pub_poc/core.clj @@ -33,7 +33,7 @@ (re-matches #"https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)" input)) (defn uri-vector? [input] - (and (every? #(uri? %) input) + (and (every? #(uri-string? %) input) (vector? input))) (def context "@context") @@ -51,8 +51,8 @@ (s/def actor uri-string?) (s/def object uri-string?) -(s/def ::to uri-string?) -(s/def ::target string?) +(s/def ::to uri-vector?) +(s/def ::object string?) (s/def ::from uri-string?) (def like? (s/keys :req-un [context @@ -61,14 +61,13 @@ actor object])) -(def like-data? (s/keys :req-un [::to ::target ::from])) +(def like-data? (s/keys :req-un [::to ::object ::from])) (def activity-streams-context "https://www.w3.org/ns/activitystreams") (def like-data - {:to ["https://chatty.bla/ben/", "https://chatty.bla/gen/"] - :target "https://chatty.bla/ben/posts/234s23-2g34234-2hhj536" - :from "https://social.bla/alyssa/"}) + {:object "https://chatty.bla/ben/posts/234s23-2g34234-2hhj536" + :from "https://social.bla/alyssa"}) (defn generate-id-from-object [from] (str from "out" "/" "sdfsd44243g324g3455")) @@ -77,10 +76,10 @@ [input-map like-data?] (assoc {} "@context" activity-streams-context + "id" (str (:from input-map) "#likes/" "RANDOMHASH") "type" "Like" - "to" (:to input-map) "actor" (:from input-map) - "object" (:target input-map))) + "object" (:object input-map))) (defn-spec write-json-ld string? [input map? diff --git a/src/test/resources/like.json b/src/test/resources/like.json index cb91da3..5566c6b 100644 --- a/src/test/resources/like.json +++ b/src/test/resources/like.json @@ -1 +1 @@ -{"@context":"https://www.w3.org/ns/activitystreams","type":"Like","to":["https://chatty.bla/ben/","https://chatty.bla/gen/"],"actor":"https://social.bla/alyssa/","object":"https://chatty.bla/ben/posts/234s23-2g34234-2hhj536"} \ No newline at end of file +{"@context":"https://www.w3.org/ns/activitystreams","id":"https://social.bla/alyssa#likes/RANDOMHASH","type":"Like","to":["https://chatty.bla/ben","https://chatty.bla/gen"],"actor":"https://social.bla/alyssa","object":"https://chatty.bla/ben/posts/234s23-2g34234-2hhj536"} \ No newline at end of file