From e0562a230155aba48e19f4986dc0f79f8cd2afa1 Mon Sep 17 00:00:00 2001 From: Shane Kilkelly Date: Thu, 21 Jul 2016 14:20:09 +0100 Subject: [PATCH] Update ProjectInvite model --- .../app/coffee/models/ProjectInvite.coffee | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/services/web/app/coffee/models/ProjectInvite.coffee b/services/web/app/coffee/models/ProjectInvite.coffee index 3349dafa9b..1181454d74 100644 --- a/services/web/app/coffee/models/ProjectInvite.coffee +++ b/services/web/app/coffee/models/ProjectInvite.coffee @@ -4,15 +4,21 @@ Settings = require 'settings-sharelatex' Schema = mongoose.Schema ObjectId = Schema.ObjectId +THIRTY_DAYS_IN_SECONDS = 60 * 60 * 24 * 30 + +makeExpirationDate = () -> + nowInMillis = Date.now() + new Date(nowInMillis + (1000 * THIRTY_DAYS_IN_SECONDS)) + + ProjectInviteSchema = new Schema - project_id: ObjectId - from_user_id: ObjectId - privilegeLevel: String - # For existing users - to_user_id: ObjectId - # For non-existant users - hashed_token: String email: String + token: String + sendingUserId: ObjectId + projectId: ObjectId + privileges: String + createdAt: {type: Date, default: Date.now} + expiresAt: {type: Date, default: makeExpirationDate} conn = mongoose.createConnection(Settings.mongo.url, server: poolSize: Settings.mongo.poolSize || 10) @@ -20,4 +26,4 @@ ProjectInvite = conn.model('ProjectInvite', ProjectInviteSchema) mongoose.model 'ProjectInvite', ProjectInviteSchema exports.ProjectInvite = ProjectInvite -exports.ProjectInviteSchema = ProjectInviteSchema \ No newline at end of file +exports.ProjectInviteSchema = ProjectInviteSchema