feat: filter out replies to other accounts than original author

This commit is contained in:
Ayo Ayco 2024-04-19 20:27:31 +02:00
parent 67bea0768b
commit 7bb7faa86c

5
app.py
View file

@ -11,14 +11,15 @@ def home():
threads = [] threads = []
for id in thread_ids: for id in thread_ids:
status = requests.get(server + '/api/v1/statuses/' + id ).json() status = requests.get(server + '/api/v1/statuses/' + id ).json()
author = status['account']['acct'] author = status['account']['id']
context = requests.get(server + '/api/v1/statuses/' + id + '/context').json() context = requests.get(server + '/api/v1/statuses/' + id + '/context').json()
descendants = [] descendants = []
for reply in context['descendants']: for reply in context['descendants']:
if reply['account']['acct'] == author: if reply['account']['id'] == author and reply['in_reply_to_account_id'] == author:
descendants.append(clean_status(reply)) descendants.append(clean_status(reply))
status = clean_status(status) status = clean_status(status)
status['descendants'] = descendants status['descendants'] = descendants
status['descendants_count'] = len(descendants)
threads.append(status) threads.append(status)
return threads return threads