track invites, contributors, subscribers on backend; make comments plaintext

This commit is contained in:
Isaac Visintainer 2019-06-19 16:06:43 -07:00
parent 2210236262
commit 8a0447b135
6 changed files with 144 additions and 47 deletions

View File

@ -61,6 +61,17 @@
:: +our-beak: beak for this app, with case set to current invocation date :: +our-beak: beak for this app, with case set to current invocation date
:: ::
++ our-beak /(scot %p our.bol)/[q.byk.bol]/(scot %da now.bol) ++ our-beak /(scot %p our.bol)/[q.byk.bol]/(scot %da now.bol)
::
::
++ allowed
|= [who=@p mod=?(%read %write) pax=path]
^- ?
=. pax (weld our-beak pax)
=/ pem=[dict:clay dict:clay] .^([dict:clay dict:clay] %cp pax)
?- mod
%read (allowed-by who -.pem)
%write (allowed-by who +.pem)
==
:: +allowed-by: checks if ship :who is allowed by the permission rules in :dic :: +allowed-by: checks if ship :who is allowed by the permission rules in :dic
:: ::
++ allowed-by ++ allowed-by
@ -229,8 +240,8 @@
(~(get by subs.sat) who.del col.del) (~(get by subs.sat) who.del col.del)
=/ new=collection =/ new=collection
?~ old ?~ old
[dat.del ~ ~ ~ ~] [dat.del ~ ~ [~ ~] ~ ~]
[dat.del pos.u.old com.u.old order.u.old] u.old(col dat.del)
=? pubs.sat =(our.bol who.del) =? pubs.sat =(our.bol who.del)
(~(put by pubs.sat) col.del new) (~(put by pubs.sat) col.del new)
=? subs.sat !=(our.bol who.del) =? subs.sat !=(our.bol who.del)
@ -244,8 +255,8 @@
(~(get by subs.sat) who.del col.del) (~(get by subs.sat) who.del col.del)
=/ new=collection =/ new=collection
?~ old ?~ old
[[%.n ~] (my [pos.del dat.del] ~) ~ ~ ~] [[%.n ~] (my [pos.del dat.del] ~) ~ [~ ~] ~ ~]
[col.u.old (~(put by pos.u.old) pos.del dat.del) com.u.old order.u.old] u.old(pos (~(put by pos.u.old) pos.del dat.del))
=? pubs.sat =(our.bol who.del) =? pubs.sat =(our.bol who.del)
(~(put by pubs.sat) col.del new) (~(put by pubs.sat) col.del new)
=? subs.sat !=(our.bol who.del) =? subs.sat !=(our.bol who.del)
@ -261,8 +272,8 @@
(~(get by subs.sat) who.del col.del) (~(get by subs.sat) who.del col.del)
=/ new=collection =/ new=collection
?~ old ?~ old
[[%.n ~] ~ (my [pos.del dat.del] ~) ~ ~] [[%.n ~] ~ (my [pos.del dat.del] ~) [~ ~] ~ ~]
[col.u.old pos.u.old (~(put by com.u.old) pos.del dat.del) order.u.old] u.old(com (~(put by com.u.old) pos.del dat.del))
=? pubs.sat =(our.bol who.del) =? pubs.sat =(our.bol who.del)
(~(put by pubs.sat) col.del new) (~(put by pubs.sat) col.del new)
=? subs.sat !=(our.bol who.del) =? subs.sat !=(our.bol who.del)
@ -285,6 +296,9 @@
posts t.posts posts t.posts
== ==
(da-emil (affection del)) (da-emil (affection del))
::
%remove
da-this
:: ::
== ==
:: ::
@ -454,7 +468,7 @@
(bake [%collection our.bol col dat]) (bake [%collection our.bol col dat])
:: 1st part of multi-part, store partial delta and don't process it :: 1st part of multi-part, store partial delta and don't process it
:: ::
=/ del=delta [%total our.bol col dat ~ ~ ~ ~] =/ del=delta [%total our.bol col dat ~ ~ [~ ~] ~ ~]
=. awaiting.sat (~(put by awaiting.sat) col builds.u.awa `del) =. awaiting.sat (~(put by awaiting.sat) col builds.u.awa `del)
[~ this] [~ this]
:: ::
@ -470,6 +484,8 @@
pos.dat.u.partial.u.awa pos.dat.u.partial.u.awa
com.dat.u.partial.u.awa com.dat.u.partial.u.awa
[~ ~] [~ ~]
~
~
== ==
=. awaiting.sat (~(del by awaiting.sat) col) =. awaiting.sat (~(del by awaiting.sat) col)
(bake del) (bake del)
@ -484,6 +500,8 @@
pos.dat.u.partial.u.awa pos.dat.u.partial.u.awa
com.dat.u.partial.u.awa com.dat.u.partial.u.awa
[~ ~] [~ ~]
~
~
== ==
=. awaiting.sat (~(put by awaiting.sat) col builds.u.awa `del) =. awaiting.sat (~(put by awaiting.sat) col builds.u.awa `del)
[~ this] [~ this]
@ -513,7 +531,8 @@
(bake [%post our.bol col pos dat]) (bake [%post our.bol col pos dat])
:: 1st part of multi-part, store partial delta and don't process it :: 1st part of multi-part, store partial delta and don't process it
:: ::
=/ del=delta [%total our.bol col [%.n ~] (my [pos dat] ~) ~ ~ ~] =/ del=delta
[%total our.bol col [%.n ~] (my [pos dat] ~) ~ [~ ~] ~ ~]
=. awaiting.sat (~(put by awaiting.sat) col builds.u.awa `del) =. awaiting.sat (~(put by awaiting.sat) col builds.u.awa `del)
[~ this] [~ this]
:: ::
@ -529,6 +548,8 @@
(~(put by pos.dat.u.partial.u.awa) pos dat) (~(put by pos.dat.u.partial.u.awa) pos dat)
com.dat.u.partial.u.awa com.dat.u.partial.u.awa
[~ ~] [~ ~]
~
~
== ==
=. awaiting.sat (~(del by awaiting.sat) col) =. awaiting.sat (~(del by awaiting.sat) col)
(bake del) (bake del)
@ -543,6 +564,8 @@
(~(put by pos.dat.u.partial.u.awa) pos dat) (~(put by pos.dat.u.partial.u.awa) pos dat)
com.dat.u.partial.u.awa com.dat.u.partial.u.awa
[~ ~] [~ ~]
~
~
== ==
=. awaiting.sat (~(put by awaiting.sat) col builds.u.awa `del) =. awaiting.sat (~(put by awaiting.sat) col builds.u.awa `del)
[~ this] [~ this]
@ -552,14 +575,14 @@
=/ pos=@tas i.t.t.wir =/ pos=@tas i.t.t.wir
=/ awa (~(get by awaiting.sat) col) =/ awa (~(get by awaiting.sat) col)
:: ::
=/ dat=(each (list [comment-info manx]) tang) =/ dat=(each (list [comment-info @t]) tang)
?: ?=([%incomplete *] mad) ?: ?=([%incomplete *] mad)
[%.n tang.mad] [%.n tang.mad]
?: ?=([%error *] build-result.mad) ?: ?=([%error *] build-result.mad)
[%.n message.build-result.mad] [%.n message.build-result.mad]
?> ?=(%bake +<.build-result.mad) ?> ?=(%bake +<.build-result.mad)
?> ?=(%write-comments p.cage.build-result.mad) ?> ?=(%write-comments p.cage.build-result.mad)
[%.y (,(list [comment-info manx]) q.q.cage.build-result.mad)] [%.y (,(list [comment-info @t]) q.q.cage.build-result.mad)]
:: ::
?~ awa ?~ awa
(bake [%comments our.bol col pos dat]) (bake [%comments our.bol col pos dat])
@ -572,7 +595,8 @@
(bake [%comments our.bol col pos dat]) (bake [%comments our.bol col pos dat])
:: 1st part of multi-part, store partial delta and don't process it :: 1st part of multi-part, store partial delta and don't process it
:: ::
=/ del=delta [%total our.bol col [%.n ~] ~ (my [pos dat] ~) ~ ~] =/ del=delta
[%total our.bol col [%.n ~] ~ (my [pos dat] ~) [~ ~] ~ ~]
=. awaiting.sat (~(put by awaiting.sat) col builds.u.awa `del) =. awaiting.sat (~(put by awaiting.sat) col builds.u.awa `del)
[~ this] [~ this]
:: ::
@ -588,6 +612,8 @@
pos.dat.u.partial.u.awa pos.dat.u.partial.u.awa
(~(put by com.dat.u.partial.u.awa) pos dat) (~(put by com.dat.u.partial.u.awa) pos dat)
[~ ~] [~ ~]
~
~
== ==
=. awaiting.sat (~(del by awaiting.sat) col) =. awaiting.sat (~(del by awaiting.sat) col)
(bake del) (bake del)
@ -602,6 +628,8 @@
pos.dat.u.partial.u.awa pos.dat.u.partial.u.awa
(~(put by com.dat.u.partial.u.awa) pos dat) (~(put by com.dat.u.partial.u.awa) pos dat)
[~ ~] [~ ~]
~
~
== ==
=. awaiting.sat (~(put by awaiting.sat) col builds.u.awa `del) =. awaiting.sat (~(put by awaiting.sat) col builds.u.awa `del)
[~ this] [~ this]
@ -708,7 +736,13 @@
:_ this :_ this
[(write-file pax %udon !>(out))]~ [(write-file pax %udon !>(out))]~
:: ::
%delete %delete-collection
[~ this]
::
%delete-post
[~ this]
::
%delete-comment
[~ this] [~ this]
:: ::
%edit-collection %edit-collection
@ -744,11 +778,26 @@
:_ this :_ this
[(write-file pax %udon !>(out))]~ [(write-file pax %udon !>(out))]~
:: ::
%edit-comment :: %invite: if the action is from us it means send invites to other people
[~ this] :: if its from someone else it means we've been invited
:: ::
%invite %invite
[~ this] ?: =(our.bol src.bol)
=/ new-act=action [%invite coll.act title.act ~]
:_ this
%+ turn who.act
|= who=@p
^- move
[ost.bol %poke /forward [who %write] %write-action new-act]
:- ~
this(invites.sat (~(put by invites.sat) [src.bol coll.act] title.act))
::
:: %reject-invite: remove invite from list, acceptance is handled by
:: %subscribe action
::
%reject-invite
:- ~
this(invites.sat (~(del by invites.sat) [who.act coll.act]))
:: ::
:: %serve: :: %serve:
:: ::
@ -852,15 +901,15 @@
unread.sat new-unread unread.sat new-unread
== ==
:: ::
:: %subscribe: :: %subscribe: sub to a foreign blog; remove invites for that blog
:: ::
%subscribe %subscribe
~& write-action+act ~& write-action+act
=/ wir=wire /collection/[coll.act] =/ wir=wire /collection/[coll.act]
:_ this :_ this(invites.sat (~(del by invites.sat) [who.act coll.act]))
[ost.bol %peer wir [who.act %write] wir]~ [ost.bol %peer wir [who.act %write] wir]~
:: ::
:: %unsubscribe: :: %unsubscribe: unsub from a foreign blog, delete all state related to it
:: ::
%unsubscribe %unsubscribe
=/ new-latest=(list [@p @tas @tas]) =/ new-latest=(list [@p @tas @tas])

