Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 77 additions & 17 deletions desk/app/reel.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,19 @@
|* [caz=(list card) etc=*]
[[cad caz] etc]
--
:: +group-og-title: render the open-graph title for a group invite.
:: empty group title falls back to "a Groupchat".
::
++ group-og-title
|= [nickname=(unit @t) group-title=@t]
^- @t
=/ gt=@t
?: =('' group-title) 'a Groupchat'
group-title
%- crip
?: |(?=(~ nickname) =('' u.nickname))
"Tlon Messenger: You're Invited to {(trip gt)}"
"Tlon Messenger: {(trip u.nickname)} invited you to {(trip gt)}"
Comment thread
arthyn marked this conversation as resolved.
Outdated
--
|_ =bowl:gall
+* this .
Expand Down Expand Up @@ -230,6 +243,66 @@
[%'inviterUserId' (scot %p src.bowl)]
[%'invitedGroupId' id]
==
:: gap-fill open-graph metadata from server state when the caller
:: didn't provide it: title / description / image from %groups,
:: and nickname / avatar from our cached profile. Caller-provided
:: values always win.
::
Comment thread
arthyn marked this conversation as resolved.
=/ type=(unit @t) (~(get by fields.metadata) %'inviteType')
=? fields.metadata |(?=(~ type) =('group' u.type))
=/ fld fields.metadata
Comment thread
arthyn marked this conversation as resolved.
Outdated
:: treat absent or empty-string fields as gap-fillable.
Comment thread
arthyn marked this conversation as resolved.
Outdated
::
=/ blank
|= [m=(map cord cord) k=cord]
^- ?
=/ v (~(get by m) k)
?|(?=(~ v) =('' u.v))
Comment thread
arthyn marked this conversation as resolved.
Outdated
:: inviter fields from our-profile
::
=/ nickname=(unit @t) (~(get cy:t our-profile) %nickname %text)
=/ avatar=(unit @t) (~(get cy:t our-profile) %avatar %look)
=? fld
?& ?=(^ nickname)
!=('' u.nickname)
(blank fld %'inviterNickname')
==
(~(put by fld) %'inviterNickname' u.nickname)
=? fld
?& ?=(^ avatar)
!=('' u.avatar)
(blank fld %'inviterAvatarImage')
==
(~(put by fld) %'inviterAvatarImage' u.avatar)
:: group meta from %groups; only attempt when id parses as a flag
:: and the group exists locally.
::
=/ parsed=(unit flag:v0:groups-ver) (rush id flag)
?~ parsed fld
Comment thread
arthyn marked this conversation as resolved.
Outdated
=/ base /(scot %p our.bowl)/groups/(scot %da now.bowl)
?. .^(? %gu (weld base /groups/(scot %p p.u.parsed)/[q.u.parsed]))
fld
=/ grp=group:v9:groups-ver
.^ group:v9:groups-ver %gx
(weld base /v2/groups/(scot %p p.u.parsed)/[q.u.parsed]/group-2)
==
=* gmeta meta.grp
Comment thread
arthyn marked this conversation as resolved.
Outdated
=? fld
?& !=('' title.gmeta)
(blank fld %'invitedGroupTitle')
==
(~(put by fld) %'invitedGroupTitle' title.gmeta)
=? fld
?& !=('' description.gmeta)
(blank fld %'invitedGroupDescription')
==
(~(put by fld) %'invitedGroupDescription' description.gmeta)
=? fld
?& !=('' image.gmeta)
(blank fld %'invitedGroupIconImageUrl')
==
(~(put by fld) %'invitedGroupIconImageUrl' image.gmeta)
fld
:: the nonce here is a temporary identifier for the metadata.
:: a new one will be assigned by the bait provider and returned to us.
::
Expand Down Expand Up @@ -394,16 +467,9 @@
::
=+ type=(~(get by fields.meta) %'inviteType')
?: |(?=(~ type) =('group' u.type))
=/ group-title=@t
=+ til=(~(get by fields.meta) %'invitedGroupTitle')
?: |(?=(~ til) =('' u.til))
'a Groupchat'
u.til
=/ title=@t
%- crip
?: |(?=(~ nickname) =('' u.nickname))
"Tlon Messenger: You're Invited to a Groupchat"
"Tlon Messenger: {(trip u.nickname)} invited you to {(trip group-title)}"
%+ group-og-title nickname
(fall (~(get by fields.meta) %'invitedGroupTitle') '')
=. fields.update
(~(put by fields.update) %'$og_title' title)
=. fields.update
Expand Down Expand Up @@ -448,15 +514,9 @@
?+ -.r-group.r-groups ~
%meta
=* meta meta.r-group.r-groups
=+ nickname=(~(get cy:t our-profile) %nickname %text)
=/ group-title=@t
?: =('' title.meta) 'a Groupchat'
title.meta
=/ title=@t
%- crip
?: |(?=(~ nickname) =('' u.nickname))
"Tlon Messenger: You're Invited to a Groupchat"
"Tlon Messenger: {(trip u.nickname)} invited you to {(trip group-title)}"
%- group-og-title
[(~(get cy:t our-profile) %nickname %text) title.meta]
%- ~(gas by *(map field:reel cord))
:~ %'invitedGroupTitle'^title.meta
%'invitedGroupDescription'^description.meta
Expand Down
21 changes: 19 additions & 2 deletions desk/tests/app/reel.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,20 @@
%- ~(gas by *contact:t)
:~ %nickname^text+'Sampel Palnet'
==
:: scry mock for the gap-fill path in %reel-describe. the %gu check
:: reports the group as present so the %gx fetch proceeds; the %gx
:: returns an empty group so the agent's gap-fill checks
:: (!=('' title.gmeta) etc.) all fall through and no fields are added.
::
Comment thread
arthyn marked this conversation as resolved.
Outdated
++ scry
|= =(pole knot)
?+ pole ~|(`path`pole !!)
[%gu @ %groups @ %groups host=@ term=@ ~]
`!>(&)
::
[%gx @ %groups @ %v2 %groups host=@ term=@ %group-2 ~]
`!>(*group:v9:gv)
==
++ do-register-invite
|= [=token:reel =metadata:reel]
=/ m (mare ,(list card))
Expand Down Expand Up @@ -134,6 +148,7 @@
^- form:m
;< * bind:m (do-init dap reel-agent)
;< ~ bind:m (jab-bowl |=(=bowl bowl(now ~2025.9.3, our ~sampel-palnet)))
;< ~ bind:m (set-scry-gate scry)
:: a group invite can be requested from reel
::
=/ =nonce:reel (scot %da ~2025.9.3)
Expand Down Expand Up @@ -186,6 +201,7 @@
^- form:m
;< ~ bind:m (jab-bowl |=(=bowl bowl(our ~sampel-palnet)))
;< caz=(list card) bind:m (do-init dap reel-agent)
;< ~ bind:m (set-scry-gate scry)
;< * bind:m (do-agent /contacts [~sampel-palnet %contacts] %watch-ack ~)
;< * bind:m (do-agent /groups [~sampel-palnet %groups] %watch-ack ~)
;< * bind:m (do-register-invite ~.0v1 group-invite-meta)
Expand Down Expand Up @@ -214,8 +230,8 @@
:~ %'invitedGroupTitle'^'Early Sunrise'
%'invitedGroupDescription'^'Sunrise, sunset.'
%'invitedGroupIconImageUrl'^'https://sampel-palnet.arvo.network/early-sunrise.jpg'
%'$og_title'^'Tlon Messenger: You\'re Invited to a Groupchat'
%'$twitter_title'^'Tlon Messenger: You\'re Invited to a Groupchat'
%'$og_title'^'Tlon Messenger: You\'re Invited to Early Sunrise'
%'$twitter_title'^'Tlon Messenger: You\'re Invited to Early Sunrise'
==
;< ~ bind:m
%+ ex-cards caz
Expand Down Expand Up @@ -294,6 +310,7 @@
^- form:m
;< ~ bind:m (jab-bowl |=(=bowl bowl(our ~sampel-palnet)))
;< caz=(list card) bind:m (do-init dap reel-agent)
;< ~ bind:m (set-scry-gate scry)
;< * bind:m (do-agent /contacts [~sampel-palnet %contacts] %watch-ack ~)
;< * bind:m (do-register-invite ~.0v1 group-invite-meta)
;< * bind:m (do-register-invite ~.0v2 personal-invite-meta)
Expand Down
Loading