forked from sim0n00ps/OF-DL
Added safe-guard against paid content returned for other models
This commit is contained in:
parent
9f8e9aa022
commit
a142c43b45
@ -726,7 +726,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}");
|
||||
|
||||
@ -778,6 +778,9 @@ public class APIHelper : IAPIHelper
|
||||
{
|
||||
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();
|
||||
if (purchase.previews != null)
|
||||
{
|
||||
@ -1829,7 +1832,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}");
|
||||
|
||||
@ -1892,10 +1895,16 @@ public class APIHelper : IAPIHelper
|
||||
|
||||
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))
|
||||
{
|
||||
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)
|
||||
{
|
||||
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);
|
||||
|
||||
@ -19,13 +19,13 @@ namespace OF_DL.Helpers
|
||||
Task<Dictionary<string, int>> GetLists(string endpoint, IDownloadConfig config);
|
||||
Task<List<string>> GetListUsers(string endpoint, IDownloadConfig config);
|
||||
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<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<ArchivedCollection> GetArchived(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<List<PurchasedTabCollection>> GetPurchasedTab(string endpoint, string folder, IDownloadConfig config, Dictionary<string, int> users);
|
||||
Task<User> GetUserInfo(string endpoint);
|
||||
|
||||
@ -1303,7 +1303,7 @@ public class Program
|
||||
await AnsiConsole.Status()
|
||||
.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 newPaidMessagesCount = 0;
|
||||
@ -1956,7 +1956,7 @@ public class Program
|
||||
await AnsiConsole.Status()
|
||||
.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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user