Skip to content

SocialPostSavingNotification

Published before a post is created or updated. A handler can change any part of the post, including its channels and its timing, or refuse the save.

The following properties are available within the notification

Property Name Type Use
Target SocialPostDraft The post as it is about to be saved. Change it here.
Existing SocialPost? The stored post on an update, for comparison; null when the post is being created. Changes to it are ignored.
Messages EventMessages Add the message to show when you cancel.
Cancel bool Set to true to cancel without a message.

SocialPostDraft has these properties, all settable:

Property Name Type Use
Text string The main text.
LinkUrl string? The link.
LinkTitle string? The link’s title.
LinkDescription string? The link’s description.
MediaKey Guid? The image’s media item key.
ImageAltText string? The image’s alt text.
Channels Dictionary<Guid, string?> Channel key → that channel’s own text, or null for the main text.
When When Draft, Queue, At or Now.
AtUtc DateTime? The time (UTC) when When is At.

Call CancelOperation(new EventMessage(category, message, EventMessageType.Error)). Nothing is saved, and the result is post.cancelled:<message>.

  • Everything Social checks (required text, size caps, https links, network limits, known and unpaused channels, a time in the future, a free queue slot) runs after the handlers, on what they leave.
  • On an update, these checks run before the handlers, and the notification isn’t published if one fails: the post doesn’t exist (post.not_found), is sealed (post.sealed), is being sent (post.in_flight), or has a target whose outcome is Unknown (post.outcome_unknown).
  • In the management API, the permission check (Schedule for anything but a draft), the rate limit, and the check that MediaKey is a media item use the request as it was sent, before the handlers. If a handler sets MediaKey, use the key of a media item.

See Extending UmbSocial for an example.