Skip to content

Commit a314dfb

Browse files
authored
Merge pull request #131 from modulr-software/feat/edit-incoming-posts
creator post pruning
2 parents 7d3c9e2 + 53abc70 commit a314dfb

File tree

2 files changed

+52
-1
lines changed

2 files changed

+52
-1
lines changed

src/source/routes/post.clj

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
(ns source.routes.post
2+
(:require [source.services.interface :as services]
3+
[ring.util.response :as res]))
4+
5+
(defn get
6+
{:summary "get post by id"
7+
:parameters {:path [:map [:post-id {:title "post-id"
8+
:description "post id"} :int]]}
9+
:responses {200 {:body [:map
10+
[:id :int]
11+
[:post-id :string]
12+
[:feed-id :int]
13+
[:creator-id :int]
14+
[:content-type-id :int]
15+
[:title :string]
16+
[:thumbnail [:maybe :string]]
17+
[:info [:maybe :string]]
18+
[:url [:maybe :string]]
19+
[:stream-url [:maybe :string]]
20+
[:season [:maybe :int]]
21+
[:episode [:maybe :int]]
22+
[:redacted {:optional true} [:maybe :int]]
23+
[:posted-at [:maybe :string]]]}}}
24+
25+
[{:keys [ds user path-params] :as _request}]
26+
(-> (services/incoming-post ds {:where [:and
27+
[:= :id (:post-id path-params)]
28+
[:= :creator-id (:id user)]]})
29+
(res/response)))
30+
31+
(defn post
32+
{:summary "Update redacted status of post with the given id"
33+
:parameters {:path [:map [:post-id {:title "post-id"
34+
:description "post id"} :int]]
35+
:body [:map
36+
[:redacted :boolean]]}
37+
:responses {200 {:body [:map [:message :string]]}
38+
401 {:body [:map [:message :string]]}
39+
403 {:body [:map [:message :string]]}}}
40+
41+
[{:keys [ds path-params user body] :as _request}]
42+
(services/update-incoming-post! ds {:where [:and
43+
[:= :id (:post-id path-params)]
44+
[:= :creator-id (:id user)]]
45+
:data {:redacted (if (:redacted body) 1 0)}})
46+
(res/response {:message "successfully updated post"}))

src/source/routes/reitit.clj

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
[source.routes.bundle-posts :as bundle-posts]
5454
[source.routes.bundle-post :as bundle-post]
5555
[source.routes.posts :as posts]
56+
[source.routes.post :as post]
5657
[source.routes.admin-feeds :as admin-feeds]
5758
[source.routes.xml :as xml]
5859
[source.routes.data :as data]
@@ -192,7 +193,11 @@
192193
["/:id"
193194
["" (route {:get feed/get
194195
:post feed/post})]
195-
["/posts" (route {:get posts/get})]
196+
["/posts"
197+
["" (route {:get posts/get})]
198+
["/:post-id"
199+
["" (route {:get post/get})]
200+
["/prune" (route {:post post/post})]]]
196201
["/categories" (route {:get feed-categories/get
197202
:post feed-categories/post})]]]
198203

0 commit comments

Comments
 (0)