Merge pull request #2119 from overleaf/ta-subscription-deletion

Store Deleted Subscriptions

GitOrigin-RevId: c7004f1807dee6b6ec82eeb2a8fe939801ce3e8b
This commit is contained in:
Eric Mc Sween
2019-09-09 12:05:23 +00:00
committed by sharelatex
parent bc233e6eba
commit d0fc8d90e5
12 changed files with 286 additions and 32 deletions
@@ -0,0 +1,42 @@
const mongoose = require('mongoose')
const Settings = require('settings-sharelatex')
const { SubscriptionSchema } = require('./Subscription')
const { Schema } = mongoose
const { ObjectId } = Schema
const DeleterDataSchema = new Schema(
{
deleterId: { type: ObjectId, ref: 'User' },
deleterIpAddress: { type: String },
deletedAt: {
type: Date,
default() {
return new Date()
}
}
},
{ _id: false }
)
const DeletedSubscriptionSchema = new Schema(
{
deleterData: DeleterDataSchema,
subscription: SubscriptionSchema
},
{ collection: 'deletedSubscriptions' }
)
const conn = mongoose.createConnection(Settings.mongo.url, {
server: { poolSize: Settings.mongo.poolSize || 10 },
config: { autoIndex: false }
})
const DeletedSubscription = conn.model(
'DeletedSubscription',
DeletedSubscriptionSchema
)
mongoose.model('DeletedSubscription', DeletedSubscriptionSchema)
exports.DeletedSubscription = DeletedSubscription
exports.DeletedSubscriptionSchema = DeletedSubscriptionSchema