Skip to content

Twitch: Link Channel to Tenant Command #269

@danielhe4rt

Description

@danielhe4rt

Parent

#266 — Twitch EventSub: ingestão de eventos via webhook (data lake)

What to build

An Artisan command that links a Twitch channel to a tenant by creating an ExternalIdentity record, following the same pattern as GenerateDiscordTenant.

End-to-end behavior

After this slice, running php artisan twitch:link-channel danielhe4rt --tenant=he4rt-developers resolves the Twitch user ID via the Helix API, finds the target tenant, and creates an ExternalIdentity linking them. This establishes the "official channel" relationship for the tenant.

What changes

New — Command:

  • LinkTwitchChannelCommand in Console/ with signature twitch:link-channel {login} {--tenant= : Tenant slug or ID}
  • Resolves broadcaster user ID by sending GetUsers request via TwitchHelixConnector
  • Finds tenant by slug or ID
  • Creates ExternalIdentity on the tenant with provider=Twitch, external_account_id=<broadcaster_user_id>, metadata containing login and display name
  • Follows the GenerateDiscordTenant pattern: IdentityType::External, CredentialsType::OAuth2, ClientAccessManager::make(), connected_at=now()
  • Registers command in IntegrationTwitchServiceProvider

Acceptance criteria

  • php artisan twitch:link-channel danielhe4rt --tenant=he4rt-developers creates an ExternalIdentity with provider=Twitch on the target tenant
  • external_account_id is set to the resolved Twitch broadcaster user ID (not the login string)
  • metadata contains the channel login and display name
  • Command outputs success message with broadcaster ID and tenant name
  • Command handles errors: invalid login (user not found on Twitch), tenant not found, identity already exists
  • Tests: command creates ExternalIdentity with correct attributes (mocked Helix API response)
  • Tests: command handles duplicate linking gracefully
  • vendor/bin/pint --dirty --format agent passes
  • php artisan test --compact --filter=Twitch passes

Blocked by

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready-for-agentFully specified, ready for an AFK agent

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions