Let applications create their own inbox channels

Closed
BO
1mo ago
+594-93

Applications can create, update and delete their own inbox channels, including from logic functions with no member behind them. Managing channels still requires AI_SETTINGS.

  • Creating a channel is idempotent by universal identifier: the application gets back the channel it already owns, and an identifier another application owns is refused.
  • An application can only update or delete channels it owns. Members still manage every channel.
  • Channel names stay unique. A member reusing a taken name gets an error; an application gets the next free one, such as "Support 2".
  • Uninstalling an application moves its channels' conversations to General before deleting the channels.
  • Manifest sync no longer deletes channels created at runtime, until manifests can declare them.
sequenceDiagram
  participant App as Application
  participant Twenty
  participant Channels
  participant Chats as Conversations

  App->>Twenty: create channel<br/>(universal id)
  Twenty->>Channels: find by<br/>universal id
  alt not found
    Twenty->>Channels: insert under<br/>the next free name
    Twenty-->>App: new channel<br/>owned by the app
  else owned by the app
    Twenty-->>App: same channel,<br/>unchanged
  else owned by another app
    Twenty-->>App: CONFLICT
  end

  App->>Twenty: update or delete
  alt the app owns the channel
    Twenty->>Channels: apply the change
  else another owner
    Twenty-->>App: FORBIDDEN
  end

  Note over Twenty,Chats: Application uninstall
  Twenty->>Chats: move chats to General
  Twenty->>Channels: delete app channels

Tracks application inbox channels.