diff --git a/keyserver/src/responders/website-responders.js b/keyserver/src/responders/website-responders.js --- a/keyserver/src/responders/website-responders.js +++ b/keyserver/src/responders/website-responders.js @@ -27,6 +27,7 @@ import { defaultWebEnabledApps } from 'lib/types/enabled-apps.js'; import { entryStoreValidator } from 'lib/types/entry-types.js'; import { defaultCalendarFilters } from 'lib/types/filter-types.js'; +import { inviteLinksStoreValidator } from 'lib/types/link-types.js'; import { defaultNumberPerThread, messageStoreValidator, @@ -51,6 +52,7 @@ import { navInfoFromURL } from 'web/url-utils.js'; import { fetchEntryInfos } from '../fetchers/entry-fetchers.js'; +import { fetchPrimaryInviteLinks } from '../fetchers/link-fetchers.js'; import { fetchMessageInfos } from '../fetchers/message-fetchers.js'; import { hasAnyNotAcknowledgedPolicies } from '../fetchers/policy-acknowledgment-fetchers.js'; import { fetchThreadInfos } from '../fetchers/thread-fetchers.js'; @@ -242,6 +244,7 @@ pushApiPublicKey: t.maybe(t.String), _persist: t.Nil, commServicesAccessToken: t.Nil, + inviteLinksStore: inviteLinksStoreValidator, }); async function websiteResponder( @@ -471,6 +474,21 @@ return pushConfig.publicKey; })(); + const inviteLinksStorePromise = (async () => { + const primaryInviteLinks = await fetchPrimaryInviteLinks(viewer); + const links = {}; + for (const link of primaryInviteLinks) { + if (link.primary) { + links[link.communityID] = { + primaryLink: link, + }; + } + } + return { + links, + }; + })(); + const { jsURL, fontsURL, cssInclude, olmFilename, sqljsFilename, opaqueURL } = await assetInfoPromise; @@ -565,6 +583,7 @@ pushApiPublicKey: pushApiPublicKeyPromise, _persist: null, commServicesAccessToken: null, + inviteLinksStore: inviteLinksStorePromise, }); const validatedInitialReduxState = validateOutput( viewer.platformDetails, diff --git a/lib/types/link-types.js b/lib/types/link-types.js --- a/lib/types/link-types.js +++ b/lib/types/link-types.js @@ -55,6 +55,15 @@ export type InviteLinksStore = { +links: InviteLinks, }; +export const inviteLinksStoreValidator: TInterface = + tShape({ + links: t.dict( + tID, + tShape({ + primaryLink: t.maybe(inviteLinkValidator), + }), + ), + }); export type CreateOrUpdatePublicLinkRequest = { +name: string,