Schedule Service
The schedule service reads and changes the shared posting schedule, its time zone and the webhook opt-ins, and finds the next free slot. See Posting schedule and time zone.
You can access it by injecting IScheduleService, which can be found within the namespace UmbSocial.Core.Scheduling.
A slot is a SlotInput(DayOfWeek Day, TimeOnly LocalTime), in the schedule’s time zone.
GetAsync
Section titled “GetAsync”Gets the time zone and the shared slots, ordered by day and time.
Task<ScheduleView> GetAsync(CancellationToken cancellationToken);ScheduleView has TimeZoneId (string) and Slots (IReadOnlyList<SlotInput>).
SaveAsync
Section titled “SaveAsync”Replaces the shared slots and, when timeZoneId isn’t null, sets the time zone in the same save: if either is refused, nothing changes. Duplicate slots are saved once and times are kept to the minute. Returns error codes, empty when saved: settings.time_zone_unknown, schedule.too_many_slots (more than 168) or schedule.day_invalid.
| Name | Detail |
|---|---|
| slots | Every slot the schedule should have. |
| timeZoneId | The time zone to save with them: an IANA id (Europe/London) or a Windows id the server knows, at most 100 characters; null keeps the current one. |
Task<IReadOnlyList<string>> SaveAsync(IReadOnlyList<SlotInput> slots, string? timeZoneId, CancellationToken cancellationToken);GetWebhookOptInsAsync
Section titled “GetWebhookOptInsAsync”Whether Social’s webhooks carry the post’s text and its author. Both are off until a site opts in.
Task<WebhookOptIns> GetWebhookOptInsAsync(CancellationToken cancellationToken);WebhookOptIns has IncludePostTextInWebhooks and IncludeAuthorInWebhooks (bool).
SaveSettingsAsync
Section titled “SaveSettingsAsync”Saves the webhook opt-ins and, when timeZoneId isn’t null, the time zone, in the same save: if the time zone is refused (settings.time_zone_unknown), nothing changes. Returns error codes, empty when saved.
| Name | Detail |
|---|---|
| timeZoneId | The time zone, as for SaveAsync; null keeps the current one. |
| webhooks | Whether webhooks carry the post’s text and its author. |
Task<IReadOnlyList<string>> SaveSettingsAsync(string? timeZoneId, WebhookOptIns webhooks, CancellationToken cancellationToken);NextFreeSlotAsync
Section titled “NextFreeSlotAsync”The next slot (UTC) that no scheduled post has taken, within the next 28 days, or null when there is none.
Task<DateTime?> NextFreeSlotAsync(CancellationToken cancellationToken);