Skip to content

Services

UmbSocial’s services are registered in Umbraco’s dependency injection as singletons. Inject them where you need them:

Service Namespace Use
IPostService UmbSocial.Core.Posts Create, change, list, delete and resolve posts.
IChannelService UmbSocial.Core.Channels Add, change and remove channels and their automations.
IScheduleService UmbSocial.Core.Scheduling The posting schedule, its time zone and the next free slot.
NetworkCatalogue UmbSocial.Core.Channels The networks available here (Available()), and a network’s template (Template(network)).
ISocialMediaUrls UmbSocial.Core.Publishing An image’s public URL. See Replacing services.

Every method takes a CancellationToken. The services apply every rule the management API does (validation, network limits, the edition’s limits, the history window), and they publish the notifications. They don’t check permissions: that is the caller’s job, as the management API does with its policies.

Results don’t throw for a refused change: they carry stable error codes, listed in Error codes.

ScheduleAnnouncement.cs
using UmbSocial.Core.Channels;
using UmbSocial.Core.Posts;
public sealed class ScheduleAnnouncement(IPostService posts, IChannelService channels)
{
public async Task<PostResult> QueueAsync(string text, string link, Guid userKey, CancellationToken cancellationToken)
{
var all = await channels.ListAsync(cancellationToken);
var input = new PostInput(
Text: text,
LinkUrl: link,
LinkTitle: "Read more",
LinkDescription: null,
MediaKey: null,
ImageAltText: null,
Channels: all.Where(c => c.IsEnabled).ToDictionary(c => c.Key, _ => (string?)null));
return await posts.CreateAsync(input, new Schedule(When.Queue, null), userKey, cancellationToken);
}
}

PostResult.Ok says whether it was saved, PostKey is the new post’s key, and Errors holds the codes when it wasn’t.