Skip to content
This repository has been archived by the owner on Aug 14, 2019. It is now read-only.

Commit

Permalink
style changes for tiebout
Browse files Browse the repository at this point in the history
  • Loading branch information
tacryt-socryp committed Feb 28, 2019
1 parent ac66d9a commit cf0b409
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 129 deletions.
142 changes: 79 additions & 63 deletions app/tiebout.hoon
Original file line number Diff line number Diff line change
@@ -1,15 +1,50 @@
::
:::: /app/tiebout/hoon
::
/? 309
/- hall
/+ tiebout
/- hall, tiebout
=, tiebout
=, eyre
|%
+$ move [bone card]
::
+$ card
$% [%poke wire dock poke]
[%peer wire dock path]
[%pull wire dock ~]
[%diff diff]
[%hiss wire [~ ~] %httr %hiss hiss]
==
::
+$ diff
$% [%hall-rumor rumor:hall]
[%tiebout-action action]
==
::
+$ poke
$% [%tiebout-action action]
==
::
+$ state
$% [%0 tiebout-zero]
==
::
+$ tiebout-zero
$:
:: iOS device token
::
token=@t
:: ship that routes notifications to Apple
::
king=@p
:: url of Apple server to send notifications to
::
baseurl=@t
:: name and last read
::
circles=(map name:hall @)
==
::
--
::
:: state:
::
~% %tiebout ..^is ~
|_ [bol=bowl:gall sta=state]
::
:: +this: app core subject
Expand All @@ -24,8 +59,8 @@
?~ old
:- ~
%= this
king.tie.sta ~dopzod
baseurl.tie.sta 'https://api.push.apple.com/3/device/'
king.sta ~dabben-larbet
baseurl.sta 'https://api.push.apple.com/3/device/'
==
?- -.u.old
%0
Expand Down Expand Up @@ -54,63 +89,57 @@
|= act=action
^- (quip move _this)
?- -.act
$king
(set-king +.act)
$token
(set-token +.act)
$baseurl
(set-baseurl +.act)
$add-circle
(add-circle +.act)
$del-circle
(del-circle +.act)
$notify
(send-notify +.act)
$king (set-king +.act)
$token (set-token +.act)
$baseurl (set-baseurl +.act)
$add-circle (add-circle +.act)
$del-circle (del-circle +.act)
$notify (send-notify +.act)
==
::
:: +add-circle: add circle and subscribe for updates
::
++ add-circle
|= nom=name:hall
^- (quip move _this)
:_ this(circles.tie.sta (~(put by circles.tie.sta) nom 0))
:_ this(circles.sta (~(put by circles.sta) nom 0))
[ost.bol %peer /our/[nom] [our.bol %hall] /circle/[nom]/config/grams]~
::
:: +del-circle: delete circle and unsubscribe from updates
::
++ del-circle
|= nom=name:hall
^- (quip move _this)
:_ this(circles.tie.sta (~(del by circles.tie.sta) nom))
:_ this(circles.sta (~(del by circles.sta) nom))
[ost.bol %pull /our/[nom] [our.bol %hall] ~]~
::
:: +set-king: set king @p
::
++ set-king
|= kng=@p
^- (quip move _this)
[~ this(king.tie.sta kng)]
[~ this(king.sta kng)]
::
:: +set-token: set iOS device token @t
::
++ set-token
|= tok=@t
^- (quip move _this)
[~ this(token.tie.sta tok)]
[~ this(token.sta tok)]
::
:: +set-baseurl: set base url @t
::
++ set-baseurl
|= burl=@t
^- (quip move _this)
[~ this(baseurl.tie.sta burl)]
[~ this(baseurl.sta burl)]
::
:: +send-notify: if king, send hiss. if not, do nothing.
::
++ send-notify
|= not=notification
^- (quip move _this)
?: =(king.tie.sta our.bol)
?: =(king.sta our.bol)
:_ this
[ost.bol %hiss /request [~ ~] %httr %hiss (create-apns-request not)]~
[~ this]
Expand All @@ -120,9 +149,6 @@
++ diff-hall-prize
|= [wir=wire piz=prize:hall]
^- (quip move _this)
~& prize+[wir piz]
?~ wir
(mean [leaf+"invalid wire for diff: {(spud wir)}"]~)
?+ wir
(mean [leaf+"invalid wire for diff: {(spud wir)}"]~)
::
Expand All @@ -133,38 +159,33 @@
?> ?=(%circle -.piz)
=/ nom/name:hall i.t.wir
=/ red/@ud red.loc.cos.piz
[~ this(circles.tie.sta (~(put by circles.tie.sta) nom red))]
[~ this(circles.sta (~(put by circles.sta) nom red))]
==
::
:: +reap: recieve acknowledgement for peer
::
++ reap
|= [wir=wire err=(unit tang)]
^- (quip move _this)
::~& reap+[wir =(~ err)]
?~ err
:: XX send message to users inbox
[~ this]
?~ wir
(mean [leaf+"invalid wire for diff: {(spud wir)}"]~)
?+ i.wir
?+ wir
(mean [leaf+"invalid wire for diff: {(spud wir)}"]~)
%our
::
{%our @ @}
?< ?=(~ t.wir)
:_ this
~
[~ this]
==
::
:: +quit: receive subscription failed, resubscribe
::
++ quit
|= wir=wire
^- (quip move _this)
?~ wir
(mean [leaf+"invalid wire for diff: {(spud wir)}"]~)
?+ i.wir
?+ wir
(mean [leaf+"invalid wire for diff: {(spud wir)}"]~)
%our
::
{%our @ @}
?< ?=(~ t.wir)
:_ this
=/ doc/dock [our.bol %hall]
Expand All @@ -177,9 +198,6 @@
++ diff-hall-rumor
|= [wir=wire rum=rumor:hall]
^- (quip move _this)
::~& rumor+[wir rum]
?~ wir
(mean [leaf+"invalid wire for diff: {(spud wir)}"]~)
?+ wir
(mean [leaf+"invalid wire for diff: {(spud wir)}"]~)
::
Expand All @@ -194,44 +212,41 @@
:: %gram: send notification if envelope is lower than read number
::
%gram
=/ red (~(get by circles.tie.sta) nom)
=/ red (~(get by circles.sta) nom)
?~ red
(mean [leaf+"invalid circle for diff: {(spud wir)}"]~)
?: (gth num.nev.rum.rum u.red)
:_ this(circles.tie.sta (~(put by circles.tie.sta) nom u.red))
(message-to-notification u.red nev.rum.rum)
:_ this(circles.sta (~(put by circles.sta) nom u.red))
(conditional-msg-to-not u.red nev.rum.rum)
:_ this
(message-to-notification u.red nev.rum.rum)
(conditional-msg-to-not u.red nev.rum.rum)
::
:: %config: set our read number
::
%config
?+ -.dif.rum.rum
[~ this]
%read
=/ red/@ud red.dif.rum.rum
[~ this(circles.tie.sta (~(put by circles.tie.sta) nom red))]
==
::
%read
[~ this(circles.sta (~(put by circles.sta) nom red.dif.rum.rum))]
==
==
==
::
:: generate notification move from hall message
:: generate notification move from hall message if conditions are met
::
++ message-to-notification
++ conditional-msg-to-not
|= [red=@ud env=envelope:hall]
^- (list move)
?: =(aut.gam.env our.bol)
~
=/ pay %- my :~
alert+s+'New message from {(cite:title aut.gam.env)}'
==
=/ not/notification :+
token.tie.sta
'com.tlon.urbit-client'
pay
=/ not/notification [token.sta 'com.tlon.urbit-client' pay]
?: (lte num.env red)
~
=/ doc/dock [king.tie.sta dap.bol]
=/ doc/dock [king.sta dap.bol]
[ost.bol %poke /ask-king doc %tiebout-action [%notify not]]~

