<commit_before>var _ = require('lodash'),
    xml = require('xml'),
    config = require('../config'),
    urlService = require('../services/url'),
    common = require('../lib/common'),
    request = require('../lib/request'),
    settingsCache = require('./settings/cache'),

    defaultPostSlugs = [
        'welcome',
        'the-editor',
        'using-tags',
        'managing-users',
        'private-sites',
        'advanced-markdown',
        'themes'
    ],
    // ToDo: Make this configurable
    pingList = [
        {
            url: 'blogsearch.google.com/ping/RPC2'
        },
        {
            url: 'rpc.pingomatic.com'
        }
    ];

function ping(post) {
    var pingXML,
        title = post.title,
        url = urlService.utils.urlFor('post', {post: post}, true);

    if (post.page || config.isPrivacyDisabled('useRpcPing') || settingsCache.get('is_private')) {
        return;
    }

    // Don't ping for the default posts.
    // This also handles the case where during ghost's first run
    // models.init() inserts this post but permissions.init() hasn't
    // (can't) run yet.
    if (defaultPostSlugs.indexOf(post.slug) > -1) {
        return;
    }

    // Build XML object.
    pingXML = xml({
        methodCall: [{
            methodName: 'weblogUpdate.ping'
        }, {
            params: [{
                param: [{
                    value: [{
                        string: title
                    }]
                }]
            }, {
                param: [{
                    value: [{
                        string: url
                    }]
                }]
            }]
        }]
    }, {declaration: true});

    // Ping each of the defined services.
    _.each(pingList, function (pingHost) {
        var options = {
            body: pingXML,
            timeout: 2 * 1000
        };

        request(pingHost.url, options)
            .catch(function (err) {
                common.logging.error(new common.errors.GhostError({
                    err: err,
                    message: err.message,
                    context: common.i18n.t('errors.services.ping.requestFailed.error', {service: 'slack'}),
                    help: common.i18n.t('errors.services.ping.requestFailed.help', {url: 'http://docs.ghost.org'})
                }));
            });
    });
}

function listener(model, options) {
    // CASE: do not rpc ping if we import a database<commit_msg>Fixed error message for failed xmlrpc request<commit_after>var _ = require('lodash'),
    xml = require('xml'),
    config = require('../config'),
    urlService = require('../services/url'),
    common = require('../lib/common'),
    request = require('../lib/request'),
    settingsCache = require('./settings/cache'),

    defaultPostSlugs = [
        'welcome',
        'the-editor',
        'using-tags',
        'managing-users',
        'private-sites',
        'advanced-markdown',
        'themes'
    ],
    // ToDo: Make this configurable
    pingList = [
        {
            url: 'blogsearch.google.com/ping/RPC2'
        },
        {
            url: 'rpc.pingomatic.com'
        }
    ];

function ping(post) {
    var pingXML,
        title = post.title,
        url = urlService.utils.urlFor('post', {post: post}, true);

    if (post.page || config.isPrivacyDisabled('useRpcPing') || settingsCache.get('is_private')) {
        return;
    }

    // Don't ping for the default posts.
    // This also handles the case where during ghost's first run
    // models.init() inserts this post but permissions.init() hasn't
    // (can't) run yet.
    if (defaultPostSlugs.indexOf(post.slug) > -1) {
        return;
    }

    // Build XML object.
    pingXML = xml({
        methodCall: [{
            methodName: 'weblogUpdate.ping'
        }, {
            params: [{
                param: [{
                    value: [{
                        string: title
                    }]
                }]
            }, {
                param: [{
                    value: [{
                        string: url
                    }]
                }]
            }]
        }]
    }, {declaration: true});

    // Ping each of the defined services.
    _.each(pingList, function (pingHost) {
        var options = {
            body: pingXML,
            timeout: 2 * 1000
        };

        request(pingHost.url, options)
            .catch(function (err) {
                common.logging.error(new common.errors.GhostError({
                    err: err,
                    message: err.message,
                    context: common.i18n.t('errors.services.ping.requestFailed.error', {service: 'xmlrpc'}),
                    help: common.i18n.t('errors.services.ping.requestFailed.help', {url: 'http://docs.ghost.org'})
                }));
            });
    });
}

function listener(model, options) {
    // CASE: do not rpc ping if we import a database
{'fraction_non_alphanumeric': 0.13807106598984772, 'fraction_numerical': 0.004467005076142132, 'mean_word_length': 1.45440956651719, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, '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': '5692504', 'n_tokens_mistral': 1442, 'n_tokens_neox': 1339, 'n_words': 291}