View File

@ -108,16 +108,16 @@
(tang-to-json +.bud) (tang-to-json +.bud)
:: ::
++ comment-build-to-json ++ comment-build-to-json
|= bud=(each (list [comment-info manx]) tang) |= bud=(each (list [comment-info @t]) tang)
^- json ^- json
?: ?=(%.y -.bud) ?: ?=(%.y -.bud)
:- %a :- %a
%+ turn p.bud %+ turn p.bud
|= [com=comment-info man=manx] |= [com=comment-info bod=@t]
^- json ^- json
%- pairs:enjs:format %- pairs:enjs:format
:~ info+(comment-info-to-json com) :~ info+(comment-info-to-json com)
body+(elem-to-react-json man) body+s+bod
== ==
(tang-to-json +.bud) (tang-to-json +.bud)
:: ::
@ -146,7 +146,19 @@
:~ pin+a+(turn pin.order.col |=(s=@tas [%s s])) :~ pin+a+(turn pin.order.col |=(s=@tas [%s s]))
unpin+a+(turn unpin.order.col |=(s=@tas [%s s])) unpin+a+(turn unpin.order.col |=(s=@tas [%s s]))
== ==
::
:+ %contributors
%a
%+ turn ~(tap in contributors.col)
|= who=@p
(ship:enjs:format who)
::
:+ %subscribers
%a
%+ turn ~(tap in subscribers.col)
|= who=@p
^- json
(ship:enjs:format who)
== ==
:: ::
++ state-to-json ++ state-to-json
@ -199,6 +211,16 @@
coll+s+coll coll+s+coll
post+s+post post+s+post
== ==
::
:+ %invites
%a
%+ turn ~(tap in invites.sat)
|= [[who=@p coll=@tas] title=@t]
%- pairs:enjs:format
:~ who+(ship:enjs:format who)
coll+s+coll
title+s+title
==
== ==
:: ::
-- --

