Skip to content

Unlimited History

With UmbSocial Pro licensed, there is no history window: every finished post stays in the lists, however old it is, and nothing is sealed.

A site that ran the free edition first has posts the free edition sealed: their content is encrypted in the database and their columns are blank. Pro puts them back on its own; there is nothing to run or switch on.

  • Every 10 minutes, while the licence is active, Pro opens up to 200 sealed posts with UmbHost’s private key (which only the Pro package holds) and writes their content back: the text, link, image, alt text, framing, review note and campaign, and each channel’s text, live URL, network id and error. The post goes back to the campaign it went out with, found by its key, even if the campaign has been renamed since. A campaign that has been deleted stays deleted: restoring never adds or recreates a campaign. Such a post comes back with no campaign, and its history gets a Campaign no longer exists entry with the campaign’s old name.
  • A post’s status, dates and history are untouched; only its content comes back. Restoring a post that is already restored changes nothing.
  • A site with many sealed posts is restored over several runs, 200 posts at a time.
  • It is an Umbraco distributed background job named UmbSocial.Pro.HistoryRestore: Umbraco runs it on one server at a time (in a load-balanced site, whichever server is free), once the site is running, and records its runs in its own database table. The first run is about 10 minutes after the site first starts with Pro installed; after that, 10 minutes from the end of the previous run.
  • It runs whether or not publishing is switched on, and not while the database is read-only.

HistoryKeyCheck.HistoryKeyAvailable() (UmbSocial.Pro.Diagnostics) answers whether the installed UmbSocial.Pro can open history the free edition sealed: it seals a test value with UmbHost’s public key and opens it with the key the package carries. It never exposes the key, restores nothing and doesn’t depend on the licence, so it is safe to call from a health check or a support page.

On the Published page, Export CSV (in the footer bar, for anyone who can view UmbSocial) asks for a first and a last day, which start as the last 30 days, and downloads the history of those days as a CSV file. It is a Pro feature: while UmbSocial isn’t licensed, the request is refused.

  • One row for each channel a post went to, for posts that finished (published, partly failed or failed), by when it went out: the channel’s completion time, else the post’s published, scheduled or created time. The days are in UTC, the first and the last included.
  • The columns are PostKey, ScheduledForUtc (empty for a post that wasn’t scheduled), PublishedUtc (when the channel’s post went out, else the post’s), Channel, Network, Status (the channel’s), PostUrl, Error and Text (the channel’s own text, or the post’s).
  • A range is at most 366 days. A longer one is refused with history.range_too_long, and a last day before the first with history.range_invalid.
  • The file is UTF-8 with a byte order mark, so Excel opens it correctly, and follows RFC 4180: fields with a comma, quote or line break are quoted. A value that starts with =, +, -, @, a tab or a carriage return gets a leading ', so a spreadsheet shows it as text instead of running it as a formula.
  • A post still sealed (the licence was off when it was sealed and isn’t restored yet) is listed with its status as stored and an empty Text.
  • Rows are streamed from the database as the file is written, so a long history isn’t held in memory.

The file name is umbsocial-history-<first day>-<last day>.csv. The endpoint is GET /umbraco/management/api/v1/umbsocial/pro/history/export?fromUtc=…&toUtc=… (the end is not included) and needs the View permission.

Two more notifications, in UmbSocial.Pro.Notifications:

Notification When Properties
SocialHistoryExportingNotification Before the rows are read. Cancel it to refuse the export. Range (SocialHistoryExportRange: FromUtc, ToUtc), UserKey (the backoffice user).
SocialHistoryExportedNotification After the file was written. Range, UserKey and RowCount.

A handler that cancels the exporting notification with an error message refuses the request with history.export_cancelled:<message>, and the person sees the message.

From code, the export is IHistoryExportService (UmbSocial.Pro.History). StartAsync checks the range and raises the exporting notification; it answers the codes it refused with, or the file name and a WriteAsync that streams the CSV to a stream you give it and then raises the exported notification. Pro’s services check the licence themselves, not only its endpoints: while UmbSocial isn’t licensed, a service that changes something refuses with licence.pro_required and changes nothing, and one that reads finds nothing.

HistoryExportAuditHandler.cs
using UmbSocial.Pro.Notifications;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Notifications;
public sealed class HistoryExportingHandler : INotificationHandler<SocialHistoryExportingNotification>
{
public void Handle(SocialHistoryExportingNotification notification)
{
if (notification.Range.ToUtc - notification.Range.FromUtc > TimeSpan.FromDays(90))
{
notification.CancelOperation(new EventMessage("Export", "Export at most 90 days at a time.", EventMessageType.Error));
}
}
}

Restoring stops straight away. The licence is checked at the start of every run and again just before a batch is saved, so a licence that lapses during a run writes nothing back.

Nothing is deleted. Once the site is back on the free edition, finished posts older than 90 days are hidden and sealed again by the free edition, restored ones included. When the licence is renewed, Pro restores them again.

Restoring raises a pair of notifications, in UmbSocial.Pro.Notifications. Both are for information only: restoring is what the licence provides, so a handler can’t cancel or postpone it, and a handler that throws is logged (with the post ids) and ignored.

Notification When Properties
SocialHistoryRestoringNotification Before a batch of sealed posts is restored. PostIds (IReadOnlyList<int>): the posts about to be restored.
SocialHistoryRestoredNotification After the batch is saved. PostIds (IReadOnlyList<int>): the posts restored. A post that stays sealed isn’t listed.
HistoryRestoredHandler.cs
using Microsoft.Extensions.Logging;
using UmbSocial.Pro.Notifications;
using Umbraco.Cms.Core.Events;
public sealed class HistoryRestoredHandler(ILogger<HistoryRestoredHandler> logger)
: INotificationHandler<SocialHistoryRestoredNotification>
{
public void Handle(SocialHistoryRestoredNotification notification)
=> logger.LogInformation("Restored {Count} sealed posts", notification.PostIds.Count);
}

Register it in a composer with builder.AddNotificationHandler<SocialHistoryRestoredNotification, HistoryRestoredHandler>();.

They run on the server that runs the job, outside any request. The free edition’s own SocialHistorySealingNotification and SocialHistorySealedNotification are raised when posts are sealed.