/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */
"use strict";

//TODO ensure repo exists.
//TODO ensure necessary rights are granted -> repo?

const Board = require("./board");

/**
 * Basic class that manages the events for a single repo.
 */
class ContentQueue {
    /**
     * @param {PromisifiedGitHub} githubClient - GitHub client from github
     *                                               authenticated for a user.
     * @param {external:TwitterClient} twitterClient - Authenticated for a user.
     * @param {Object} config - Config for this project
     * @constructs
     */
    constructor(githubClient, twitterClient, config) {
        const [ owner, repo ] = config.repo.split("/");
        config.owner = owner;
        config.repo = repo;

        this.config = config;
        this.board = new Board(githubClient, config);
    }
}

module.exports = ContentQueue;

@@ -332,16 +332,205 @@
 ard%22);%0A%0A
+const DEFAULT_LABELS = %7B%0A    retweet: %22Retweet%22,%0A    ready: %22ready%22,%0A    invalid: %22invalid%22%0A%7D;%0A%0Aconst LABEL_COLORS = %7B%0A    retweet: %2237FC00%22,%0A    ready: %22FFFFFF%22,%0A    invalid: %22FC4700%22%0A%7D;%0A%0A
 /**%0A * B
@@ -1116,81 +1116,1495 @@
     
-this.config = config;%0A        this.board = new Board(githubClient, config
+config.labels = Object.assign(Object.assign(%7B%7D, DEFAULT_LABELS), config.lables);%0A%0A        this.config = config;%0A        this.githubClient = githubClient;%0A        this.ensureLabels();%0A%0A        this.board = new Board(githubClient, config);%0A    %7D%0A%0A    /**%0A     * Makes sure the used labels exist for the repository.%0A     *%0A     * @async%0A     * @returns %7Bundefined%7D%0A     */%0A    ensureLabels() %7B%0A        return Promise.all(Object.values(this.config.lables).map((label) =%3E %7B%0A            if(!this.hasLabel(label)) %7B%0A                return this.addLabel(label, LABEL_COLORS%5Blabel%5D);%0A            %7D%0A            return Promise.resolve();%0A        %7D));%0A    %7D%0A%0A    /**%0A     * Checks if a label exists for the repository.%0A     *%0A     * @param %7Bstring%7D name - Name of the label.%0A     * @async%0A     * @returns %7Bboolean%7D Whether the label exists.%0A     */%0A    hasLabel(name) %7B%0A        return this.githubClient(%22issues%22, %22getLabel%22, %7B%0A            owner: this.config.owner,%0A            repo: this.config.repo,%0A            name%0A        %7D).then(() =%3E true, () =%3E false);%0A    %7D%0A%0A    /**%0A     * Add a label to the repository.%0A     *%0A     * @param %7Bstring%7D name - Name of the label.%0A     * @param %7Bstring%7D color - Hex color of the label without leading #.%0A     * @async%0A     * @returns %7Bundefined%7D%0A     */%0A    addLabel(name, color) %7B%0A        return this.githubClient(%22issues%22, %22createLabel%22, %7B%0A            owner: this.config.owner,%0A            repo: this.config.repo,%0A            name,%0A            color%0A        %7D
 );%0A 

Make sure we have the labels