Unauthorized requests for premium posts should return an empty set

merge-requests/30/head
Bob Mottram 2024-03-20 22:17:03 +00:00
parent caa49aac2e
commit a3b3661e61
1 changed files with 30 additions and 18 deletions

View File

@ -34,6 +34,7 @@ from webfinger import webfinger_handle
from httpsig import create_signed_header from httpsig import create_signed_header
from siteactive import site_is_active from siteactive import site_is_active
from languages import understood_post_language from languages import understood_post_language
from utils import is_premium_account
from utils import contains_private_key from utils import contains_private_key
from utils import get_url_from_post from utils import get_url_from_post
from utils import date_from_string_format from utils import date_from_string_format
@ -4752,6 +4753,10 @@ def _create_box_indexed(recent_posts_cache: {},
print('ERROR: invalid boxname ' + boxname) print('ERROR: invalid boxname ' + boxname)
return None return None
unauthorized_premium = False
if not authorized and boxname == 'outbox':
unauthorized_premium = is_premium_account(base_dir, nickname, domain)
# bookmarks and events timelines are like the inbox # bookmarks and events timelines are like the inbox
# but have their own separate index # but have their own separate index
index_box_name = boxname index_box_name = boxname
@ -4798,24 +4803,31 @@ def _create_box_indexed(recent_posts_cache: {},
posts_in_box = [] posts_in_box = []
post_urls_in_box = [] post_urls_in_box = []
total_posts_count, posts_added_to_timeline = \ if not unauthorized_premium:
_create_box_items(base_dir, total_posts_count, posts_added_to_timeline = \
timeline_nickname, _create_box_items(base_dir,
original_domain, timeline_nickname,
nickname, domain, original_domain,
index_box_name, nickname, domain,
first_post_id, index_box_name,
page_number, first_post_id,
items_per_page, page_number,
newswire_votes_threshold, items_per_page,
positive_voting, newswire_votes_threshold,
voting_time_mins, positive_voting,
post_urls_in_box, voting_time_mins,
recent_posts_cache, post_urls_in_box,
boxname, recent_posts_cache,
posts_in_box, boxname,
box_actor) posts_in_box,
if first_post_id and posts_added_to_timeline == 0: box_actor)
else:
# unauthorized requests for premium posts should return an empty set
total_posts_count = posts_added_to_timeline = 0
if first_post_id and \
posts_added_to_timeline == 0 and \
not unauthorized_premium:
# no first post was found within the index, so just use the page number # no first post was found within the index, so just use the page number
first_post_id = '' first_post_id = ''
total_posts_count, posts_added_to_timeline = \ total_posts_count, posts_added_to_timeline = \