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