mirror of
https://github.com/urbit/shrub.git
synced 2024-11-30 22:15:47 +03:00
handle marking posts as read
This commit is contained in:
parent
97f820a2c6
commit
041900dc26
@ -96,7 +96,7 @@
|
||||
%+ require-authorization:app req
|
||||
handle-http-request:main
|
||||
::
|
||||
%publish-action2
|
||||
%publish-action
|
||||
=^ cards state
|
||||
(poke-publish-action:main !<(action vas))
|
||||
[cards this]
|
||||
@ -109,14 +109,9 @@
|
||||
[%http-response *] [~ this]
|
||||
::
|
||||
[%notebook @ ~]
|
||||
=/ book-name i.t.pax
|
||||
?. (allowed src.bol %read book-name)
|
||||
~|("not permitted" !!)
|
||||
=/ book (~(got by books) book-name)
|
||||
=/ delta=notebook-delta
|
||||
[%add-book our.bol book-name book]
|
||||
:_ this
|
||||
[%give %fact ~ %publish-notebook-delta !>(delta)]~
|
||||
=^ cards state
|
||||
(watch-notebook:main pax)
|
||||
[cards this]
|
||||
::
|
||||
[%primary ~] [~ this]
|
||||
::
|
||||
@ -535,6 +530,18 @@
|
||||
(weld /notebook path.upd)
|
||||
==
|
||||
::
|
||||
++ watch-notebook
|
||||
|= pax=path
|
||||
?> ?=([%notebook @ ~] pax)
|
||||
=/ book-name i.t.pax
|
||||
?. (allowed src.bol %read book-name)
|
||||
~|("not permitted" !!)
|
||||
=/ book (~(got by books) book-name)
|
||||
=/ delta=notebook-delta
|
||||
[%add-book our.bol book-name book]
|
||||
:_ state
|
||||
[%give %fact ~ %publish-notebook-delta !>(delta)]~
|
||||
::
|
||||
++ our-beak /(scot %p our.bol)/[q.byk.bol]/(scot %da now.bol)
|
||||
::
|
||||
++ allowed
|
||||
@ -546,7 +553,7 @@
|
||||
?: =(%read mod)
|
||||
subscribers.book
|
||||
writers.book
|
||||
=/ full-pax :(weld scry-bek /permitted/(scot %p who) scry-pax)
|
||||
=/ full-pax :(weld scry-bek /permitted/(scot %p who) scry-pax /noun)
|
||||
.^(? %gx full-pax)
|
||||
::
|
||||
++ write-file
|
||||
@ -691,7 +698,7 @@
|
||||
%new-note
|
||||
?: &(=(src.bol our.bol) !=(our.bol who.act))
|
||||
:_ state
|
||||
[%pass /forward %agent [who.act %publish] %poke %publish-action2 !>(act)]~
|
||||
[%pass /forward %agent [who.act %publish] %poke %publish-action !>(act)]~
|
||||
=/ book=(unit notebook) (~(get by books) book.act)
|
||||
?~ book
|
||||
~|("nonexistent notebook {<book.act>}" !!)
|
||||
@ -715,7 +722,7 @@
|
||||
%new-comment
|
||||
?: &(=(src.bol our.bol) !=(our.bol who.act))
|
||||
:_ state
|
||||
[%pass /forward %agent [who.act %publish] %poke %publish-action2 !>(act)]~
|
||||
[%pass /forward %agent [who.act %publish] %poke %publish-action !>(act)]~
|
||||
=/ book=(unit notebook) (~(get by books) book.act)
|
||||
?~ book
|
||||
~|("nonexistent notebook {<book.act>}" !!)
|
||||
@ -762,7 +769,7 @@
|
||||
%edit-note
|
||||
?: &(=(src.bol our.bol) !=(our.bol who.act))
|
||||
:_ state
|
||||
[%pass /forward %agent [who.act %publish] %poke %publish-action2 !>(act)]~
|
||||
[%pass /forward %agent [who.act %publish] %poke %publish-action !>(act)]~
|
||||
=/ book=(unit notebook) (~(get by books) book.act)
|
||||
?~ book
|
||||
~|("nonexistent notebook {<book.act>}" !!)
|
||||
@ -789,7 +796,7 @@
|
||||
%edit-comment
|
||||
?: &(=(src.bol our.bol) !=(our.bol who.act))
|
||||
:_ state
|
||||
[%pass /forward %agent [who.act %publish] %poke %publish-action2 !>(act)]~
|
||||
[%pass /forward %agent [who.act %publish] %poke %publish-action !>(act)]~
|
||||
=/ book=(unit notebook) (~(get by books) book.act)
|
||||
?~ book
|
||||
~|("nonexistent notebook {<book.act>}" !!)
|
||||
@ -826,7 +833,7 @@
|
||||
%del-note
|
||||
?: &(=(src.bol our.bol) !=(our.bol who.act))
|
||||
:_ state
|
||||
[%pass /forward %agent [who.act %publish] %poke %publish-action2 !>(act)]~
|
||||
[%pass /forward %agent [who.act %publish] %poke %publish-action !>(act)]~
|
||||
=/ book=(unit notebook) (~(get by books) book.act)
|
||||
?~ book
|
||||
~|("nonexistent notebook {<book.act>}" !!)
|
||||
@ -846,7 +853,7 @@
|
||||
%del-comment
|
||||
?: &(=(src.bol our.bol) !=(our.bol who.act))
|
||||
:_ state
|
||||
[%pass /forward %agent [who.act %publish] %poke %publish-action2 !>(act)]~
|
||||
[%pass /forward %agent [who.act %publish] %poke %publish-action !>(act)]~
|
||||
=/ book=(unit notebook) (~(get by books) book.act)
|
||||
?~ book
|
||||
~|("nonexistent notebook {<book.act>}" !!)
|
||||
@ -883,6 +890,26 @@
|
||||
:~ [%pass wir %agent [who.act %publish] %leave ~]
|
||||
[%give %fact `/primary %publish-primary-delta !>(del)]
|
||||
==
|
||||
::
|
||||
%read
|
||||
?> (team:title our.bol src.bol)
|
||||
=/ book=(unit notebook)
|
||||
?: =(our.bol who.act)
|
||||
(~(get by books) book.act)
|
||||
(~(get by subs) who.act book.act)
|
||||
?~ book
|
||||
~|("nonexistent notebook: {<book.act>}" !!)
|
||||
=/ not=(unit note) (~(get by notes.u.book) note.act)
|
||||
?~ not
|
||||
~|("nonexistent note: {<note.act>}" !!)
|
||||
=. read.u.not %.y
|
||||
=. notes.u.book (~(put by notes.u.book) note.act u.not)
|
||||
=? books =(our.bol who.act)
|
||||
(~(put by books) book.act u.book)
|
||||
=? subs !=(our.bol who.act)
|
||||
(~(put by subs) [who.act book.act] u.book)
|
||||
:_ state
|
||||
[%give %fact `/primary %publish-primary-delta !>(act)]~
|
||||
==
|
||||
::
|
||||
++ get-notebook
|
||||
|
@ -1,11 +1,10 @@
|
||||
::
|
||||
:::: /hoon/action/publish/mar
|
||||
::
|
||||
/? 309
|
||||
/- publish
|
||||
/- *publish
|
||||
=, format
|
||||
::
|
||||
|_ act=action:publish
|
||||
|_ act=action
|
||||
::
|
||||
++ grow
|
||||
|%
|
||||
@ -14,179 +13,112 @@
|
||||
::
|
||||
++ grab
|
||||
|%
|
||||
++ noun action:publish
|
||||
++ noun action
|
||||
++ json
|
||||
|= jon=^json
|
||||
%- action:publish
|
||||
=< (action jon)
|
||||
|%
|
||||
++ action
|
||||
%- of:dejs
|
||||
:~ new-collection+new-collection
|
||||
new-post+new-post
|
||||
=, dejs:format
|
||||
;; action
|
||||
|^ %- of
|
||||
:~ new-book+new-book
|
||||
new-note+new-note
|
||||
new-comment+new-comment
|
||||
::
|
||||
delete-collection+delete-collection
|
||||
delete-post+delete-post
|
||||
delete-comment+delete-comment
|
||||
::
|
||||
edit-collection+edit-collection
|
||||
edit-post+edit-post
|
||||
::
|
||||
invite+invite
|
||||
reject-invite+reject-invite
|
||||
::
|
||||
serve+serve
|
||||
unserve+unserve
|
||||
::
|
||||
edit-book+edit-book
|
||||
edit-note+edit-note
|
||||
edit-comment+edit-comment
|
||||
del-book+del-book
|
||||
del-note+del-note
|
||||
del-comment+del-comment
|
||||
subscribe+subscribe
|
||||
unsubscribe+unsubscribe
|
||||
::
|
||||
read+read
|
||||
==
|
||||
::
|
||||
++ new-collection
|
||||
%- ot:dejs
|
||||
:~ name+so:dejs
|
||||
title+so:dejs
|
||||
comments+comment-config
|
||||
allow-edit+edit-config
|
||||
perm+perm-config
|
||||
++ new-book
|
||||
%- ot
|
||||
:~ book+so
|
||||
title+so
|
||||
about+so
|
||||
coms+bo
|
||||
group+group-info
|
||||
==
|
||||
::
|
||||
++ new-post
|
||||
%- ot:dejs
|
||||
:~ who+(su:dejs fed:ag)
|
||||
coll+so:dejs
|
||||
name+so:dejs
|
||||
title+so:dejs
|
||||
comments+comment-config
|
||||
perm+perm-config
|
||||
content+so:dejs
|
||||
++ new-note
|
||||
%- ot
|
||||
:~ who+(su fed:ag)
|
||||
book+so
|
||||
note+so
|
||||
title+so
|
||||
body+so
|
||||
==
|
||||
::
|
||||
++ new-comment
|
||||
%- ot:dejs
|
||||
:~ who+(su:dejs fed:ag)
|
||||
coll+so:dejs
|
||||
name+(su:dejs sym)
|
||||
content+so:dejs
|
||||
%- ot
|
||||
:~ who+(su fed:ag)
|
||||
book+so
|
||||
note+so
|
||||
body+so
|
||||
==
|
||||
::
|
||||
++ delete-collection
|
||||
%- ot:dejs
|
||||
:~ coll+so:dejs
|
||||
++ edit-book
|
||||
%- ot
|
||||
:~ book+so
|
||||
title+so
|
||||
about+so
|
||||
coms+bo
|
||||
group+(mu group-info)
|
||||
==
|
||||
::
|
||||
++ delete-post
|
||||
%- ot:dejs
|
||||
:~ coll+so:dejs
|
||||
post+so:dejs
|
||||
==
|
||||
::
|
||||
++ delete-comment
|
||||
%- ot:dejs
|
||||
:~ coll+so:dejs
|
||||
post+so:dejs
|
||||
comment+so:dejs
|
||||
==
|
||||
::
|
||||
++ edit-collection
|
||||
%- ot:dejs
|
||||
:~ name+so:dejs
|
||||
title+so:dejs
|
||||
==
|
||||
::
|
||||
++ edit-post
|
||||
%- ot:dejs
|
||||
:~ who+(su:dejs fed:ag)
|
||||
coll+so:dejs
|
||||
name+so:dejs
|
||||
title+so:dejs
|
||||
comments+comment-config
|
||||
perm+perm-config
|
||||
content+so:dejs
|
||||
++ edit-note
|
||||
%- ot
|
||||
:~ who+(su fed:ag)
|
||||
book+so
|
||||
note+so
|
||||
title+so
|
||||
body+so
|
||||
==
|
||||
::
|
||||
++ edit-comment
|
||||
%- ot:dejs
|
||||
:~ coll+so:dejs
|
||||
name+so:dejs
|
||||
id+so:dejs
|
||||
content+so:dejs
|
||||
%- ot
|
||||
:~ who+(su fed:ag)
|
||||
book+so
|
||||
note+so
|
||||
comment+(su ;~(pfix sig (cook year when:^so)))
|
||||
body+so
|
||||
==
|
||||
::
|
||||
++ comment-config
|
||||
%- su:dejs
|
||||
;~(pose (jest %open) (jest %closed) (jest %none))
|
||||
++ del-book (ot book+so ~)
|
||||
::
|
||||
++ edit-config
|
||||
%- su:dejs
|
||||
;~(pose (jest %post) (jest %comment) (jest %all) (jest %none))
|
||||
++ del-note (ot who+(su fed:ag) book+so note+so ~)
|
||||
::
|
||||
++ perm-config
|
||||
%- ot:dejs
|
||||
:~ :- %read
|
||||
%- ot:dejs
|
||||
:~ mod+(su:dejs ;~(pose (jest %black) (jest %white)))
|
||||
who+whoms
|
||||
++ del-comment
|
||||
%- ot
|
||||
:~ who+(su fed:ag)
|
||||
book+so
|
||||
note+so
|
||||
comment+(su ;~(pfix sig (cook year when:^so)))
|
||||
==
|
||||
:- %write
|
||||
%- ot:dejs
|
||||
:~ mod+(su:dejs ;~(pose (jest %black) (jest %white)))
|
||||
who+whoms
|
||||
== ==
|
||||
::
|
||||
++ whoms
|
||||
|= jon=^json
|
||||
^- (set whom:clay)
|
||||
=/ x ((ar:dejs (su:dejs fed:ag)) jon)
|
||||
%- (set whom:clay)
|
||||
%- ~(run in (sy x))
|
||||
|=(w=@ [& w])
|
||||
::
|
||||
++ invite
|
||||
%- ot:dejs
|
||||
:~ coll+so:dejs
|
||||
title+so:dejs
|
||||
who+(ar:dejs (su:dejs fed:ag))
|
||||
==
|
||||
::
|
||||
++ reject-invite
|
||||
%- ot:dejs
|
||||
:~ who+(su:dejs fed:ag)
|
||||
coll+so:dejs
|
||||
==
|
||||
::
|
||||
++ serve
|
||||
%- ot:dejs
|
||||
:~ coll+so:dejs
|
||||
==
|
||||
::
|
||||
++ unserve
|
||||
%- ot:dejs
|
||||
:~ coll+so:dejs
|
||||
==
|
||||
::
|
||||
++ subscribe
|
||||
%- ot:dejs
|
||||
:~ who+(su:dejs fed:ag)
|
||||
coll+so:dejs
|
||||
%- ot
|
||||
:~ who+(su fed:ag)
|
||||
book+so
|
||||
==
|
||||
::
|
||||
++ unsubscribe
|
||||
%- ot:dejs
|
||||
:~ who+(su:dejs fed:ag)
|
||||
coll+so:dejs
|
||||
%- ot
|
||||
:~ who+(su fed:ag)
|
||||
book+so
|
||||
==
|
||||
::
|
||||
++ read
|
||||
%- ot:dejs
|
||||
:~ who+(su:dejs fed:ag)
|
||||
coll+so:dejs
|
||||
post+so:dejs
|
||||
%- ot
|
||||
:~ who+(su fed:ag)
|
||||
book+so
|
||||
note+so
|
||||
==
|
||||
::
|
||||
++ group-info
|
||||
%- of
|
||||
:~ old+(ot writers+pa subscribers+pa ~)
|
||||
new+(ot writers+set-ship subscribers+set-ship sec+so ~)
|
||||
==
|
||||
++ set-ship (ar (su fed:ag))
|
||||
--
|
||||
--
|
||||
--
|
||||
|
@ -1,117 +0,0 @@
|
||||
::
|
||||
:::: /hoon/action/publish/mar
|
||||
::
|
||||
/- *publish
|
||||
=, format
|
||||
::
|
||||
|_ act=action
|
||||
::
|
||||
++ grow
|
||||
|%
|
||||
++ tank >act<
|
||||
--
|
||||
::
|
||||
++ grab
|
||||
|%
|
||||
++ noun action
|
||||
++ json
|
||||
|= jon=^json
|
||||
=, dejs:format
|
||||
;; action
|
||||
|^ %- of
|
||||
:~ new-book+new-book
|
||||
new-note+new-note
|
||||
new-comment+new-comment
|
||||
edit-book+edit-book
|
||||
edit-note+edit-note
|
||||
edit-comment+edit-comment
|
||||
del-book+del-book
|
||||
del-note+del-note
|
||||
del-comment+del-comment
|
||||
subscribe+subscribe
|
||||
unsubscribe+unsubscribe
|
||||
==
|
||||
::
|
||||
++ new-book
|
||||
%- ot
|
||||
:~ book+so
|
||||
title+so
|
||||
about+so
|
||||
coms+bo
|
||||
group+group-info
|
||||
==
|
||||
::
|
||||
++ new-note
|
||||
%- ot
|
||||
:~ who+(su fed:ag)
|
||||
book+so
|
||||
note+so
|
||||
title+so
|
||||
body+so
|
||||
==
|
||||
::
|
||||
++ new-comment
|
||||
%- ot
|
||||
:~ who+(su fed:ag)
|
||||
book+so
|
||||
note+so
|
||||
body+so
|
||||
==
|
||||
::
|
||||
++ edit-book
|
||||
%- ot
|
||||
:~ book+so
|
||||
title+so
|
||||
about+so
|
||||
coms+bo
|
||||
group+(mu group-info)
|
||||
==
|
||||
::
|
||||
++ edit-note
|
||||
%- ot
|
||||
:~ who+(su fed:ag)
|
||||
book+so
|
||||
note+so
|
||||
title+so
|
||||
body+so
|
||||
==
|
||||
::
|
||||
++ edit-comment
|
||||
%- ot
|
||||
:~ who+(su fed:ag)
|
||||
book+so
|
||||
note+so
|
||||
comment+(su ;~(pfix sig (cook year when:^so)))
|
||||
body+so
|
||||
==
|
||||
::
|
||||
++ del-book (ot book+so ~)
|
||||
::
|
||||
++ del-note (ot who+(su fed:ag) book+so note+so ~)
|
||||
::
|
||||
++ del-comment
|
||||
%- ot
|
||||
:~ who+(su fed:ag)
|
||||
book+so
|
||||
note+so
|
||||
comment+(su ;~(pfix sig (cook year when:^so)))
|
||||
==
|
||||
++ subscribe
|
||||
%- ot
|
||||
:~ who+(su fed:ag)
|
||||
book+so
|
||||
==
|
||||
++ unsubscribe
|
||||
%- ot
|
||||
:~ who+(su fed:ag)
|
||||
book+so
|
||||
==
|
||||
++ group-info
|
||||
%- of
|
||||
:~ old+(ot writers+pa subscribers+pa ~)
|
||||
new+(ot writers+set-ship subscribers+set-ship sec+so ~)
|
||||
==
|
||||
++ set-ship (ar (su fed:ag))
|
||||
--
|
||||
--
|
||||
--
|
@ -71,6 +71,13 @@
|
||||
note+s+note.del
|
||||
comment+s+(scot %da comment.del)
|
||||
==
|
||||
::
|
||||
%read
|
||||
%- pairs:enjs:format
|
||||
:~ host+s+(scot %p who.del)
|
||||
book+s+book.del
|
||||
note+s+note.del
|
||||
==
|
||||
==
|
||||
--
|
||||
--
|
||||
|
@ -1,55 +0,0 @@
|
||||
/- *publish
|
||||
/+ *publish
|
||||
|_ rum=rumor
|
||||
++ grab
|
||||
|%
|
||||
++ noun rumor
|
||||
--
|
||||
++ grow
|
||||
|%
|
||||
++ noun rum
|
||||
++ json
|
||||
=, enjs:format
|
||||
%+ frond -.rum
|
||||
?- -.rum
|
||||
%collection
|
||||
%- pairs
|
||||
:~ [%coll s+col.rum]
|
||||
[%who (ship who.rum)]
|
||||
[%data (collection-build-to-json dat.rum)]
|
||||
==
|
||||
::
|
||||
%post
|
||||
%- pairs
|
||||
:~ [%coll s+col.rum]
|
||||
[%post s+pos.rum]
|
||||
[%who (ship who.rum)]
|
||||
[%data (post-build-to-json dat.rum)]
|
||||
==
|
||||
::
|
||||
%comments
|
||||
%- pairs
|
||||
:~ [%coll s+col.rum]
|
||||
[%post s+pos.rum]
|
||||
[%who (ship who.rum)]
|
||||
[%data (comment-build-to-json dat.rum)]
|
||||
==
|
||||
::
|
||||
%total
|
||||
%- pairs
|
||||
:~ [%coll s+col.rum]
|
||||
[%who (ship who.rum)]
|
||||
[%data (total-build-to-json dat.rum)]
|
||||
==
|
||||
::
|
||||
%remove
|
||||
%- pairs
|
||||
:~ [%who (ship who.rum)]
|
||||
[%coll s+col.rum]
|
||||
[%post ?~(pos.rum ~ s+u.pos.rum)]
|
||||
==
|
||||
::
|
||||
==
|
||||
::
|
||||
--
|
||||
--
|
@ -1,41 +0,0 @@
|
||||
/- *publish
|
||||
|_ upd=update
|
||||
++ grab
|
||||
|%
|
||||
++ noun update
|
||||
--
|
||||
++ grow
|
||||
|%
|
||||
++ noun upd
|
||||
++ json
|
||||
=, enjs:format
|
||||
%+ frond -.upd
|
||||
::
|
||||
?- -.upd
|
||||
%invite
|
||||
%- pairs
|
||||
:~ [%who (ship who.upd)]
|
||||
[%add b+add.upd]
|
||||
[%coll s+col.upd]
|
||||
[%title s+title.upd]
|
||||
==
|
||||
::
|
||||
%unread
|
||||
%- pairs
|
||||
:~ [%add b+add.upd]
|
||||
:+ %posts
|
||||
%a
|
||||
%+ turn ~(tap in keys.upd)
|
||||
|= [who=@p coll=@tas post=@tas]
|
||||
^- ^json
|
||||
%- pairs
|
||||
:~ [%who (ship who)]
|
||||
[%coll s+coll]
|
||||
[%post s+post]
|
||||
==
|
||||
==
|
||||
::
|
||||
==
|
||||
::
|
||||
--
|
||||
--
|
@ -21,6 +21,8 @@
|
||||
::
|
||||
[%subscribe who=@p book=@tas]
|
||||
[%unsubscribe who=@p book=@tas]
|
||||
::
|
||||
[%read who=@p book=@tas note=@tas]
|
||||
==
|
||||
::
|
||||
+$ comment
|
||||
@ -77,5 +79,6 @@
|
||||
::
|
||||
+$ primary-delta
|
||||
$% notebook-delta
|
||||
[%read who=@p book=@tas note=@tas]
|
||||
==
|
||||
--
|
||||
|
@ -31,6 +31,9 @@ export class PrimaryReducer {
|
||||
case "del-comment":
|
||||
this.delComment(json["del-comment"], state);
|
||||
break;
|
||||
case "read":
|
||||
this.read(json["read"], state);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -210,4 +213,17 @@ export class PrimaryReducer {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
read(json, state){
|
||||
let host = json.host;
|
||||
let book = json.book;
|
||||
let noteId = json.note
|
||||
if (state.notebooks[host] &&
|
||||
state.notebooks[host][book] &&
|
||||
state.notebooks[host][book].notes &&
|
||||
state.notebooks[host][book].notes[noteId])
|
||||
{
|
||||
state.notebooks[host][book].notes[noteId]["read"] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user