View File

@ -26,13 +26,15 @@
new-post+new-post new-post+new-post
new-comment+new-comment new-comment+new-comment
:: ::
delete+item-id delete-collection+delete-collection
delete-post+delete-post
delete-comment+delete-comment
:: ::
edit-collection+edit-collection edit-collection+edit-collection
edit-post+edit-post edit-post+edit-post
edit-comment+edit-comment
:: ::
invite+invite invite+invite
reject-invite+reject-invite
:: ::
serve+serve serve+serve
unserve+unserve unserve+unserve
@ -70,6 +72,21 @@
content+so:dejs content+so:dejs
== ==
:: ::
++ delete-collection (of:dejs coll+(su:dejs sym) ~)
::
++ delete-post
%- ot:dejs
coll+(su:dejs sym)
post+(su:dejs sym)
==
::
++ delete-comment
%- ot:dejs
coll+(su:dejs sym)
post+(su:dejs sym)
comment+(su:dejs sym)
==
::
++ edit-collection ++ edit-collection
%- ot:dejs %- ot:dejs
:~ name+(su:dejs sym) :~ name+(su:dejs sym)
@ -151,6 +168,12 @@
who+(ar:dejs (su:dejs fed:ag)) who+(ar:dejs (su:dejs fed:ag))
== ==
:: ::
++ reject-invite
%- ot:dejs
:~ coll+(su:dejs sym)
who+(su:dejs fed:ag)
==
::
++ serve ++ serve
%- ot:dejs %- ot:dejs
:~ coll+(su:dejs sym) :~ coll+(su:dejs sym)

