From 3e308fe15b2c3e810903033eb27f124d277eb0d7 Mon Sep 17 00:00:00 2001 From: Isaac Visintainer Date: Fri, 7 Feb 2020 11:07:30 -0800 Subject: [PATCH 1/4] handle inviting/kicking when ship is added/removed from group --- pkg/arvo/app/publish.hoon | 92 +++++++++++++++++++++++++++++++-------- 1 file changed, 75 insertions(+), 17 deletions(-) diff --git a/pkg/arvo/app/publish.hoon b/pkg/arvo/app/publish.hoon index 93f3df0b3..600113f8c 100644 --- a/pkg/arvo/app/publish.hoon +++ b/pkg/arvo/app/publish.hoon @@ -285,10 +285,41 @@ ^- (quip card _this) ?- -.sin %poke-ack (on-agent:def wir sin) + :: If our subscribe failed, delete notebook associated with subscription if + :: it exists :: - %watch-ack (on-agent:def wir sin) + %watch-ack + ?. ?=([%subscribe @ @ ~] wir) + (on-agent:def wir sin) + ?~ p.sin + [~ this] + =/ who=@p (slav %p i.t.wir) + =/ book=@tas i.t.t.wir + [~ this(subs (~(del by subs) who book))] + :: Resubscribe to any subscription we get kicked from. The case of actually + :: getting banned from a notebook is handled by %watch-ack :: - %kick (on-agent:def wir sin) + %kick + ?+ wir + [~ this] + :: + [%subscribe @ @ ~] + =/ who=@p (slav %p i.t.wir) + =/ book=@tas i.t.t.wir + :_ this + [%pass wir %agent [who %publish] %watch /notebook/[book]]~ + :: + [%permissions ~] + :_ this + [%pass /permissions %agent [our.bol %permission-store] %watch /updates]~ + :: + [%invites ~] + :_ this + :_ ~ + :* %pass /invites %agent [our.bol %invite-store] %watch + /invitatory/publish + == + == :: %fact ?+ wir (on-agent:def wir sin) @@ -672,22 +703,49 @@ ++ handle-permission-update |= upd=permission-update ^- (quip card _state) - ?. ?=(%remove -.upd) + ?+ -.upd [~ state] - =/ book=@tas - %- need - %+ roll ~(tap by books) - |= [[nom=@tas book=notebook] out=(unit @tas)] - ?: =(path.upd subscribers.book) - `nom - out - :_ state - %- zing - %+ turn ~(tap in who.upd) - |= who=@p - ?: (allowed who %read book) - ~ - [%give %kick [/notebook/[book]]~ `who]~ + :: + %remove + =/ book=(unit @tas) + %+ roll ~(tap by books) + |= [[nom=@tas book=notebook] out=(unit @tas)] + ?: =(path.upd subscribers.book) + `nom + out + ?~ book + [~ state] + :_ state + %- zing + %+ turn ~(tap in who.upd) + |= who=@p + ?: (allowed who %read u.book) + ~ + [%give %kick [/notebook/[u.book]]~ `who]~ + :: + %add + =/ book=(unit @tas) + %+ roll ~(tap by books) + |= [[nom=@tas book=notebook] out=(unit @tas)] + ?: =(path.upd subscribers.book) + `nom + out + ?~ book + [~ state] + :_ state + %- zing + %+ turn ~(tap in who.upd) + |= who=@p + ?. (allowed who %read u.book) + ~ + =/ uid (sham %publish who u.book eny.bol) + =/ inv=invite + :* our.bol %publish /notebook/[u.book] who + (crip "invite for notebook {}/{(trip u.book)}") + == + =/ act=invite-action [%invite /publish uid inv] + [%pass / %agent [our.bol %invite-hook] %poke %invite-action !>(act)]~ + == :: ++ handle-invite-update |= upd=invite-update From 7a64615cf7783dbe4d1a8ec38c1ad533433d3112 Mon Sep 17 00:00:00 2001 From: Isaac Visintainer Date: Fri, 7 Feb 2020 11:37:02 -0800 Subject: [PATCH 2/4] added new post button for all members of the notebook writers group --- .../publish/src/js/components/lib/notebook.js | 15 ++++++++++----- pkg/interface/publish/src/js/components/root.js | 1 + 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/pkg/interface/publish/src/js/components/lib/notebook.js b/pkg/interface/publish/src/js/components/lib/notebook.js index dbc2e2050..5fa1fcde5 100644 --- a/pkg/interface/publish/src/js/components/lib/notebook.js +++ b/pkg/interface/publish/src/js/components/lib/notebook.js @@ -59,6 +59,7 @@ export class Notebook extends Component { render() { let notebook = this.props.notebooks[this.props.ship][this.props.book]; + let tabStyles = { posts: "bb b--gray4 gray2 pv4 ph2", about: "bb b--gray4 gray2 pv4 ph2" @@ -96,15 +97,19 @@ export class Notebook extends Component { let settings = base + '/settings'; let newUrl = base + '/new'; - let newPost = !(window.ship === this.props.ship.slice(1)) - // XX TODO check based on authorized writers instead - ? null - : + let newPost = null; + if (notebook["writers-group-path"] in this.props.groups){ + let writers = notebook["writers-group-path"]; + if (this.props.groups[writers].has(window.ship)) { + newPost = + New Post + } + } let unsub = (window.ship === this.props.ship.slice(1)) - ? null + ? null :