Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions FEATURES.md

Large diffs are not rendered by default.

151 changes: 130 additions & 21 deletions src/Application/Admin/BroadcastCampaignService.cs

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions src/Application/Common/ITraleDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ Task<bool> TryClaimNotificationTriggerAsync(
/// </summary>
Task<bool> TryFinishCampaignSendAllAsync(Guid campaignId, CancellationToken cancellationToken);

/// <summary>
/// Atomically turns a campaign whose scheduled time has come into one being sent to everyone: clears the
/// schedule and sets the "send to everyone" request. Returns <c>true</c> only for the one caller that made
/// the move — only that caller picks the recipients. Inside a transaction the row stays locked until the
/// commit, so a second replica waits and then finds nothing to start.
/// </summary>
Task<bool> TryStartScheduledCampaignAsync(Guid campaignId, DateTime now, CancellationToken cancellationToken);

/// <summary>
/// Atomically marks a campaign's gift as given to this recipient. Returns <c>true</c> only for
/// the one caller that made the mark — only that caller may change the user's access. This is
Expand Down
9 changes: 9 additions & 0 deletions src/Domain/Entities/BroadcastCampaign.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ public class BroadcastCampaign
/// "stop". The background sender works through such campaigns whether or not the admin page stays open.</summary>
public DateTime? SendAllRequestedAtUtc { get; set; }

/// <summary>When the campaign goes out by itself; null — it is not scheduled. At that moment the background
/// sender picks everyone in <see cref="Audience"/> who is not in the campaign yet and sends to all picked.
/// The recipients are decided then, not when the owner set the time: whoever left the audience in between
/// (paid, for one) gets nothing, whoever joined it does. Cleared when the sending starts or by "stop".</summary>
public DateTime? ScheduledAtUtc { get; set; }

/// <summary>The time zone the owner named the moment in ("Asia/Tbilisi") — only to show it back the same way.</summary>
public string? ScheduledTimeZone { get; set; }

public bool IsSurvey => SurveyJson != null;

public SurveyForm? Survey => SurveyForm.FromJson(SurveyJson);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public void Configure(EntityTypeBuilder<BroadcastCampaign> builder)
builder.Property(c => c.ButtonText).HasMaxLength(64);
builder.Property(c => c.ButtonQuery).HasMaxLength(256);
builder.Property(c => c.SurveyJson).HasColumnType("jsonb");
builder.Property(c => c.ScheduledTimeZone).HasMaxLength(64);
builder.Ignore(c => c.IsSurvey);
builder.Ignore(c => c.Survey);
}
Expand Down
Loading
Loading