Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
93 changes: 76 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
=/ title=@t
?: =('' group-title) 'a Groupchat'
group-title
%- crip
?: |(?=(~ nickname) =('' u.nickname))
"Tlon Messenger: You're Invited to {(trip title)}"
"Tlon Messenger: {(trip u.nickname)} invited you to {(trip title)}"
--
|_ =bowl:gall
+* this .
Expand Down Expand Up @@ -230,6 +243,65 @@
[%'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 take priority.
::
Comment thread
arthyn marked this conversation as resolved.
=/ type=(unit @t) (~(get by fields.metadata) %'inviteType')
=? fields.metadata |(?=(~ type) =('group' u.type))
=* fields fields.metadata
:: treat absent or empty-string fields as gap-fillable
::
=* is-blank
|= k=field:reel
^- ?
=/ v (~(get by fields) k)
?|(?=(~ v) =('' u.v))
:: 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)
=? fields
?& ?=(^ nickname)
!=('' u.nickname)
(is-blank %'inviterNickname')
==
(~(put by fields) %'inviterNickname' u.nickname)
=? fields
?& ?=(^ avatar)
!=('' u.avatar)
(is-blank %'inviterAvatarImage')
==
(~(put by fields) %'inviterAvatarImage' u.avatar)
:: group meta from %groups; only attempt when id parses as a flag
:: and the group exists locally.
::
?~ parsed=(rush id flag) fields
=/ base /(scot %p our.bowl)/groups/(scot %da now.bowl)
?. .^(? %gu (weld base /groups/(scot %p -.u.parsed)/[+.u.parsed]))
fields
=/ grp=group:v9:groups-ver
.^ group:v9:groups-ver %gx
(weld base /v2/groups/(scot %p -.u.parsed)/[+.u.parsed]/group-2)
==
=* meta meta.grp
=? fields
?& !=('' title.meta)
(is-blank %'invitedGroupTitle')
==
(~(put by fields) %'invitedGroupTitle' title.meta)
=? fields
?& !=('' description.meta)
(is-blank %'invitedGroupDescription')
==
(~(put by fields) %'invitedGroupDescription' description.meta)
=? fields
?& !=('' image.meta)
(is-blank %'invitedGroupIconImageUrl')
==
(~(put by fields) %'invitedGroupIconImageUrl' image.meta)
fields
:: 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 +466,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 +513,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
17 changes: 15 additions & 2 deletions desk/tests/app/reel.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@
%- ~(gas by *contact:t)
:~ %nickname^text+'Sampel Palnet'
==
::
++ 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 +144,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 +197,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 +226,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 +306,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