2017-05-10 14:31:17 +00:00
|
|
|
mongoose = require 'mongoose'
|
2016-03-17 17:01:26 +00:00
|
|
|
Settings = require 'settings-sharelatex'
|
|
|
|
|
2016-07-22 15:08:56 +00:00
|
|
|
|
2016-03-17 17:01:26 +00:00
|
|
|
Schema = mongoose.Schema
|
|
|
|
ObjectId = Schema.ObjectId
|
|
|
|
|
2016-07-21 13:20:09 +00:00
|
|
|
|
2016-08-12 13:40:59 +00:00
|
|
|
EXPIRY_IN_SECONDS = 60 * 60 * 24 * 30
|
|
|
|
|
|
|
|
ExpiryDate = () ->
|
|
|
|
timestamp = new Date()
|
|
|
|
timestamp.setSeconds(timestamp.getSeconds() + EXPIRY_IN_SECONDS)
|
|
|
|
return timestamp
|
|
|
|
|
2016-07-21 13:20:09 +00:00
|
|
|
|
|
|
|
|
2016-07-25 14:07:14 +00:00
|
|
|
ProjectInviteSchema = new Schema(
|
|
|
|
{
|
|
|
|
email: String
|
|
|
|
token: String
|
|
|
|
sendingUserId: ObjectId
|
|
|
|
projectId: ObjectId
|
|
|
|
privileges: String
|
2016-08-12 13:40:59 +00:00
|
|
|
createdAt: {type: Date, default: Date.now}
|
|
|
|
expires: {type: Date, default: ExpiryDate, index: {expireAfterSeconds: 10}}
|
2016-07-25 14:07:14 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
collection: 'projectInvites'
|
|
|
|
}
|
|
|
|
)
|
2016-07-22 15:08:56 +00:00
|
|
|
|
2016-03-17 17:01:26 +00:00
|
|
|
|
|
|
|
conn = mongoose.createConnection(Settings.mongo.url, server: poolSize: Settings.mongo.poolSize || 10)
|
|
|
|
|
2016-07-22 15:08:56 +00:00
|
|
|
|
2016-03-17 17:01:26 +00:00
|
|
|
ProjectInvite = conn.model('ProjectInvite', ProjectInviteSchema)
|
|
|
|
|
|
|
|
mongoose.model 'ProjectInvite', ProjectInviteSchema
|
|
|
|
exports.ProjectInvite = ProjectInvite
|
2016-07-21 13:20:09 +00:00
|
|
|
exports.ProjectInviteSchema = ProjectInviteSchema
|
2016-08-12 13:40:59 +00:00
|
|
|
exports.EXPIRY_IN_SECONDS = EXPIRY_IN_SECONDS
|