urbit/ape/work.hoon

338 lines
9.1 KiB
Plaintext
Raw Normal View History

2015-08-27 01:21:21 +03:00
::
2015-08-20 01:40:03 +03:00
::::
::
/? 314
/- work
2015-08-20 01:40:03 +03:00
/+ talk
!:
::::
::
2015-09-02 03:24:18 +03:00
[. work]
2015-08-20 01:40:03 +03:00
|%
++ move (pair bone card) :: all actions
++ card :: general card
2015-08-20 03:36:40 +03:00
$% [%diff %work-report client] ::
2015-08-20 01:40:03 +03:00
[%peer wire dock path] ::
[%poke wire dock pear] ::
== ::
++ pear :: poke fruit
2015-08-20 03:36:40 +03:00
$% [%talk-command command:talk] ::
2015-08-20 01:40:03 +03:00
== ::
--
!:
::::
::
2015-08-27 01:21:21 +03:00
|_ $: bowl
client
2015-12-14 10:58:14 +03:00
connected=$@ :: subscribed to talk
2015-09-08 23:37:20 +03:00
count=@ud :: # messages from talk
2015-08-27 01:21:21 +03:00
unordered=(map ,[@uvH @u] (pair ship flesh:work-stuff:talk))
==
2015-08-20 01:40:03 +03:00
++ at
2015-08-22 03:02:35 +03:00
|= client-task
2015-08-20 01:40:03 +03:00
=| moves=(list move)
|%
++ abet
2015-12-14 10:58:14 +03:00
^- [(list move) $+>.$]
2015-08-22 03:02:35 +03:00
[(flop moves) +>.$(tasks (~(put by tasks) id.tax +<.$))]
2015-08-21 00:00:18 +03:00
::
++ abut
2015-12-14 10:58:14 +03:00
^- [(list move) $+>.$]
2015-08-21 00:00:18 +03:00
[(flop moves) +>.$]
::
2015-08-22 03:02:35 +03:00
++ send-audience
|= [to=(set station:talk) action=duty:work-stuff:talk]
2015-08-20 01:40:03 +03:00
%_ +>.$
eny (sham eny action)
moves
2015-08-22 03:02:35 +03:00
:_ moves
2015-08-20 03:36:40 +03:00
^- move
2015-08-20 01:40:03 +03:00
:* ost %poke
2015-08-22 03:02:35 +03:00
/sending/(scot %uv id.tax)/(scot %ud version.tax)
2015-08-20 01:40:03 +03:00
[our %talk]
%talk-command
2015-09-02 03:24:18 +03:00
=> [. talk] ^- command:talk
2015-08-20 01:40:03 +03:00
:- %publish
|- ^- (list thought)
:_ ~
:+ (shaf %task eny)
2015-09-02 03:24:18 +03:00
%- mo ^- (list ,[partner envelope delivery])
2015-08-22 03:02:35 +03:00
%+ turn (~(tap in to))
2015-09-02 03:24:18 +03:00
|=(sat=station [[%& sat] [*envelope %pending]])
2015-08-20 01:40:03 +03:00
[now *bouquet [%tax action]]
==
==
2015-08-21 00:00:18 +03:00
::
2015-08-22 03:02:35 +03:00
++ send
|= action=duty:work-stuff:talk
(send-audience audience action)
::
++ send-archive
|= to=(set station:talk)
(send-audience to %archive id.tax)
2015-08-21 00:00:18 +03:00
::
2015-08-22 03:02:35 +03:00
++ send-create (send %create tax)
2015-08-27 01:21:21 +03:00
++ send-change |* *
2015-08-28 20:01:25 +03:00
?: =(our creator.tax)
(send-update +(version.tax) our +<)
2015-08-27 01:21:21 +03:00
%+ send-audience
2015-09-02 03:24:18 +03:00
[[creator.tax (main:talk creator.tax)] ~ ~]
2015-08-27 01:21:21 +03:00
[%change id.tax +<]
2015-08-22 03:02:35 +03:00
++ send-update |*(* (send %update id.tax +<))
2015-08-20 03:36:40 +03:00
++ process-update
2015-08-27 01:21:21 +03:00
|= up=update
2015-08-20 03:36:40 +03:00
^+ +>
?- -.up
2015-09-09 02:31:42 +03:00
%add ?>(?=(%comment +<.up) (send-change %add-comment our +>.up))
2015-08-27 01:34:26 +03:00
%doer
2015-08-20 03:36:40 +03:00
?- +<.up
2015-08-27 01:34:26 +03:00
%release (send-change %set-doer ~)
%claim (send-change %set-doer `our)
2015-08-20 03:36:40 +03:00
==
2015-08-27 01:21:21 +03:00
::
2015-08-20 03:36:40 +03:00
%set
?- +<.up
2015-08-28 02:50:21 +03:00
%audience (process-audience to.up)
2015-08-27 01:21:21 +03:00
%date-due (send-change %set-date-due +>.up)
%title (send-change %set-title +>.up)
%description (send-change %set-description +>.up)
%tags (send-change %set-tags +>.up)
%done (send-change %set-done +>.up)
2015-08-20 03:36:40 +03:00
==
==
2015-08-22 03:02:35 +03:00
++ process-audience
|= to=(set station:talk)
^+ +>
=. +>.$ (send-archive (~(dif in audience) to))
=. +>.$ (send-audience (~(dif in to) audience) %create tax)
+>.$(audience to)
2015-08-20 01:40:03 +03:00
--
::
2015-08-22 03:27:09 +03:00
++ prep
2015-08-27 01:21:21 +03:00
|= $= old
$_
=< $
%- unit
$: client
2015-12-14 10:58:14 +03:00
$@
2015-09-08 23:37:20 +03:00
@ud
2015-08-27 01:21:21 +03:00
(map ,[@uvH @u] (pair ship flesh:work-stuff:talk))
==
2015-12-14 10:58:14 +03:00
^- [(list move) $+>.$]
2015-08-22 03:27:09 +03:00
initialize(+<+ ?~(old +<+.+>.$ u.old))
::
2015-08-20 01:40:03 +03:00
++ initialize
^- [(list move) _.]
2015-08-22 03:27:09 +03:00
?: connected
[~ .]
2015-08-20 04:37:09 +03:00
:_ .(connected %&) :_ ~
2015-09-08 23:37:20 +03:00
[ost %peer /peering [our %talk] /f/(main:talk our)/(scot %ud count)]
2015-08-20 01:40:03 +03:00
::
++ process-duty
2015-08-20 03:36:40 +03:00
|= [when=@da her=ship from=(set station:talk) action=duty:work-stuff:talk]
2015-12-14 10:58:14 +03:00
^- [(list move) $+>.$]
2015-08-20 22:04:52 +03:00
=- =^ mof con mirror-to-web:con
2015-08-24 21:43:45 +03:00
[(welp mof mos) con]
2015-12-14 10:58:14 +03:00
^- [mos=(list move) con=$+>.$]
2015-08-20 01:40:03 +03:00
?- -.action
2015-08-22 03:02:35 +03:00
%create
=+ existing-task=(~(get by tasks) id.tax.action)
2015-08-22 03:02:35 +03:00
?: ?& ?=(^ existing-task)
!=(tax.action tax.u.existing-task)
!archived.u.existing-task
2015-08-20 03:36:40 +03:00
==
2015-08-22 03:02:35 +03:00
~& :* %new-task-with-old-id
her=her
from=from
new-task=tax.action
2015-08-22 03:02:35 +03:00
existing-task=u.existing-task
==
[~ +>.$]
2015-08-27 01:21:21 +03:00
?. =(her creator.tax.action)
~& :* %created-with-bad-creator
2015-08-21 01:57:13 +03:00
her=her
from=from
new-task=tax.action
existing-task=existing-task
==
[~ +>.$]
2015-08-20 01:40:03 +03:00
=. tasks
2015-08-22 03:02:35 +03:00
%^ ~(put by tasks) id.tax.action |
2015-08-27 01:21:21 +03:00
:_ tax.action
2015-08-20 01:40:03 +03:00
?~ existing-task from
(~(uni in audience.u.existing-task) from)
2015-08-21 00:00:18 +03:00
=. sort ?^(existing-task sort [id.tax.action sort])
2015-08-20 22:04:52 +03:00
[~ +>.$]
2015-08-22 03:02:35 +03:00
::
%archive
=+ tax=(~(get by tasks) id.action)
?~ tax
~& :* %archive-for-nonexistent-task
her=her
from=from
action=action
==
[~ +>.$]
2015-08-27 01:21:21 +03:00
?: !=(her creator.tax.u.tax)
~& :* %archiver-not-creator
2015-08-22 03:02:35 +03:00
her=her
from=from
action=action
tax=tax
==
[~ +>.$]
=. tasks
%+ ~(put by tasks) id.action
2015-08-27 01:21:21 +03:00
:* =(~ (~(dif in audience.u.tax) from))
2015-08-22 03:02:35 +03:00
(~(dif in audience.u.tax) from)
tax.u.tax
==
[~ +>.$]
2015-08-20 01:40:03 +03:00
::
2015-08-27 01:21:21 +03:00
%change
2015-08-20 01:40:03 +03:00
=+ tax=(~(get by tasks) id.action)
?~ tax
2015-08-27 01:21:21 +03:00
~& :* %change-for-nonexistent-task
2015-08-20 01:40:03 +03:00
her=her
from=from
action=action
==
2015-08-20 22:04:52 +03:00
[~ +>.$]
2015-08-27 01:21:21 +03:00
?: !=(our creator.tax.u.tax)
~& :* %me-not-creator
her=her
2015-08-20 01:40:03 +03:00
from=from
action=action
tax=tax
==
2015-08-20 22:04:52 +03:00
[~ +>.$]
2015-08-27 01:21:21 +03:00
abet:(send-update:(at u.tax) +(version.tax.u.tax) her meat.action)
::
%update
=+ tax=(~(get by tasks) id.action)
?~ tax
~& :* %update-for-nonexistent-task
her=her
from=from
action=action
==
[~ +>.$]
?: !=(her creator.tax.u.tax)
~& :* %her-not-creator
2015-08-22 03:02:35 +03:00
her=her
from=from
action=action
tax=tax
2015-08-21 00:15:02 +03:00
==
2015-08-22 03:02:35 +03:00
[~ +>.$]
2015-08-27 01:21:21 +03:00
?. =(version.action +(version.tax.u.tax))
~& :* %update-bad-version
her
from=from
action=action
tax=tax
==
2015-08-28 20:01:25 +03:00
?: (lte version.action version.tax.u.tax)
~& %really-bad-version
[~ +>.$]
2015-08-27 01:21:21 +03:00
:- ~
%_ +>.$
unordered
%+ ~(put by unordered)
[id.action version.action]
[her.action meat.action]
==
|-
2015-08-22 03:02:35 +03:00
=. tasks
%+ ~(put by tasks) id.action
2015-08-27 01:21:21 +03:00
:+ archived.u.tax
(~(uni in audience.u.tax) from)
=. version.tax.u.tax version.action
=. date-modified.tax.u.tax when
?- -.meat.action
%set-doer tax.u.tax(doer her.meat.action)
%set-date-due tax.u.tax(date-due wen.meat.action)
%set-tags tax.u.tax(tags tag.meat.action)
%set-title tax.u.tax(title til.meat.action)
%set-description tax.u.tax(description des.meat.action)
%set-done tax.u.tax(done ?.(don.meat.action ~ `when))
%add-comment
%= tax.u.tax
2015-09-09 02:31:42 +03:00
discussion [[when [who com]:meat.action] discussion.tax.u.tax]
2015-08-21 00:15:02 +03:00
==
==
2015-08-27 01:21:21 +03:00
=+ ooo=(~(get by unordered) id.action +(version.action))
?~ ooo
[~ +>.^$]
%= $
version.action +(version.action)
her.action p.u.ooo
meat.action q.u.ooo
==
2015-08-20 01:40:03 +03:00
==
::
++ mirror-to-web
^- [(list move) _.]
~& [%mirroring sort=(turn sort |=(a=@uv `@uv`(rsh 2 25 a)))]
2015-08-20 01:40:03 +03:00
:_ .
2015-08-20 04:37:09 +03:00
%+ murn (~(tap by sup))
|= [ust=bone her=ship pax=path]
^- (unit move)
2015-08-21 03:03:19 +03:00
?:(?=([%sole *] pax) ~ `[ust full-report])
2015-08-20 04:37:09 +03:00
::
2015-08-21 01:49:21 +03:00
++ full-report [%diff %work-report tasks sort]
++ peer-repo |=(path [[ost full-report]~ +>.$])
2015-08-20 04:37:09 +03:00
++ coup
|= [way=wire saw=(unit tang)]
2015-12-14 10:58:14 +03:00
^- [(list move) $+>.$]
2015-08-20 04:37:09 +03:00
?> ?=(~ saw)
[~ +>.$]
2015-08-20 01:40:03 +03:00
::
2015-10-16 00:05:18 +03:00
++ quit-peering |=(way=wire ?>(?=(~ way) initialize(connected |)))
2015-08-20 01:40:03 +03:00
++ reap-peering
|= [way=wire saw=(unit tang)]
2015-12-14 10:58:14 +03:00
^- [(list move) $+>.$]
2015-08-20 01:40:03 +03:00
?> ?=([~ ~] +<)
[~ +>.$]
::
2015-08-20 03:36:40 +03:00
++ poke-work-command
|= cod=command
2015-08-21 02:12:06 +03:00
?. =(our src)
~|([%wrong-user our=our src=src] !!)
2015-08-22 03:27:09 +03:00
?- -.cod
%sort mirror-to-web(sort p.cod)
2015-08-28 02:50:21 +03:00
%old
2015-08-22 03:27:09 +03:00
=^ mow +>.$
2015-08-28 02:50:21 +03:00
=+ (at (~(got by tasks) id.cod))
abet:(process-update:- dif.cod)
2015-08-22 03:27:09 +03:00
=^ mov +>.$ mirror-to-web
2015-08-24 21:43:45 +03:00
[(welp mov mow) +>.$]
2015-08-22 03:27:09 +03:00
%new
=. +>.cod +>.cod(date-created now, version 0, date-modified now)
2015-08-27 01:21:21 +03:00
abut:send-create:(at | +.cod)
2015-08-22 03:27:09 +03:00
==
2015-08-20 03:36:40 +03:00
::
2015-09-08 23:37:20 +03:00
:: XX test the disconnection case
2015-08-20 04:37:09 +03:00
++ diff-talk-report
|= [way=wire rep=report:talk]
2015-12-14 10:58:14 +03:00
^- [(list move) $+>.$]
2015-08-20 01:40:03 +03:00
?> ?=(%grams -.rep)
2015-12-14 10:58:14 +03:00
|- ^- [(list move) $+>.^$]
2015-08-20 01:40:03 +03:00
?~ q.rep [~ +>.^$]
2015-09-08 23:37:20 +03:00
=. count +(count)
2015-08-20 01:40:03 +03:00
=* her p.i.q.rep
=* when p.r.q.i.q.rep
=* said r.r.q.i.q.rep
2015-09-08 23:37:20 +03:00
?. ?=(%tax -.said)
$(p.rep +(p.rep), q.rep t.q.rep)
2015-08-20 03:36:40 +03:00
=+ ^- from=(set station:talk)
%- sa ^- (list station:talk)
2015-08-20 01:40:03 +03:00
%+ murn (~(tap by q.q.i.q.rep))
2015-09-02 03:24:18 +03:00
=> talk
2015-08-20 03:36:40 +03:00
|= [par=partner *]
2015-09-02 03:24:18 +03:00
`(unit station)`?.(?=(%& -.par) ~ `p.par)
2015-08-20 03:36:40 +03:00
=^ mos +>.^$ (process-duty when her from +.said)
2015-08-20 01:40:03 +03:00
=^ mof +>.^$ $(p.rep +(p.rep), q.rep t.q.rep)
[(weld mos mof) +>.^$]
--