From 0a976574431f2bca4e16de7042e0f4b5b50cea1e Mon Sep 17 00:00:00 2001 From: Michael Jerger Date: Mon, 16 Oct 2023 18:42:43 +0200 Subject: [PATCH] enhance like & dislike for repo star semantic --- .../fed_poc/activitystreams2.cljc | 2 -- .../fed_poc/forgefed.cljc | 16 ++++++++++++++ .../fed_poc/activitystreams2_test.cljc | 2 +- .../fed_poc/forgefed_test.cljc | 22 ++++++++++++++++++- 4 files changed, 38 insertions(+), 4 deletions(-) diff --git a/src/main/cljc/org/domaindrivenarchitecture/fed_poc/activitystreams2.cljc b/src/main/cljc/org/domaindrivenarchitecture/fed_poc/activitystreams2.cljc index 22d24e8..5785c36 100644 --- a/src/main/cljc/org/domaindrivenarchitecture/fed_poc/activitystreams2.cljc +++ b/src/main/cljc/org/domaindrivenarchitecture/fed_poc/activitystreams2.cljc @@ -5,8 +5,6 @@ [org.domaindrivenarchitecture.fed-poc.owl :as owl] [org.domaindrivenarchitecture.fed-poc.xsd :as xsd])) - - ;======================= ;http://www.w3.org/ns/activitystreams#Object diff --git a/src/main/cljc/org/domaindrivenarchitecture/fed_poc/forgefed.cljc b/src/main/cljc/org/domaindrivenarchitecture/fed_poc/forgefed.cljc index 2ad10a2..efc271c 100644 --- a/src/main/cljc/org/domaindrivenarchitecture/fed_poc/forgefed.cljc +++ b/src/main/cljc/org/domaindrivenarchitecture/fed_poc/forgefed.cljc @@ -3,6 +3,7 @@ [orchestra.core :refer [defn-spec]] [org.domaindrivenarchitecture.fed-poc.spec-helper :as sh] [org.domaindrivenarchitecture.fed-poc.owl :as owl] + [org.domaindrivenarchitecture.fed-poc.activitystreams2 :as as] [org.domaindrivenarchitecture.fed-poc.xsd :as xsd] [org.domaindrivenarchitecture.fed-poc.activitystreams2 :as as])) @@ -12,3 +13,18 @@ (s/and ::as/Object (sh/map-spec (s/keys :opt [])))) + +;https://forgefed.org/ns#Star +(s/def ::Star + (s/merge + ::as/Activity + (sh/map-spec (s/keys :opt [::flavour])))) + +;https://forgefed.org/ns#Unstar +(s/def ::Unstar + (s/merge + ::as/Activity + (sh/map-spec (s/keys :opt [::flavour])))) + +(s/def ::flavour + (sh/seq-spec ::xsd/anyURI)) \ No newline at end of file diff --git a/src/test/cljc/org/domaindrivenarchitecture/fed_poc/activitystreams2_test.cljc b/src/test/cljc/org/domaindrivenarchitecture/fed_poc/activitystreams2_test.cljc index 175fa7f..ef6bcb3 100644 --- a/src/test/cljc/org/domaindrivenarchitecture/fed_poc/activitystreams2_test.cljc +++ b/src/test/cljc/org/domaindrivenarchitecture/fed_poc/activitystreams2_test.cljc @@ -107,7 +107,7 @@ ::sut/type "Like", ::sut/actor "https://social.bla/alyssa", ::sut/object "http://example.org/notes/1"}))) - (testing "likes for forgejo repositories - using public uris for id refernce" + (testing "likes for forgejo repositories" (testing "using public uris for id refernce" (is (s/valid? ::sut/Like {::sut/id "https://repo.prod.meissa.de/jem/like/12345", diff --git a/src/test/cljc/org/domaindrivenarchitecture/fed_poc/forgefed_test.cljc b/src/test/cljc/org/domaindrivenarchitecture/fed_poc/forgefed_test.cljc index cd33ce6..bf34b18 100644 --- a/src/test/cljc/org/domaindrivenarchitecture/fed_poc/forgefed_test.cljc +++ b/src/test/cljc/org/domaindrivenarchitecture/fed_poc/forgefed_test.cljc @@ -18,4 +18,24 @@ ::sut/followers "https://dev.example/aviva/treesim/followers", ::sut/team "https://dev.example/aviva/treesim/team", ::sut/name "Tree Growth 3D Simulation", - ::sut/summary "

Tree growth 3D simulator for my nature exploration game

"}))) \ No newline at end of file + ::sut/summary "

Tree growth 3D simulator for my nature exploration game

"}))) + +(deftest Star-test + (testing "stars for forgejo repositories" + (testing "using activitypub api uris for id refernce" + (is (s/valid? ::sut/Star + {::as/id "https://repo.prod.meissa.de/api/activitypub/user-id/1/outbox/12345", + ::as/type "Star", + ::sut/flavour "forgejo", + ::as/actor "https://repo.prod.meissa.de/api/activitypub/user-id/1", + ::as/object "https://codeberg.org/api/repos/forgejo/forgejo"}))))) + +(deftest Unstar-test + (testing "stars for forgejo repositories" + (testing "using activitypub api uris for id refernce" + (is (s/valid? ::sut/Unstar + {::as/id "https://repo.prod.meissa.de/api/activitypub/user-id/1/outbox/12345", + ::as/type "Unstar", + ::sut/flavour "forgejo", + ::as/actor "https://repo.prod.meissa.de/api/activitypub/user-id/1", + ::as/object "https://codeberg.org/api/repos/forgejo/forgejo"}))))) \ No newline at end of file