<commit_before>import requests
from django.shortcuts import reverse
from django.conf import settings


def get_settings():

    api_url = settings.SPOTTED_API_URL
    token = settings.SPOTTED_API_SECRET
    headers = {'Authorization': 'Token ' + token}
    return api_url, token, headers


def api_process_new_post(instance):
    """
    Process new post through the API
    """

    api_url, token, headers = get_settings()

    # Payload
    data = {
        'message': instance.message,
        'is_safe': instance.is_attachment_safe,
    }

    # Resolve URL
    url = api_url + reverse('api:process_new_post')

    # Send payload to API
    response = requests.post(url, headers=headers, data=data)
    # If ok,
    if response.status_code == requests.codes.ok:
        # Check for the required response data
        try:
            # If the API has decided that the post should be posted right away, do that
            if response.json()['action'] == 'approve':
                instance.suggestion = response.json()['suggestion']
                instance.api_id = response.json()['api_id']
                instance.save()
                instance.post_spotted()<commit_msg>has_attachment is also sent to api<commit_after>import requests
from django.shortcuts import reverse
from django.conf import settings


def get_settings():

    api_url = settings.SPOTTED_API_URL
    token = settings.SPOTTED_API_SECRET
    headers = {'Authorization': 'Token ' + token}
    return api_url, token, headers


def api_process_new_post(instance):
    """
    Process new post through the API
    """

    api_url, token, headers = get_settings()

    # Payload
    data = {
        'message': instance.message,
        'is_safe': instance.is_attachment_safe,
        'has_attachment': instance.has_attachment
    }

    # Resolve URL
    url = api_url + reverse('api:process_new_post')

    # Send payload to API
    response = requests.post(url, headers=headers, data=data)
    # If ok,
    if response.status_code == requests.codes.ok:
        # Check for the required response data
        try:
            # If the API has decided that the post should be posted right away, do that
            if response.json()['action'] == 'approve':
                instance.suggestion = response.json()['suggestion']
                instance.api_id = response.json()['api_id']
                instance.save()
                instance.post_spotted()
{'fraction_non_alphanumeric': 0.09699958898479244, 'fraction_numerical': 0.0, 'mean_word_length': 2.6166419019316494, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6232610', 'n_tokens_mistral': 706, 'n_tokens_neox': 675, 'n_words': 188}