mirror of
https://github.com/urbit/shrub.git
synced 2025-01-03 01:54:43 +03:00
metadata-store, observe-hook, threads: auto-joining group feeds works for groups you're already a part of, and so does group feed creation
This commit is contained in:
parent
6d88c471bc
commit
b58e30fba7
@ -283,7 +283,9 @@
|
||||
?. ?=(%initial-group -.update) jn-core
|
||||
?. =(group.update rid) jn-core
|
||||
=. jn-core (cleanup %done)
|
||||
?. hidden:(need (scry-group:grp rid)) jn-core
|
||||
?. hidden:(need (scry-group:grp rid))
|
||||
:: TODO: join group feed if one is present
|
||||
jn-core
|
||||
%- emit-many
|
||||
%+ murn ~(tap by associations.update)
|
||||
|= [=md-resource:metadata =association:metadata]
|
||||
|
@ -272,6 +272,7 @@
|
||||
date-created date-created.m
|
||||
creator creator.m
|
||||
preview preview.m
|
||||
hidden %|
|
||||
::
|
||||
config
|
||||
?: =(module.m %$)
|
||||
|
@ -12,6 +12,8 @@
|
||||
$% [%0 observers=(map serial observer:sur)]
|
||||
[%1 observers=(map serial observer:sur)]
|
||||
[%2 observers=(map serial observer:sur)]
|
||||
[%3 observers=(map serial observer:sur)]
|
||||
[%4 observers=(map serial observer:sur)]
|
||||
==
|
||||
::
|
||||
+$ serial @uv
|
||||
@ -25,7 +27,7 @@
|
||||
--
|
||||
::
|
||||
%- agent:dbug
|
||||
=| [%2 observers=(map serial observer:sur)]
|
||||
=| [%4 observers=(map serial observer:sur)]
|
||||
=* state -
|
||||
::
|
||||
^- agent:gall
|
||||
@ -39,6 +41,7 @@
|
||||
:~ (act [%watch %invite-store /invitatory/graph %invite-accepted-graph])
|
||||
(act [%watch %group-store /groups %group-on-leave])
|
||||
(act [%watch %group-store /groups %group-on-remove-member])
|
||||
(act [%watch %metadata-store /updates %md-on-add-group-feed])
|
||||
==
|
||||
::
|
||||
++ act
|
||||
@ -50,8 +53,7 @@
|
||||
[our.bowl %observe-hook]
|
||||
%poke
|
||||
%observe-action
|
||||
!> ^- action:sur
|
||||
action
|
||||
!>(action)
|
||||
==
|
||||
--
|
||||
::
|
||||
@ -63,20 +65,31 @@
|
||||
=/ old-state !<(versioned-state old-vase)
|
||||
=| cards=(list card)
|
||||
|-
|
||||
?: ?=(%2 -.old-state)
|
||||
=. cards
|
||||
:_ cards
|
||||
(act [%watch %group-store /groups %group-on-leave])
|
||||
?- -.old-state
|
||||
%4
|
||||
[cards this(state old-state)]
|
||||
?: ?=(%1 -.old-state)
|
||||
::
|
||||
%3
|
||||
=. cards
|
||||
:_ cards
|
||||
(act [%watch %metadata-store /updates %md-on-add-group-feed])
|
||||
$(-.old-state %4)
|
||||
::
|
||||
%2
|
||||
=. cards
|
||||
:_ cards
|
||||
(act [%watch %group-store /groups %group-on-leave])
|
||||
$(-.old-state %3)
|
||||
::
|
||||
%1
|
||||
$(-.old-state %2)
|
||||
=. cards
|
||||
:_ cards
|
||||
(act [%watch %group-store /groups %group-on-remove-member])
|
||||
$(-.old-state %1)
|
||||
::
|
||||
%0
|
||||
=. cards
|
||||
:_ cards
|
||||
(act [%watch %group-store /groups %group-on-remove-member])
|
||||
$(-.old-state %1)
|
||||
==
|
||||
::
|
||||
++ act
|
||||
|= =action:sur
|
||||
@ -87,8 +100,7 @@
|
||||
[our.bowl %observe-hook]
|
||||
%poke
|
||||
%observe-action
|
||||
!> ^- action:sur
|
||||
action
|
||||
!>(action)
|
||||
==
|
||||
--
|
||||
::
|
||||
|
@ -43,6 +43,7 @@
|
||||
[%forward rid=resource =update:store]
|
||||
[%eval =cord]
|
||||
[%pending-indices pending=(map hash:store index:store)]
|
||||
[%create-group-feed group=resource]
|
||||
==
|
||||
--
|
||||
|
||||
|
@ -44,6 +44,7 @@
|
||||
config=md-config
|
||||
picture=url
|
||||
preview=?
|
||||
hidden=?
|
||||
vip=vip-metadata
|
||||
==
|
||||
::
|
||||
|
69
pkg/arvo/ted/graph/create-group-feed.hoon
Normal file
69
pkg/arvo/ted/graph/create-group-feed.hoon
Normal file
@ -0,0 +1,69 @@
|
||||
/- spider,
|
||||
graph=graph-store,
|
||||
met=metadata-store,
|
||||
push-hook
|
||||
/+ strandio, resource, graph-view
|
||||
::
|
||||
=* strand strand:spider
|
||||
=* poke poke:strandio
|
||||
=* poke-our poke-our:strandio
|
||||
::
|
||||
^- thread:spider
|
||||
|= arg=vase
|
||||
=/ m (strand ,vase)
|
||||
^- form:m
|
||||
=+ !<([~ =action:graph-view] arg)
|
||||
?> ?=(%create-group-feed -.action)
|
||||
;< =bowl:spider bind:m get-bowl:strandio
|
||||
?. =(our.bowl entity.group.action)
|
||||
(strand-fail:strandio %bad-request ~)
|
||||
=/ feed-rid=resource
|
||||
:- entity.group.action
|
||||
%- crip
|
||||
%+ weld (trip name.group.action)
|
||||
%+ weld "-"
|
||||
(trip (scot %ud (mod eny.bowl 10.000)))
|
||||
;< metadatum=(unit metadatum:met) bind:m
|
||||
%+ scry:strandio (unit metadatum:met)
|
||||
%- zing
|
||||
:~ /gx/metadata-store/metadata/group
|
||||
(en-path:resource group.action)
|
||||
/noun
|
||||
==
|
||||
?~ metadatum
|
||||
~|('No group exists, cannot make group feed.' !!)
|
||||
?> ?=(%group -.config.u.metadatum)
|
||||
?> ?| ?=(~ feed.config.u.metadatum)
|
||||
?=([~ ~] feed.config.u.metadatum)
|
||||
==
|
||||
;< ~ bind:m
|
||||
%+ poke-our %graph-store
|
||||
:- %graph-update
|
||||
!> ^- update:graph
|
||||
[%0 now.bowl %add-graph feed-rid *graph:graph `%graph-validator-post %&]
|
||||
;< ~ bind:m
|
||||
(poke-our %graph-push-hook %push-hook-action !>([%add feed-rid]))
|
||||
;< ~ bind:m
|
||||
%+ poke-our %metadata-push-hook
|
||||
:- %metadata-update
|
||||
!> ^- action:met
|
||||
:^ %add
|
||||
group.action
|
||||
group+group.action
|
||||
u.metadatum(feed.config ``[%graph feed-rid])
|
||||
;< ~ bind:m
|
||||
%+ poke-our %metadata-push-hook
|
||||
:- %metadata-update
|
||||
!> ^- action:met
|
||||
:^ %add
|
||||
group.action
|
||||
graph+feed-rid
|
||||
%* . *metadatum:met
|
||||
title 'Group Feed'
|
||||
date-created now.bowl
|
||||
creator our.bowl
|
||||
config [%graph %post]
|
||||
preview %.n
|
||||
hidden %.y
|
||||
==
|
||||
(pure:m !>(~))
|
31
pkg/arvo/ted/md/on-add-group-feed.hoon
Normal file
31
pkg/arvo/ted/md/on-add-group-feed.hoon
Normal file
@ -0,0 +1,31 @@
|
||||
/- spider, graph-view, met=metadata-store
|
||||
/+ strandio
|
||||
::
|
||||
=* strand strand:spider
|
||||
=* poke-our poke-our:strandio
|
||||
::
|
||||
^- thread:spider
|
||||
|= arg=vase
|
||||
=/ m (strand ,vase)
|
||||
^- form:m
|
||||
=+ !<([~ =update:met] arg)
|
||||
?. ?=(%add -.update)
|
||||
(pure:m !>(~))
|
||||
;< =bowl:spider bind:m get-bowl:strandio
|
||||
?: =(our.bowl entity.group.update)
|
||||
(pure:m !>(~))
|
||||
?. ?=(%group -.config.metadatum.update)
|
||||
(pure:m !>(~))
|
||||
?~ feed.config.metadatum.update
|
||||
(pure:m !>(~))
|
||||
?~ u.feed.config.metadatum.update
|
||||
(pure:m !>(~))
|
||||
=* feed u.u.feed.config.metadatum.update
|
||||
;< ~ bind:m
|
||||
%+ poke-our %spider
|
||||
=- spider-start+!>([`tid.bowl ~ %graph-join -])
|
||||
%+ slop !>(~)
|
||||
!> ^- action:graph-view
|
||||
[%join resource.feed entity.resource.feed]
|
||||
(pure:m !>(~))
|
||||
|
Loading…
Reference in New Issue
Block a user