{"size": 556, "ext": "js", "max_stars_repo_path": "packages/api-main/pubsubListeners/messageForBot.js", "max_stars_repo_name": "momentechnologies/Slugin", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "packages/api-main/pubsubListeners/messageForBot.js", "max_issues_repo_name": "momentechnologies/Slugin", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "packages/api-main/pubsubListeners/messageForBot.js", "max_forks_repo_name": "momentechnologies/Slugin", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 29.2631578947, "max_line_length": 74, "alphanum_fraction": 0.535971223}
const PubSubUtils = require('../api/utils/pubsub');

module.exports = () => {
    PubSubUtils.getSubscription('message', 'bot_listener').then(
        subscription => {
            const messageHandler = message => {
                const threadMessage = JSON.parse(message.data.toString());

                if (!threadMessage.isFromClient) {
                    return message.ack();
                }
            };

            // Listen for new messages until timeout is hit
            subscription.on(`message`, messageHandler);
        }
    );
};
