sending updates to subscribers

This commit is contained in:
Isaac Visintainer 2019-12-09 09:10:03 -08:00
parent 504b9b289c
commit dcec0315ae
3 changed files with 127 additions and 283 deletions

View File

@ -34,35 +34,6 @@
|%
+$ card card:agent:gall
::
+$ comment
$: author=@p
date-created=@da
last-edit=@da
content=@t
==
::
+$ note
$: author=@p
title=@t
filename=@tas
date-created=@da
last-edit=@da
file=@t
build=(each manx tang)
comments=(map @da comment)
==
::
+$ notebook
$: title=@t
date-created=@da
last-note=@da
notes=(map @tas note)
order=(list @tas)
pinned=(set @tas)
participants=path
subscribers=path
==
::
+$ versioned-state
$% [%1 state-one]
==
@ -120,13 +91,11 @@
:_ this
%+ give-simple-payload:app id
%+ require-authorization:app req
|= req=inbound-request:eyre
^- simple-payload:http
not-found:gen
handle-http-request:main
::
%publish-action2
=^ cards state
(poke-publish-action-2:main !<(action-2 vas))
(poke-publish-action:main !<(action vas))
[cards this]
==
::
@ -138,8 +107,11 @@
::
[%notebook @ ~]
=/ book-name i.t.pax
=/ book (~(get by books) book-name)
!!
=/ book (~(got by books) book-name)
:_ this
[%give %fact ~ %publish-book-update !>([%full book-name book])]~
::
[%primary ~] [~ this]
::
[%tile ~] !!
==
@ -168,7 +140,8 @@
[%subscribe @ @ ~]
=/ who=@p (slav %p i.t.wir)
=/ book-name i.t.t.wir
!!
?> ?=(%publish-book-update p.cage.sin)
(handle-notebook-delta:main !<(notebook-delta q.cage.sin))
::
[%permissions ~] !!
::
@ -254,8 +227,11 @@
=. comments.new-note comments.u.old-note
=. notes.u.book (~(put by notes.u.book) note-name new-note)
=/ rif=riff:clay [q.byk.bol `[%next %x [%da now.bol] pax]]
:- [%pass (welp /read/note pax) %arvo %c %warp our.bol rif]~
state(books (~(put by books) book-name u.book))
=/ fac=notebook-delta [%note book-name note-name new-note]
:_ state(books (~(put by books) book-name u.book))
:~ [%pass (welp /read/note pax) %arvo %c %warp our.bol rif]
[%give %fact `/notebook/[book-name] %publish-book-update !>(fac)]
==
::
++ read-comment
|= [pax=path rot=riot:clay]
@ -281,8 +257,12 @@
=. comments.u.note (~(put by comments.u.note) u.comment-date new-comment)
=. notes.u.book (~(put by notes.u.book) note-name u.note)
=/ rif=riff:clay [q.byk.bol `[%next %x [%da now.bol] pax]]
:- [%pass (welp /read/comment pax) %arvo %c %warp our.bol rif]~
state(books (~(put by books) book-name u.book))
=/ fac=notebook-delta
[%comment book-name note-name u.comment-date new-comment]
:_ state(books (~(put by books) book-name u.book))
:~ [%pass (welp /read/comment pax) %arvo %c %warp our.bol rif]
[%give %fact `/notebook/[book-name] %publish-book-update !>(fac)]
==
::
++ filter-and-sort-paths
|= paths=(list path)
@ -317,8 +297,9 @@
?~ book
[~ sty]
=. notes.u.book (~(del by notes.u.book) note-name)
:- ~
sty(books (~(put by books) book-name u.book))
=/ fac=notebook-delta [%del-note book-name note-name]
:_ sty(books (~(put by books) book-name u.book))
[%give %fact `/notebook/[book-name] %publish-book-update !>(fac)]~
::
[%app %publish %notebooks @ @ @ %publish-comment ~]
=/ book-name i.t.t.t.pax
@ -334,8 +315,9 @@
[~ sty]
=. comments.u.note (~(del by comments.u.note) u.comment-date)
=. notes.u.book (~(put by notes.u.book) note-name u.note)
:- ~
sty(books (~(put by books.sty) book-name u.book))
=/ fac=notebook-delta [%del-comment book-name note-name u.comment-date]
:_ sty(books (~(put by books.sty) book-name u.book))
[%give %fact `/notebook/[book-name] %publish-book-update !>(fac)]~
==
::
++ add-paths
@ -368,8 +350,11 @@
=. comments.new-note comments.u.old-note
=. notes.new-book (~(put by notes.new-book) note-name new-note)
=/ rif=riff:clay [q.byk.bol `[%next %x [%da now.bol] pax]]
:- [%pass (welp /read/note pax) %arvo %c %warp our.bol rif]~
sty(books (~(put by books.sty) book-name new-book))
=/ fac=notebook-delta [%note book-name note-name new-note]
:_ sty(books (~(put by books.sty) book-name new-book))
:~ [%pass (welp /read/note pax) %arvo %c %warp our.bol rif]
[%give %fact `/notebook/[book-name] %publish-book-update !>(fac)]
==
::
=/ comment-dir /app/publish/notebooks/[book-name]/[note-name]
=/ comment-paths .^((list path) %ct (weld our-beak comment-dir))
@ -388,8 +373,12 @@
=. comments.new-note new-comments
=. notes.new-book (~(put by notes.new-book) note-name new-note)
=/ rif=riff:clay [q.byk.bol `[%next %x [%da now.bol] pax]]
:- [[%pass (welp /read/note pax) %arvo %c %warp our.bol rif] cards]
sty(books (~(put by books.sty) book-name new-book))
=/ fac=notebook-delta [%note book-name note-name new-note]
:_ sty(books (~(put by books.sty) book-name new-book))
:* [%pass (welp /read/note pax) %arvo %c %warp our.bol rif]
[%give %fact `/notebook/[book-name] %publish-book-update !>(fac)]
cards
==
::
[%app %publish %notebooks @ @ @ %publish-comment ~]
=/ book-name i.t.t.t.pax
@ -407,8 +396,12 @@
=. comments.u.note (~(put by comments.u.note) u.comment-name new-com)
=. notes.u.book (~(put by notes.u.book) note-name u.note)
=/ rif=riff:clay [q.byk.bol `[%next %x [%da now.bol] pax]]
:- [%pass (welp /read/comment pax) %arvo %c %warp our.bol rif]~
sty(books (~(put by books.sty) book-name u.book))
=/ fac=notebook-delta
[%comment book-name note-name u.comment-name new-com]
:_ sty(books (~(put by books.sty) book-name u.book))
:~ [%pass (welp /read/comment pax) %arvo %c %warp our.bol rif]
[%give %fact `/notebook/[book-name] %publish-book-update !>(fac)]
==
==
::
++ scry-note
@ -580,8 +573,8 @@
(perm-group-hook-poke [%associate sub [[sub sub-type] ~ ~]])
==
::
++ poke-publish-action-2
|= act=action-2
++ poke-publish-action
|= act=action
^- (quip card _state)
?- -.act
%new-book
@ -660,7 +653,10 @@
==
=. participants.book par-path
=. subscribers.book sub-path
[~ state(books (~(put by books) book.act book))]
:_ state(books (~(put by books) book.act book))
?~ new-title.act ~
=/ fac=notebook-delta [%book-meta book.act u.new-title.act]
[%give %fact `/notebook/[book.act] %publish-book-update !>(fac)]~
::
%edit-note
=/ pax=path /app/publish/notebooks/[book.act]/[note.act]/udon
@ -713,4 +709,53 @@
[%pass wir %agent [who.act %publish] %leave ~]~
==
::
++ handle-notebook-delta
|= del=notebook-delta
^- (quip card _state)
?- -.del
%book
:_ state(books (~(put by books) book.del data.del))
~
::
%book-meta
=/ book (~(got by books) book.del)
=. title.book title.del
:_ state(books (~(put by books) book.del data.del))
~
::
%note
=/ book (~(got by books) book.del)
=. notes.book (~(put by notes.book) note.del data.del)
:_ state(books (~(put by books) book.del data.del))
~
::
%comment
=/ book (~(got by books) book.del)
=/ note (~(got by notes.book) note.del)
=. comments.note (~(put by comments.note) comment-date.del data.del)
=. notes.book (~(put by notes.book) note.del note)
:_ state(books (~(put by books) book.del data.del))
~
::
%del-book !!
::
%del-note
=/ book (~(got by books) book.del)
=. notes.book (~(del by notes.book) note.del)
:_ state(books (~(put by books) book.del data.del))
~
::
%del-comment
=/ book (~(got by books) book.del)
=/ note (~(got by notes.book) note.del)
=. comments.note (~(del by comments.note) comment-date.del)
=. notes.book (~(put by notes.book) note.del note)
:_ state(books (~(put by books) book.del data.del))
~
==
::
++ handle-http-request
|= req=inbound-request:eyre
^- simple-payload:http
not-found:gen
--

View File

@ -2,48 +2,6 @@
/+ elem-to-react-json
|%
::
++ front-to-post-info
|= fro=(map knot cord)
^- post-info
=/ got ~(got by fro)
~| %invalid-frontmatter
:* (slav %p (got %creator))
(got %title)
(got %collection)
(got %filename)
(comment-config (got %comments))
(slav %da (got %date-created))
(slav %da (got %last-modified))
(rash (got %pinned) (fuss %true %false))
==
::
++ collection-info-to-json
|= con=collection-info
^- json
%- pairs:enjs:format
:~ :- %owner [%s (scot %p owner.con)]
:- %title [%s title.con]
:- %comments [%s comments.con]
:- %allow-edit [%s allow-edit.con]
:- %date-created (time:enjs:format date-created.con)
:- %last-modified (time:enjs:format last-modified.con)
:- %filename [%s filename.con]
==
::
++ post-info-to-json
|= info=post-info
^- json
%- pairs:enjs:format
:~ :- %creator [%s (scot %p creator.info)]
:- %title [%s title.info]
:- %comments [%s comments.info]
:- %date-created (time:enjs:format date-created.info)
:- %last-modified (time:enjs:format last-modified.info)
:- %pinned [%b pinned.info]
:- %filename [%s filename.info]
:- %collection [%s collection.info]
==
::
++ tang-to-json
|= tan=tang
%- wall:enjs:format
@ -65,87 +23,4 @@
?: &((gte a 'A') (lte a 'Z'))
(add 32 a)
'-'
::
++ collection-build-to-json
|= bud=(each collection-info tang)
^- json
?: ?=(%.y -.bud)
(collection-info-to-json +.bud)
(tang-to-json +.bud)
::
++ post-build-to-json
|= bud=(each [post-info manx @t] tang)
^- json
?: ?=(%.y -.bud)
%- pairs:enjs:format
:~ info+(post-info-to-json +<.bud)
body+(elem-to-react-json +>-.bud)
raw+[%s +>+.bud]
==
(tang-to-json +.bud)
::
++ comment-build-to-json
|= bud=(each (list comment) tang)
^- json
?: ?=(%.y -.bud)
:- %a
%+ turn p.bud
|= com=comment
^- json
%- pairs:enjs:format
:~ :- %info
%- pairs:enjs:format
:~ :- %creator [%s (scot %p author.com)]
:- %date-created (time:enjs:format date-created.com)
:- %last-modified (time:enjs:format last-modified.com)
==
body+s+body.com
==
(tang-to-json +.bud)
::
++ total-build-to-json
|= col=collection
^- json
%- pairs:enjs:format
:~ info+(collection-build-to-json dat.col.col)
::
:+ %posts
%o
%+ roll ~(tap in ~(key by pos.col))
|= [post=@tas out=(map @t json)]
=/ post-build (~(got by pos.col) post)
=/ comm-build (~(got by com.col) post)
%+ ~(put by out)
post
%- pairs:enjs:format
:~ post+(post-build-to-json dat.post-build)
comments+(comment-build-to-json dat.comm-build)
==
::
:- %order
%- pairs:enjs:format
:~ pin+a+(turn pin.order.col |=(s=@tas [%s s]))
unpin+a+(turn unpin.order.col |=(s=@tas [%s s]))
==
::
:- %contributors
%- pairs:enjs:format
:~ mod+s+mod.contributors.col
:+ %who
%a
%+ turn ~(tap in who.contributors.col)
|= who=@p
(ship:enjs:format who)
==
::
:+ %subscribers
%a
%+ turn ~(tap in subscribers.col)
|= who=@p
^- json
(ship:enjs:format who)
::
[%last-update (time:enjs:format last-update.col)]
==
--

View File

@ -1,61 +1,12 @@
/- *rw-security
|%
::
+$ action
$% $: %new-collection
name=@tas
title=@t
com=comment-config
edit=edit-config
perm=perm-config
==
::
$: %new-post
who=@p
coll=@tas
name=@tas
title=@t
com=comment-config
perm=perm-config
content=@t
==
::
[%new-comment who=@p coll=@tas post=@tas content=@t]
::
[%delete-collection coll=@tas]
[%delete-post coll=@tas post=@tas]
[%delete-comment coll=@tas post=@tas comment=@tas]
::
[%edit-collection name=@tas title=@t]
::
$: %edit-post
who=@p
coll=@tas
name=@tas
title=@t
com=comment-config
perm=perm-config
content=@t
==
::
[%invite coll=@tas title=@t who=(list ship)]
[%reject-invite who=@p coll=@tas]
::
[%serve coll=@tas]
[%unserve coll=@tas]
::
[%subscribe who=@p coll=@tas]
[%unsubscribe who=@p coll=@tas]
::
[%read who=@p coll=@tas post=@tas]
==
::
+$ group-info
$% [%old par=path sub=path]
[%new par=(set ship) sub=(set ship) sec=rw-security]
==
::
+$ action-2
+$ action
$% [%new-book book=@tas title=@t group=group-info]
[%new-note who=@p book=@tas note=@tas title=@t body=@t]
[%new-comment who=@p book=@tas note=@tas body=@t]
@ -72,70 +23,43 @@
[%unsubscribe who=@p book=@tas]
==
::
+$ collection-info
$: owner=@p
title=@t
filename=@tas
comments=comment-config
allow-edit=edit-config
date-created=@da
last-modified=@da
==
::
+$ post-info
$: creator=@p
title=@t
collection=@tas
filename=@tas
comments=comment-config
date-created=@da
last-modified=@da
pinned=?
==
::
+$ comment
$: author=@p
date-created=@da
last-modified=@da
body=@t
last-edit=@da
content=@t
==
::
+$ perm-config [read=rule:clay write=rule:clay]
::
+$ comment-config $?(%open %closed %none)
::
+$ edit-config $?(%post %comment %all %none)
::
+$ rumor delta
::
+$ publish-dir (map path publish-file)
::
+$ publish-file
$% [%udon @t]
[%publish-info collection-info]
[%publish-comment comment]
+$ note
$: author=@p
title=@t
filename=@tas
date-created=@da
last-edit=@da
file=@t
build=(each manx tang)
comments=(map @da comment)
==
::
+$ collection
$: col=[=bone dat=(each collection-info tang)]
pos=(map @tas [=bone dat=(each [post-info manx @t] tang)])
com=(map @tas [=bone dat=(each (list comment) tang)])
order=[pin=(list @tas) unpin=(list @tas)]
contributors=[mod=?(%white %black) who=(set @p)]
subscribers=(set @p)
last-update=@da
+$ notebook
$: title=@t
date-created=@da
notes=(map @tas note)
order=(list @tas)
pinned=(set @tas)
participants=path
subscribers=path
==
::
+$ delta
$% [%collection who=@p col=@tas dat=(each collection-info 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) tang)]
[%total who=@p col=@tas dat=collection]
[%remove who=@p col=@tas pos=(unit @tas)]
+$ notebook-delta
$% [%book book=@tas data=notebook]
[%book-meta book=@tas title=@t]
[%note book=@tas note=@tas data=note]
[%comment book=@tas note=@tas comment-date=@da data=comment]
[%del-book book=@tas]
[%del-note book=@tas note=@tas]
[%del-comment book=@tas note=@tas comment=@da]
==
::
+$ update
$% [%invite add=? who=@p col=@tas title=@t]
[%unread add=? keys=(set [who=@p coll=@tas post=@tas])]
==
+$ primary-delta !!
--