From cf0b409db742a40e686338a281670f1eb50b4988 Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Thu, 28 Feb 2019 13:20:39 -0800 Subject: [PATCH] style changes for tiebout --- app/tiebout.hoon | 142 ++++++++++++++++++++++------------------ lib/tiebout.hoon | 58 ---------------- mar/tiebout-action.hoon | 9 +-- sur/tiebout.hoon | 21 ++++++ 4 files changed, 101 insertions(+), 129 deletions(-) delete mode 100644 lib/tiebout.hoon create mode 100644 sur/tiebout.hoon diff --git a/app/tiebout.hoon b/app/tiebout.hoon index 7f72ccd91..db93115a1 100644 --- a/app/tiebout.hoon +++ b/app/tiebout.hoon @@ -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 @@ -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 @@ -54,18 +89,12 @@ |= 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 @@ -73,7 +102,7 @@ ++ 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 @@ -81,7 +110,7 @@ ++ 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 @@ -89,28 +118,28 @@ ++ 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] @@ -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)}"]~) :: @@ -133,7 +159,7 @@ ?> ?=(%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 @@ -141,18 +167,14 @@ ++ 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 @@ -160,11 +182,10 @@ ++ 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] @@ -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)}"]~) :: @@ -194,30 +212,30 @@ :: %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) @@ -225,13 +243,10 @@ =/ 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]]~ :: @@ -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 diff --git a/lib/tiebout.hoon b/lib/tiebout.hoon deleted file mode 100644 index efee2e95f..000000000 --- a/lib/tiebout.hoon +++ /dev/null @@ -1,58 +0,0 @@ -:: -:::: /lib/tiebout/hoon - :: -/? 309 -/- hall -=, eyre -:: -~% %tiebout-lib ..is ~ -|% -+$ 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 tie=tiebout-zero] - == -:: -+$ tiebout-zero - $: - token=@t - king=@p - baseurl=@t - :: name and last read - :: - circles=(map name:hall @) - == -:: -+$ notification - $: token=@t - topic=@t - payload=(map @t json) - == -:: -+$ action - $% [%token tok=@t] - [%king kng=@p] - [%baseurl bur=@t] - [%notify not=notification] - [%add-circle nom=name:hall] - [%del-circle nom=name:hall] - == -:: --- diff --git a/mar/tiebout-action.hoon b/mar/tiebout-action.hoon index 8b24c9b85..f8ce537ee 100644 --- a/mar/tiebout-action.hoon +++ b/mar/tiebout-action.hoon @@ -1,10 +1,4 @@ -:: -:::: /hoon/actions/collection/mar - :: -/? 309 -/- hall -/+ tiebout -=, tiebout +/- hall, tiebout =, format :: |_ act=action:tiebout @@ -20,7 +14,6 @@ ++ json |= jon=^json ^- action:tiebout - %- (hard action:tiebout) =< (action jon) |% ++ action diff --git a/sur/tiebout.hoon b/sur/tiebout.hoon new file mode 100644 index 000000000..af302489e --- /dev/null +++ b/sur/tiebout.hoon @@ -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 + == +:: +--