overleaf/services/web/app/coffee/models/ProjectInvite.coffee

43 lines
998 B
CoffeeScript
Raw Normal View History

mongoose = require 'mongoose'
Settings = require 'settings-sharelatex'
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
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}}
},
{
collection: 'projectInvites'
}
)
conn = mongoose.createConnection(Settings.mongo.url, server: poolSize: Settings.mongo.poolSize || 10)
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