From 9b260e081d32436827c0ca5513b209fa1a05533e Mon Sep 17 00:00:00 2001 From: Isaac Visintainer Date: Tue, 4 Feb 2020 11:14:06 -0800 Subject: [PATCH 1/2] change publish api to pass though group paths from frontend --- pkg/arvo/app/publish.hoon | 82 ++++++++++++++++++-------------- pkg/arvo/mar/publish/action.hoon | 9 +++- pkg/arvo/sur/publish.hoon | 8 +++- 3 files changed, 60 insertions(+), 39 deletions(-) diff --git a/pkg/arvo/app/publish.hoon b/pkg/arvo/app/publish.hoon index e60342d663..d91145afe1 100644 --- a/pkg/arvo/app/publish.hoon +++ b/pkg/arvo/app/publish.hoon @@ -191,11 +191,12 @@ [%web %publish @ %publish-info ~] =/ book-name i.t.t.pax =/ old=old-info .^(old-info %cx (welp our-beak:main pax)) - =/ book=notebook-info [title.old '' =(%open comments.old) / /] - =+ ^- [grp-car=(list card) writers-path=path subscribers-path=path] - (make-groups book-name [%new ~ ~ %journal]) - =. writers.book writers-path - =. subscribers.book subscribers-path + =/ write-pax /~/publish/(scot %p our.bol)/[book-name]/write + =/ read-pax /~/publish/(scot %p our.bol)/[book-name]/read + =/ book=notebook-info + [title.old '' =(%open comments.old) write-pax read-pax] + =/ grp-car=(list card) + (make-groups ~ writers.book ~ subscribers.book %journal) =/ inv-car (send-invites book-name (~(get ju old-subs) book-name)) :- :(weld car grp-car inv-car) ^- soba:clay @@ -521,10 +522,12 @@ now.bol ~ ~ ~ == - =+ ^- [grp-car=(list card) writers-path=path subscribers-path=path] - (make-groups book-name [%new ~ ~ %journal]) - =. writers.new-book writers-path - =. subscribers.new-book subscribers-path + =? writers.new-book =(writers.new-book /) + /~/publish/(scot %p our.bol)/[book-name]/write + =? subscribers.new-book =(writers.new-book /) + /~/publish/(scot %p our.bol)/[book-name]/read + =/ grp-car=(list card) + (make-groups ~ writers.new-book ~ subscribers.new-book %journal) =+ ^- [read-cards=(list card) notes=(map @tas note)] (watch-notes /app/publish/notebooks/[book-name]) =. notes.new-book notes @@ -851,25 +854,20 @@ == :: ++ make-groups - |= [book-name=@tas group=group-info] - ^- [(list card) path path] - ?- -.group - %old [~ writers.group subscribers.group] - %new - =/ writers-path /~/publish/[book-name]/writers - =/ subscribers-path /~/publish/[book-name]/subscribers - ^- [(list card) path path] - :_ [writers-path subscribers-path] - ;: weld - :~ (group-poke [%bundle writers-path]) - (group-poke [%bundle subscribers-path]) - (group-poke [%add writers.group writers-path]) - (group-poke [%add subscribers.group subscribers-path]) - == - (create-security subscribers-path writers-path sec.group) - :~ (perm-hook-poke [%add-owned writers-path writers-path]) - (perm-hook-poke [%add-owned subscribers-path subscribers-path]) + |= $: write-grp=(set ship) write-pax=path + read-grp=(set ship) read-pax=path + sec=rw-security == + ^- (list card) + ;: weld + :~ (group-poke [%bundle write-pax]) + (group-poke [%bundle read-pax]) + (group-poke [%add write-grp write-pax]) + (group-poke [%add read-grp read-pax]) + == + (create-security read-pax write-pax sec) + :~ (perm-hook-poke [%add-owned write-pax write-pax]) + (perm-hook-poke [%add-owned read-pax read-pax]) == == :: @@ -882,14 +880,21 @@ ~|("action not permitted" !!) ?: (~(has by books) book.act) ~|("notebook already exists: {}" !!) - =+ ^- [cards=(list card) writers-path=path subscribers-path=path] - (make-groups book.act group.act) + =+ ^- [cards=(list card) write-pax=path read-pax=path] + ?. ?=(%new -.group.act) + [~ write-pax.group.act read-pax.group.act] + :_ [write-pax.group.act read-pax.group.act] + %- make-groups + :* write-grp.group.act write-pax.group.act + read-grp.group.act read-pax.group.act + sec.group.act + == =/ new-book=notebook-info :* title.act about.act coms.act - writers-path - subscribers-path + write-pax + read-pax == =/ pax=path /app/publish/notebooks/[book.act]/publish-info :_ state @@ -951,16 +956,23 @@ =/ book (~(get by books) book.act) ?~ book ~|("nonexistent notebook" !!) - =+ ^- [cards=(list card) writers-path=path subscribers-path=path] + =+ ^- [cards=(list card) write-pax=path read-pax=path] ?~ group.act [~ writers.u.book subscribers.u.book] - (make-groups book.act u.group.act) + ?. ?=(%new -.u.group.act) + [~ write-pax.u.group.act read-pax.u.group.act] + :_ [write-pax.u.group.act read-pax.u.group.act] + %- make-groups + :* write-grp.u.group.act write-pax.u.group.act + read-grp.u.group.act read-pax.u.group.act + sec.u.group.act + == =/ new-info=notebook-info :* title.act about.act coms.act - writers-path - subscribers-path + write-pax + read-pax == =/ pax=path /app/publish/notebooks/[book.act]/publish-info :_ state diff --git a/pkg/arvo/mar/publish/action.hoon b/pkg/arvo/mar/publish/action.hoon index c23d8e8b80..f585845e8d 100644 --- a/pkg/arvo/mar/publish/action.hoon +++ b/pkg/arvo/mar/publish/action.hoon @@ -116,8 +116,13 @@ == ++ group-info %- of - :~ old+(ot writers+pa subscribers+pa ~) - new+(ot writers+set-ship subscribers+set-ship sec+so ~) + :~ old+(ot write-pax+pa read-pax+pa ~) + :- %new + %- ot + :~ write-grp+set-ship write-pax+pa + read-grp+set-ship read-pax+pa + sec+so + == == ++ set-ship (ar (su fed:ag)) -- diff --git a/pkg/arvo/sur/publish.hoon b/pkg/arvo/sur/publish.hoon index a3c2847f1a..16558c9d12 100644 --- a/pkg/arvo/sur/publish.hoon +++ b/pkg/arvo/sur/publish.hoon @@ -2,8 +2,12 @@ |% :: +$ group-info - $% [%old writers=path subscribers=path] - [%new writers=(set ship) subscribers=(set ship) sec=rw-security] + $% [%old write-pax=path read-pax=path] + $: %new + write-grp=(set ship) write-pax=path + read-grp=(set ship) read-pax=path + sec=rw-security + == == :: :: From 63bea15f58969940e43e5832a9313b3c774fb9af Mon Sep 17 00:00:00 2001 From: Isaac Visintainer Date: Tue, 4 Feb 2020 12:59:49 -0800 Subject: [PATCH 2/2] fixed wrong name for ship --- pkg/interface/publish/src/js/components/lib/new-post.js | 4 ++-- pkg/interface/publish/src/js/components/root.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/interface/publish/src/js/components/lib/new-post.js b/pkg/interface/publish/src/js/components/lib/new-post.js index 5ac5fe6bf9..22d4275bda 100644 --- a/pkg/interface/publish/src/js/components/lib/new-post.js +++ b/pkg/interface/publish/src/js/components/lib/new-post.js @@ -22,7 +22,7 @@ export class NewPost extends Component { postSubmit() { let newNote = { "new-note": { - who: this.props.host.slice(1), + who: this.props.ship.slice(1), book: this.props.book, note: stringToSymbol(this.state.title), title: this.state.title, @@ -45,7 +45,7 @@ export class NewPost extends Component { let notebook = this.props.notebooks[this.props.ship][this.props.book]; if (notebook.notes[this.state.awaiting]) { let redirect = - `/~publish/note/${this.props.host}/${this.props.book}/${this.state.awaiting}`; + `/~publish/note/${this.props.ship}/${this.props.book}/${this.state.awaiting}`; this.props.history.push(redirect); } } diff --git a/pkg/interface/publish/src/js/components/root.js b/pkg/interface/publish/src/js/components/root.js index 9fd2c9f426..0cfca1084c 100644 --- a/pkg/interface/publish/src/js/components/root.js +++ b/pkg/interface/publish/src/js/components/root.js @@ -88,7 +88,7 @@ export class Root extends Component { notebooks={state.notebooks}>