Skip to content

Post Access

UmbSocial decides who may change or delete a post from the person’s UmbSocial permissions. If your package stores data of its own against a post (tags, tracking values, notes) and lets people change it, apply the same rule rather than writing your own. The rule lives in the free core, so when a release changes it, your package follows without a change of its own.

A person’s access is a PostAccess (UmbSocial.Core.Posts):

Permission Access What it reaches
Schedule PostAccess.Any Any post
Approve (without Schedule) PostAccess.OwnDraftsAndAwaiting Their own drafts, and anyone’s post awaiting approval. Deleting doesn’t widen: an approver deletes only their own drafts
Write alone PostAccess.OwnDrafts Their own posts while they are drafts or awaiting approval

A post that the system created (an Automate action, for example) has no author, so only Schedule reaches it.

Whatever the access, a post can’t be changed while its content is sealed, or while one of its channels is being sent.

PostAccessRule.ResolveAsync turns the signed-in user into their access. Pass it Umbraco’s IAuthorizationService and the controller’s User:

var access = await PostAccessRule.ResolveAsync(authorization, User); // changing
var deleteAccess = await PostAccessRule.ResolveAsync(authorization, User, deleting: true); // deleting

A post written with AI goes on the calendar only when its reviewer does it. PostAccessRule.ReviewsAiAsync decides who that is: Approve, or Schedule while the site’s approvals are off, and only for a person. An API user (UserKind.Api) never reviews, whatever its permissions. Pass it the signed-in user, and pass the answer to IPostService as reviewsAi. When an API user changes a post, pass aiAuthored: true as well (PostAccessRule.IsPerson tells you), so the post counts as written with AI:

var currentUser = backOfficeSecurity.BackOfficeSecurity?.CurrentUser;
var reviewsAi = await PostAccessRule.ReviewsAiAsync(authorization, User, currentUser, approvals, cancellationToken);
var result = await posts.UpdateAsync(
key, input, schedule, userKey, cancellationToken, access, version, reviewsAi, aiAuthored: !PostAccessRule.IsPerson(currentUser));

Whether approvals are on comes from ISocialApprovals (UmbSocial.Core.Posts). The free core has no approval step, so its answer is always no; a package that adds approvals replaces it with its own. UmbSocial Pro answers yes only while it is licensed and approvals are switched on in its settings.

public interface ISocialApprovals
{
Task<bool> EnabledAsync(CancellationToken cancellationToken);
}

Inject IPostAccess and call CanChangeAsync before you change anything:

PostNotesService.cs
using UmbSocial.Core.Posts;
public sealed class PostNotesService(IPostAccess postAccess)
{
public async Task<IReadOnlyList<string>> SaveAsync(Guid postKey, string note, Guid userKey, PostAccess access, CancellationToken cancellationToken)
{
var allowed = await postAccess.CanChangeAsync(postKey, userKey, access, cancellationToken);
if (!allowed.Ok)
{
return allowed.Errors;
}
// Save the note here.
return [];
}
}

It returns a PostResult. On success, PostKey and Version are the post’s key and its current version. Otherwise Errors holds one of UmbSocial’s own error codes, the same one UmbSocial’s own edit would give:

Code Meaning
post.not_found There is no such post
post.not_yours The person’s access doesn’t reach this post
post.sealed The post’s content is sealed
post.in_flight One of its channels is being sent right now

PostAccessRule.Allows(post, userKey, access) applies the first part of the rule (whose post it is, and its status) to a post you have already loaded. It doesn’t check sealing or sending, so prefer CanChangeAsync.