Skip to content

Commit

Permalink
add supporter modified date
Browse files Browse the repository at this point in the history
  • Loading branch information
th0mk committed Sep 9, 2024
1 parent 5150086 commit a9d92e3
Show file tree
Hide file tree
Showing 5 changed files with 2,907 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/FMBot.Bot/Services/SupporterService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ public async Task<Supporter> AddOpenCollectiveSupporter(ulong id, OpenCollective
{
Name = openCollectiveUser.Name,
Created = DateTime.UtcNow,
Modified = DateTime.UtcNow,
Notes = "Added through OpenCollective integration",
SupporterMessagesEnabled = true,
VisibleInOverview = true,
Expand Down Expand Up @@ -623,7 +624,9 @@ public async Task UpdateExistingOpenCollectiveSupporters()
Log.Information(
"Updating last payment date for supporter {supporterName} from {currentDate} to {newDate}",
existingSupporter.Name, existingSupporter.LastPayment, openCollectiveSupporter.LastPayment);

existingSupporter.LastPayment = openCollectiveSupporter.LastPayment;
existingSupporter.Modified = DateTime.UtcNow;

Log.Information("Updating name for supporter {supporterName} to {newName}", existingSupporter.Name,
openCollectiveSupporter.Name);
Expand Down Expand Up @@ -849,6 +852,8 @@ public async Task UpdateDiscordSupporters(List<DiscordEntitlement> discordSuppor
var oldDate = existingSupporter.LastPayment;

existingSupporter.LastPayment = discordSupporter.EndsAt;
existingSupporter.Modified = DateTime.UtcNow;

db.Update(existingSupporter);
await db.SaveChangesAsync();

Expand Down Expand Up @@ -958,6 +963,7 @@ public async Task CheckExpiredDiscordSupporters()
var oldDate = existingSupporter.LastPayment;

existingSupporter.LastPayment = discordSupporter.EndsAt;
existingSupporter.Modified = DateTime.UtcNow;
db.Update(existingSupporter);
await db.SaveChangesAsync();

Expand Down Expand Up @@ -1233,6 +1239,7 @@ private async Task<Supporter> ReActivateSupporter(Supporter supporter, DiscordEn
supporter.SupporterMessagesEnabled = true;
supporter.VisibleInOverview = true;
supporter.LastPayment = entitlement.EndsAt;
supporter.Modified = DateTime.UtcNow;

db.Update(supporter);
await db.SaveChangesAsync();
Expand Down
2 changes: 2 additions & 0 deletions src/FMBot.Persistence.Domain/Models/Supporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public class Supporter

public DateTime Created { get; set; }

public DateTime? Modified { get; set; }

//public DateTime? EndDate { get; set; }

//public string StripeSubscriptionId { get; set; }
Expand Down
Loading

0 comments on commit a9d92e3

Please sign in to comment.