shrub/pkg/arvo/lib/hark/store.hoon

227 lines
4.6 KiB
Plaintext
Raw Normal View History

2020-10-27 08:04:39 +03:00
/- sur=hark-store, post
2020-11-05 08:33:52 +03:00
/+ resource, graph-store, group-store, chat-store
2020-10-27 08:04:39 +03:00
^?
=< [. sur]
=, sur
|%
++ dejs
=, dejs:format
|%
++ index
%- of
:~ graph+graph-index
group+group-index
chat+chat-index
==
::
++ chat-index
%- ot
:~ chat+pa
mention+bo
2020-10-27 08:04:39 +03:00
==
::
++ group-index
%- ot
:~ group+dejs-path:resource
description+so
==
::
++ graph-index
%- ot
:~ group+dejs-path:resource
graph+dejs-path:resource
module+so
description+so
==
:: parse date as @ud
:: TODO: move to zuse
++ sd
|= jon=json
^- @da
?> ?=(%s -.jon)
`@da`(rash p.jon dem:ag)
::
++ notif-ref
^- $-(json [@da ^index])
%- ot
:~ time+sd
index+index
==
::
++ add
|= jon=json
[*^index *notification]
::
++ action
^- $-(json ^action)
%- of
:~ seen+ul
archive+notif-ref
unread+notif-ref
read+notif-ref
add+add
set-dnd+bo
2020-11-16 05:22:42 +03:00
read-index+index
2020-10-27 08:04:39 +03:00
==
--
::
++ enjs
=, enjs:format
|%
++ update
|= upd=^update
^- json
|^
%+ frond -.upd
?+ -.upd a+~
2020-10-28 08:52:59 +03:00
%added (added +.upd)
2020-10-27 08:04:39 +03:00
%timebox (timebox +.upd)
%set-dnd b+dnd.upd
%count (numb count.upd)
2020-11-16 05:22:42 +03:00
%unreads (unreads unreads.upd)
2020-10-27 08:04:39 +03:00
%more (more +.upd)
2020-11-10 06:32:48 +03:00
::
2020-10-27 08:04:39 +03:00
?(%archive %read %unread)
(notif-ref +.upd)
==
::
2020-11-16 05:22:42 +03:00
++ unreads
|= l=(list [^index @ud])
2020-11-12 04:31:33 +03:00
^- json
2020-11-16 05:22:42 +03:00
:- %a
^- (list json)
%+ turn l
|= [idx=^index unread=@ud]
2020-11-12 04:31:33 +03:00
%- pairs
2020-11-16 05:22:42 +03:00
:~ unread+(numb unread)
index+(index idx)
==
2020-11-12 04:31:33 +03:00
::
2020-10-28 08:52:59 +03:00
++ added
|= [tim=@da idx=^index not=^notification]
^- json
%- pairs
:~ time+s+(scot %ud tim)
index+(index idx)
notification+(notification not)
==
::
2020-10-27 08:04:39 +03:00
++ notif-ref
|= [tim=@da idx=^index]
^- json
%- pairs
:~ time+s+(scot %ud tim)
index+(index idx)
==
::
++ more
|= upds=(list ^update)
^- json
a+(turn upds update)
::
++ index
|= =^index
%+ frond -.index
|^
?- -.index
%graph (graph-index +.index)
%group (group-index +.index)
%chat (chat-index +.index)
2020-10-27 08:04:39 +03:00
==
::
++ chat-index
|= [chat=^path mention=?]
^- json
%- pairs
:~ chat+(path chat)
mention+b+mention
==
2020-10-27 08:04:39 +03:00
::
++ graph-index
|= [group=resource graph=resource module=@t description=@t]
^- json
%- pairs
:~ group+s+(enjs-path:resource group)
graph+s+(enjs-path:resource graph)
module+s+module
description+s+description
==
::
++ group-index
|= [group=resource description=@t]
^- json
%- pairs
:~ group+s+(enjs-path:resource group)
description+s+description
==
--
::
++ notification
|= ^notification
^- json
%- pairs
:~ time+(time date)
read+b+read
contents+(^contents contents)
==
::
++ contents
|= =^contents
^- json
%+ frond -.contents
|^
?- -.contents
%graph (graph-contents +.contents)
%group (group-contents +.contents)
2020-11-05 08:33:52 +03:00
%chat (chat-contents +.contents)
2020-10-27 08:04:39 +03:00
==
::
2020-11-05 08:33:52 +03:00
++ chat-contents
|= =(list envelope:chat-store)
^- json
:- %a
(turn list envelope:enjs:chat-store)
::
2020-10-27 08:04:39 +03:00
++ graph-contents
|= =(list post:post)
^- json
:- %a
(turn list post:enjs:graph-store)
::
++ group-contents
|= =(list ^group-contents)
^- json
:- %a
%+ murn list
|= =^group-contents
?. ?=(?(%add-members %remove-members) -.group-contents)
~
`(update:enjs:group-store group-contents)
--
::
++ indexed-notification
|= [=^index =^notification]
%- pairs
:~ index+(^index index)
notification+(^notification notification)
==
::
++ timebox
|= [tim=@da arch=? l=(list [^index ^notification])]
^- json
%- pairs
:~ time+s+(scot %ud tim)
archive+b+arch
:- %notifications
^- json
:- %a
%+ turn l
|= [=^index =^notification]
^- json
(indexed-notification index notification)
==
--
--
--