rename /rpg-docs to /app
This commit is contained in:
27
app/server/lib/configuration/accountsMeldConfig.js
Normal file
27
app/server/lib/configuration/accountsMeldConfig.js
Normal file
@@ -0,0 +1,27 @@
|
||||
AccountsMeld.configure({
|
||||
meldDBCallback: function(sourceUserId, destinationUserId){
|
||||
// Here you can modify every collection you need for the document referencing
|
||||
// to sourceUserId to be modified in order to point to destinationUserId
|
||||
Characters.update(
|
||||
{owner: sourceUserId},
|
||||
{$set: {owner: destinationUserId}},
|
||||
{multi: true}
|
||||
);
|
||||
Characters.update(
|
||||
{writers: sourceUserId},
|
||||
{
|
||||
$pull: {writers: sourceUserId},
|
||||
$addToSet: {writers: destinationUserId},
|
||||
},
|
||||
{multi: true}
|
||||
);
|
||||
Characters.update(
|
||||
{readers: sourceUserId},
|
||||
{
|
||||
$pull: {readers: sourceUserId},
|
||||
$addToSet: {readers: destinationUserId},
|
||||
},
|
||||
{multi: true}
|
||||
);
|
||||
},
|
||||
});
|
||||
45
app/server/lib/cron/deleteRemovedDocuments.js
Normal file
45
app/server/lib/cron/deleteRemovedDocuments.js
Normal file
@@ -0,0 +1,45 @@
|
||||
Meteor.startup(() => {
|
||||
const collections = [
|
||||
Attacks, Buffs, Classes, CustomBuffs, Effects, Experiences,
|
||||
Features, Notes, Proficiencies, SpellLists, Spells,
|
||||
Containers, Items,
|
||||
];
|
||||
|
||||
/**
|
||||
* Deletes all soft removed documents that were removed more than 30 minutes ago
|
||||
* and were not restored
|
||||
* @return {Number} Number of documents removed
|
||||
*/
|
||||
const deleteOldSoftRemovedDocs = function(){
|
||||
let numRemoved = 0;
|
||||
const now = new Date();
|
||||
const thirtyMinutesAgo = new Date(now.getTime() - 30*60000);
|
||||
_.each(collections, (collection) => {
|
||||
numRemoved += collection.remove({
|
||||
removed: true,
|
||||
removedAt: {$lt: thirtyMinutesAgo} // dates *before* 30 minutes ago
|
||||
});
|
||||
});
|
||||
return numRemoved;
|
||||
};
|
||||
|
||||
SyncedCron.add({
|
||||
name: "Delete all soft removed items that haven't been restored",
|
||||
schedule: function(parser) {
|
||||
return parser.text('every 6 hours');
|
||||
},
|
||||
job: function() {
|
||||
deleteOldSoftRemovedDocs();
|
||||
}
|
||||
});
|
||||
|
||||
// Add a method to manually trigger removal
|
||||
Meteor.methods({
|
||||
deleteOldSoftRemovedDocs() {
|
||||
const user = Meteor.users.findOne(this.userId);
|
||||
if (user && _.contains(user.roles, "admin")){
|
||||
return deleteOldSoftRemovedDocs();
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
8
app/server/lib/logRateError.js
Normal file
8
app/server/lib/logRateError.js
Normal file
@@ -0,0 +1,8 @@
|
||||
logRateError = function(reply, ruleInput){
|
||||
// reply = {allowed, timeToReset, numInvocationsLeft}
|
||||
// ruleInput = {userId, clientAddress, type, name, connectionId}
|
||||
console.log(
|
||||
`Limit hit for ${ruleInput.type} "${ruleInput.name}" ` +
|
||||
`by user ${ruleInput.userId} from ${ruleInput.clientAddress}`
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user