### codetube
    Copyright (C) 2011 payload payload@lavabit.com
    Copyright (C) 2011 dodo dodo.the.last@gmail.com

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.

    You should have received a copy of the GNU Affero General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>
###

Model = require('./skeleton')

class Activity extends Model
    __spaceholder__: null # coffeescript bug or feature?
    defaults:
        type: "activity"
        date: new Date()
        kind: "<custom>"
    mapping:
        watchers: (x) -> {_id: y._id} for y in x

    constructor: (kind, args...) ->
        if typeof kind is 'string'
            throw Error("Kind #{kind} not found.") unless this[kind]
            activity = this[kind].apply(this, args)
            unless activity.kind and activity.kind isnt @defaults.kind
                activity.kind = kind
            super activity
        else
            super

    # kined definitions

    'new project': (project) ->
        watchers = [project.owner]
            #.concat project.watchers
            #.concat project.owner.watchers
        #[].push.apply watchers, (x.watchers for x in project.contributors)

        watchers: watchers
        project:
            _id: project._id
        user: _id: project.owner._id

    'push': (user, project) ->
        {}

# exports

module.exports = Activity

