{"size": 491, "ext": "js", "max_stars_repo_path": "src/data/files.js", "max_stars_repo_name": "Samirgitthub/pronote-api", "max_stars_repo_stars_event_min_datetime": "2020-09-04T15:13:11.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-07T03:15:40.000Z", "max_issues_repo_path": "src/data/files.js", "max_issues_repo_name": "Samirgitthub/pronote-api", "max_issues_repo_issues_event_min_datetime": "2020-11-19T07:00:28.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T18:07:32.000Z", "max_forks_repo_path": "src/data/files.js", "max_forks_repo_name": "Samirgitthub/pronote-api", "max_forks_repo_forks_event_min_datetime": "2021-05-02T18:37:36.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-08T15:38:39.000Z"}
{"max_stars_count": 15, "max_issues_count": 81, "max_forks_count": 9, "avg_line_length": 32.7333333333, "max_line_length": 103, "alphanum_fraction": 0.6863543788}
const { toPronote } = require('./objects');
const { cipher } = require('../cipher');

const EXTERNAL_FILES_FOLDER = 'FichiersExternes/';

function getFileURL(session, { id, name, type })
{
    const fileID = cipher(session, JSON.stringify(toPronote({ id, type })));
    const fileName = encodeURIComponent(encodeURIComponent(name)); // *Clown emoji*

    return session.server + EXTERNAL_FILES_FOLDER + fileID + '/' + fileName + '?Session=' + session.id;
}

module.exports = { getFileURL };
