from load_config import config

from mastodon import Mastodon

m = Mastodon(access_token=config['boost_mastodon']['token'], api_base_url=config['boost_mastodon']['server'])

def boost(url):
    search_results = m.search(url, resolve=True, exclude_unreviewed=False)
    status_result_count = len(search_results['statuses'])
    if status_result_count != 1:
        print("Unable to find status to boost")
        return None        
    status_id = search_results['statuses'][0]['id']
    print(f"Boosting status: {status_id}")
    m.status_reblog(status_id, visibility="public")
    m.status_favourite(status_id)
