Added safe-guard against paid content returned for other models

This commit is contained in:
Casper Sparre 2025-10-06 20:10:23 +02:00
parent 27ea6a7323
commit 5588619cf5
3 changed files with 25 additions and 16 deletions

View File

@ -893,7 +893,7 @@ public class APIHelper : IAPIHelper
} }
public async Task<PaidPostCollection> GetPaidPosts(string endpoint, string folder, string username, IDownloadConfig config, List<long> paid_post_ids, StatusContext ctx) public async Task<PaidPostCollection> GetPaidPosts(string endpoint, string folder, string username, int userId, IDownloadConfig config, List<long> paid_post_ids, StatusContext ctx)
{ {
Log.Debug($"Calling GetPaidPosts - {username}"); Log.Debug($"Calling GetPaidPosts - {username}");
@ -945,6 +945,9 @@ public class APIHelper : IAPIHelper
{ {
if (purchase.responseType == "post" && purchase.media != null && purchase.media.Count > 0) if (purchase.responseType == "post" && purchase.media != null && purchase.media.Count > 0)
{ {
if (purchase.fromUser.id != userId)
continue; // Ensures only posts from current model are included
List<long> previewids = new(); List<long> previewids = new();
if (purchase.previews != null) if (purchase.previews != null)
{ {
@ -1996,7 +1999,7 @@ public class APIHelper : IAPIHelper
} }
public async Task<PaidMessageCollection> GetPaidMessages(string endpoint, string folder, string username, IDownloadConfig config, StatusContext ctx) public async Task<PaidMessageCollection> GetPaidMessages(string endpoint, string folder, string username, int userId, IDownloadConfig config, StatusContext ctx)
{ {
Log.Debug($"Calling GetPaidMessages - {username}"); Log.Debug($"Calling GetPaidMessages - {username}");
@ -2059,10 +2062,16 @@ public class APIHelper : IAPIHelper
if (paidMessages.list != null && paidMessages.list.Count > 0) if (paidMessages.list != null && paidMessages.list.Count > 0)
{ {
int ownUserId = Convert.ToInt32(auth.USER_ID);
int[] validUserIds = [ownUserId, userId];
foreach (Purchased.List purchase in paidMessages.list.Where(p => p.responseType == "message").OrderByDescending(p => p.postedAt ?? p.createdAt)) foreach (Purchased.List purchase in paidMessages.list.Where(p => p.responseType == "message").OrderByDescending(p => p.postedAt ?? p.createdAt))
{ {
if (!config.IgnoreOwnMessages || purchase.fromUser.id != Convert.ToInt32(auth.USER_ID)) if (!config.IgnoreOwnMessages || purchase.fromUser.id != ownUserId)
{ {
if (!validUserIds.Contains(purchase.fromUser.id))
continue; // Ensures only messages from current model (or self) are included
if (purchase.postedAt != null) if (purchase.postedAt != null)
{ {
await m_DBHelper.AddMessage(folder, purchase.id, purchase.text != null ? purchase.text : string.Empty, purchase.price != null ? purchase.price : "0", true, false, purchase.postedAt.Value, purchase.fromUser.id); await m_DBHelper.AddMessage(folder, purchase.id, purchase.text != null ? purchase.text : string.Empty, purchase.price != null ? purchase.price : "0", true, false, purchase.postedAt.Value, purchase.fromUser.id);

View File

@ -20,13 +20,13 @@ namespace OF_DL.Helpers
Task<List<string>> GetListUsers(string endpoint, IDownloadConfig config); Task<List<string>> GetListUsers(string endpoint, IDownloadConfig config);
Task<Dictionary<string, int>?> GetUsersFromList(string endpoint, bool includeRestricted, IDownloadConfig config); Task<Dictionary<string, int>?> GetUsersFromList(string endpoint, bool includeRestricted, IDownloadConfig config);
Task<Dictionary<long, string>> GetMedia(MediaType mediatype, string endpoint, string? username, string folder, IDownloadConfig config, List<long> paid_post_ids); Task<Dictionary<long, string>> GetMedia(MediaType mediatype, string endpoint, string? username, string folder, IDownloadConfig config, List<long> paid_post_ids);
Task<PaidPostCollection> GetPaidPosts(string endpoint, string folder, string username, IDownloadConfig config, List<long> paid_post_ids, StatusContext ctx); Task<PaidPostCollection> GetPaidPosts(string endpoint, string folder, string username, int userId, IDownloadConfig config, List<long> paid_post_ids, StatusContext ctx);
Task<PostCollection> GetPosts(string endpoint, string folder, IDownloadConfig config, List<long> paid_post_ids, StatusContext ctx); Task<PostCollection> GetPosts(string endpoint, string folder, IDownloadConfig config, List<long> paid_post_ids, StatusContext ctx);
Task<SinglePostCollection> GetPost(string endpoint, string folder, IDownloadConfig config); Task<SinglePostCollection> GetPost(string endpoint, string folder, IDownloadConfig config);
Task<StreamsCollection> GetStreams(string endpoint, string folder, IDownloadConfig config, List<long> paid_post_ids, StatusContext ctx); Task<StreamsCollection> GetStreams(string endpoint, string folder, IDownloadConfig config, List<long> paid_post_ids, StatusContext ctx);
Task<ArchivedCollection> GetArchived(string endpoint, string folder, IDownloadConfig config, StatusContext ctx); Task<ArchivedCollection> GetArchived(string endpoint, string folder, IDownloadConfig config, StatusContext ctx);
Task<MessageCollection> GetMessages(string endpoint, string folder, IDownloadConfig config, StatusContext ctx); Task<MessageCollection> GetMessages(string endpoint, string folder, IDownloadConfig config, StatusContext ctx);
Task<PaidMessageCollection> GetPaidMessages(string endpoint, string folder, string username, IDownloadConfig config, StatusContext ctx); Task<PaidMessageCollection> GetPaidMessages(string endpoint, string folder, string username, int userId, IDownloadConfig config, StatusContext ctx);
Task<Dictionary<string, int>> GetPurchasedTabUsers(string endpoint, IDownloadConfig config, Dictionary<string, int> users); Task<Dictionary<string, int>> GetPurchasedTabUsers(string endpoint, IDownloadConfig config, Dictionary<string, int> users);
Task<List<PurchasedTabCollection>> GetPurchasedTab(string endpoint, string folder, IDownloadConfig config, Dictionary<string, int> users); Task<List<PurchasedTabCollection>> GetPurchasedTab(string endpoint, string folder, IDownloadConfig config, Dictionary<string, int> users);
Task<User> GetUserInfo(string endpoint); Task<User> GetUserInfo(string endpoint);

View File

@ -1356,15 +1356,15 @@ public class Program
AnsiConsole.Markup("\n"); AnsiConsole.Markup("\n");
AnsiConsole.Write(new BreakdownChart() AnsiConsole.Write(new BreakdownChart()
.FullSize() .FullSize()
.AddItem("Paid Posts", paidPostCount, Color.Red) .AddItem("Paid Posts", paidPostCount, Color.Red)
.AddItem("Posts", postCount, Color.Blue) .AddItem("Posts", postCount, Color.Blue)
.AddItem("Archived", archivedCount, Color.Green) .AddItem("Archived", archivedCount, Color.Green)
.AddItem("Streams", streamsCount, Color.Purple) .AddItem("Streams", streamsCount, Color.Purple)
.AddItem("Stories", storiesCount, Color.Yellow) .AddItem("Stories", storiesCount, Color.Yellow)
.AddItem("Highlights", highlightsCount, Color.Orange1) .AddItem("Highlights", highlightsCount, Color.Orange1)
.AddItem("Messages", messagesCount, Color.LightGreen) .AddItem("Messages", messagesCount, Color.LightGreen)
.AddItem("Paid Messages", paidMessagesCount, Color.Aqua)); .AddItem("Paid Messages", paidMessagesCount, Color.Aqua));
AnsiConsole.Markup("\n"); AnsiConsole.Markup("\n");
} }
DateTime endTime = DateTime.Now; DateTime endTime = DateTime.Now;
@ -1428,7 +1428,7 @@ public class Program
await AnsiConsole.Status() await AnsiConsole.Status()
.StartAsync("[red]Getting Paid Messages[/]", async ctx => .StartAsync("[red]Getting Paid Messages[/]", async ctx =>
{ {
paidMessageCollection = await downloadContext.ApiHelper.GetPaidMessages("/posts/paid/chat", path, user.Key, downloadContext.DownloadConfig!, ctx); paidMessageCollection = await downloadContext.ApiHelper.GetPaidMessages("/posts/paid/chat", path, user.Key, user.Value, downloadContext.DownloadConfig!, ctx);
}); });
int oldPaidMessagesCount = 0; int oldPaidMessagesCount = 0;
int newPaidMessagesCount = 0; int newPaidMessagesCount = 0;
@ -2091,7 +2091,7 @@ public class Program
await AnsiConsole.Status() await AnsiConsole.Status()
.StartAsync("[red]Getting Paid Posts[/]", async ctx => .StartAsync("[red]Getting Paid Posts[/]", async ctx =>
{ {
purchasedPosts = await downloadContext.ApiHelper.GetPaidPosts("/posts/paid/post", path, user.Key, downloadContext.DownloadConfig!, paid_post_ids, ctx); purchasedPosts = await downloadContext.ApiHelper.GetPaidPosts("/posts/paid/post", path, user.Key, user.Value, downloadContext.DownloadConfig!, paid_post_ids, ctx);
}); });
int oldPaidPostCount = 0; int oldPaidPostCount = 0;