Pickle Systems
connectionsLogin
Twitch
/Connections/Twitch
connectionsLogin

Admin view

This surface is designed for hub owners and members. Admins can audit connections from Admin pages.
async ({ sess, ctx }) => { const db = ctx?.db; const tid = String(sess?.tenantId || 'default'); const uid = String(sess?.userId || ''); const enabledChannels = (await db.listEnabledChannels('twitch', tid)) || []; const nIdent = uid ? await ctx?.storage?.users?.countProviderIdentities(uid, ['twitch']) : null; const linkedIdentityCount = Number(nIdent?.n || 0); const linkedLoginRow = uid ? await ctx?.storage?.users?.getLinkedIdentityLogin(uid, 'twitch') : null; const linkedLogin = String(linkedLoginRow?.login || '').trim(); const connected = linkedIdentityCount > 0 || enabledChannels.length > 0; const stateLabel = connected ? 'Connected' : 'Not connected'; const stateHelp = connected ? 'Your Twitch account is linked and ready to use.' : 'Connect your Twitch account to use it in Channel Dashboard.'; const connectedChannelName = linkedLogin || enabledChannels[0] || '—'; const connectedChannelHelp = linkedLogin ? 'This is the Twitch account currently linked to Pickle Systems.' : enabledChannels.length ? 'This Twitch channel was saved earlier on this account.' : 'No Twitch channel is connected yet.'; return `
Channel connections

Twitch

Connect Twitch here. Then turn the channel on in Channel Dashboard.
Status
${esc(stateLabel)}
${esc(stateHelp)}
Linked Twitch identities
${linkedIdentityCount}
Twitch accounts linked to this Pickle Systems account.
Connected channel name
${esc(connectedChannelName)}
${esc(connectedChannelHelp)}
`; }