View File

@ -41,6 +41,13 @@
[%who (ship who.rum)] [%who (ship who.rum)]
[%data (total-build-to-json dat.rum)] [%data (total-build-to-json dat.rum)]
== ==
::
%remove
=/ suf=(list [@tas json])
%- pairs
:~ [%coll s+col.rum]
[%post ?~(pos.rum ~ s+u.pos.rum)]
==
== ==
:: ::
-- --

View File

@ -2,23 +2,24 @@
/+ write, cram, elem-to-react-json /+ write, cram, elem-to-react-json
/= args /$ ,[beam *] /= args /$ ,[beam *]
/= result /= result
/^ (list [comment-info:write manx]) /^ (list [comment-info:write @t])
/; /;
|= $= comments |= $= comments
%+ map knot %+ map knot
$: comment-front=(map knot cord) $: comment-front=(map knot cord)
comment-content=manx comment-content=wain
~ ~
== ==
^- (list [comment-info:write manx]) ^- (list [comment-info:write @t])
:: XX sort this list :: XX sort this list
%+ turn ~(tap by comments) %+ turn ~(tap by comments)
|= [fil=knot front=(map knot cord) content=manx ~] |= [fil=knot front=(map knot cord) content=wain ~]
^- [comment-info:write manx] ^- [comment-info:write @t]
[(front-to-comment-info:write front) content] :- (front-to-comment-info:write front)
(of-wain:format (slag 8 content))
:: ::
/_ /_
/. /&front&/udon/ /. /&front&/udon/
/&elem&/udon/ /&txt&/udon/
== ==
result result