::
Expand All @@ -240,9 +255,10 @@
++ create-apns-request
|= not=notification
^- hiss
=/ furl=@t (crip (weld (trip baseurl.tie.sta) (trip token.not)))
=/ furl=@t (crip (weld (trip baseurl.sta) (trip token.not)))
=/ url=purl (need (de-purl:html furl))
=/ jon=json :- %o %- my :~
=/ jon=json :- %o
%- my :~
aps+o+payload.not
==
:^ url %post
Expand Down
58 changes: 0 additions & 58 deletions lib/tiebout.hoon

This file was deleted.

9 changes: 1 addition & 8 deletions mar/tiebout-action.hoon
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
::
:::: /hoon/actions/collection/mar
::
/? 309
/- hall
/+ tiebout
=, tiebout
/- hall, tiebout
=, format
::
|_ act=action:tiebout
Expand All @@ -20,7 +14,6 @@
++ json
|= jon=^json
^- action:tiebout
%- (hard action:tiebout)
=< (action jon)
|%
++ action
Expand Down
21 changes: 21 additions & 0 deletions sur/tiebout.hoon
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/- hall
=, eyre
::
::
|%
+$ notification
$: token=@t
topic=@t
payload=(map @t json)
==
::
+$ action
$% [%token tok=@t] :: set device token
[%king kng=@p] :: set ship to route notifications through
[%baseurl bur=@t] :: set url to send notifications to
[%notify not=notification] :: send notification
[%add-circle nom=name:hall] :: send notifications for this circle
[%del-circle nom=name:hall] :: stop sending for this circle
==
::
--

0 comments on commit cf0b409

Please sign in to comment.