Channel Service
The channel service adds, changes and removes channels, and creates their managed automations in Automate.
You can access it by injecting IChannelService, which can be found within the namespace UmbSocial.Core.Channels.
Each method returns a ChannelResult:
| Property | Type | Detail |
|---|---|---|
| Ok | bool |
Whether everything succeeded. |
| ChannelKey | Guid? |
The channel’s key. Set when the channel exists, even if Ok is false (for example a channel saved without its automation, or a refused update). |
| Errors | IReadOnlyList<string> |
Error codes. |
ListAsync
Section titled “ListAsync”The channels that haven’t been removed, in sort order. Disabled channels are included.
Task<IReadOnlyList<SocialChannel>> ListAsync(CancellationToken cancellationToken);AddAsync
Section titled “AddAsync”Adds a channel, then creates and publishes its managed automation. Refused with channel.limit beyond the edition’s allowance. If the automation can’t be made yet (for example channel.no_workspace), the channel is still saved: ChannelKey is set, Ok is false and Errors says why.
Parameters:
| Name | Detail |
|---|---|
| network | The network id, for example linkedin. Must be available (its provider installed). |
| name | The channel’s name, up to 100 characters. |
| automateConnectionId | The Automate connection. Must be the network’s connection type. |
| settingsJson | The network’s channel options as a JSON object, for example {"organizationId":"12345"}, or {}. |
Task<ChannelResult> AddAsync(string network, string name, Guid automateConnectionId, string settingsJson, CancellationToken cancellationToken);UpdateAsync
Section titled “UpdateAsync”Changes a channel’s name, whether it is enabled, and its options. Changed options are copied into the managed automation’s post step. The network and connection can’t be changed: remove the channel and add a new one.
| Name | Detail |
|---|---|
| key | The channel’s key. |
| name | The channel’s name. |
| enabled | false stops its posts going out; they wait until it is enabled. |
| settingsJson | The network’s channel options. |
Task<ChannelResult> UpdateAsync(Guid key, string name, bool enabled, string settingsJson, CancellationToken cancellationToken);RemoveAsync
Section titled “RemoveAsync”Removes a channel: fails its unsent targets (channel.removed) and unpublishes its managed automation. Its history stays, and it no longer counts towards the channel limit.
| Name | Detail |
|---|---|
| key | The channel’s key. |
Task<ChannelResult> RemoveAsync(Guid key, CancellationToken cancellationToken);EnsureAutomationAsync
Section titled “EnsureAutomationAsync”Makes sure the channel has its published managed automation, creating it if it’s missing. Use it after setting up the workspace, or if the automation was deleted. See Automate integration.
| Name | Detail |
|---|---|
| key | The channel’s key. |
Task<ChannelResult> EnsureAutomationAsync(Guid key, CancellationToken cancellationToken);