View File

@ -1,9 +1,4 @@
|% |%
+$ item-id
$? coll=@tas
[coll=@tas post=@tas]
[coll=@tas post=@tas comment=@tas]
==
:: ::
+$ action +$ action
$% $: %new-collection $% $: %new-collection
@ -26,7 +21,9 @@
:: ::
[%new-comment who=@p coll=@tas post=@tas content=@t] [%new-comment who=@p coll=@tas post=@tas content=@t]
:: ::
[%delete item-id] [%delete-collection coll=@tas]
[%delete-post coll=@tas post=@tas]
[%delete-comment coll=@tas post=@tas comment=@tas]
:: ::
$: %edit-collection $: %edit-collection
name=@tas name=@tas
@ -46,9 +43,8 @@
content=@t content=@t
== ==
:: ::
[%edit-comment coll=@tas post=@tas id=@tas content=@t] [%invite coll=@tas title=@t who=(list ship)]
:: [%reject-invite coll=@tas who=ship]
[%invite coll=@tas who=(list ship)]
:: ::
[%serve coll=@tas] [%serve coll=@tas]
[%unserve coll=@tas] [%unserve coll=@tas]
@ -96,17 +92,14 @@
+$ edit-config $?(%post %comment %all %none) +$ edit-config $?(%post %comment %all %none)
:: ::
+$ rumor delta +$ rumor delta
:: $% [%collection who=@p col=@tas dat=(each collection-info tang)]
:: [%post who=@p col=@tas pos=@tas dat=(each [post-info manx] tang)]
:: [%comments who=@p col=@tas pos=@tas dat=(each (list [comment-info manx]) tang)]
:: [%serve who=@p nom=@tas col=collection]
:: ==
:: ::
+$ collection +$ collection
$: col=(each collection-info tang) $: col=(each collection-info tang)
pos=(map @tas (each [post-info manx @t] tang)) pos=(map @tas (each [post-info manx @t] tang))
com=(map @tas (each (list [comment-info manx]) tang)) com=(map @tas (each (list [comment-info @t]) tang))
order=[pin=(list @tas) unpin=(list @tas)] order=[pin=(list @tas) unpin=(list @tas)]
contributors=(set @p)
subscribers=(set @p)
== ==
:: ::
+$ state +$ state
@ -115,12 +108,14 @@
awaiting=(map @tas [builds=(set wire) partial=(unit delta)]) awaiting=(map @tas [builds=(set wire) partial=(unit delta)])
latest=(list [who=ship coll=@tas post=@tas]) latest=(list [who=ship coll=@tas post=@tas])
unread=(set [who=ship coll=@tas post=@tas]) unread=(set [who=ship coll=@tas post=@tas])
invites=(map [who=ship coll=@tas] title=@t)
== ==
:: ::
+$ delta +$ delta
$% [%collection who=@p col=@tas dat=(each collection-info tang)] $% [%collection who=@p col=@tas dat=(each collection-info tang)]
[%post who=@p col=@tas pos=@tas dat=(each [post-info manx @t] tang)] [%post who=@p col=@tas pos=@tas dat=(each [post-info manx @t] tang)]
[%comments who=@p col=@tas pos=@tas dat=(each (list [comment-info manx]) tang)] [%comments who=@p col=@tas pos=@tas dat=(each (list [comment-info @t]) tang)]
[%total who=@p col=@tas dat=collection] [%total who=@p col=@tas dat=collection]
[%remove who=@p col=@tas pos=(unit @tas)]
== ==
-- --