mirror of
https://github.com/nodemailer/wildduck.git
synced 2025-10-25 13:37:13 +08:00
Log invalid magic's
This commit is contained in:
parent
ee4a76e30e
commit
c13cd6b1c3
3 changed files with 14 additions and 3 deletions
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
const GridFSBucket = require('mongodb').GridFSBucket;
|
const GridFSBucket = require('mongodb').GridFSBucket;
|
||||||
const libbase64 = require('libbase64');
|
const libbase64 = require('libbase64');
|
||||||
|
const errors = require('../errors');
|
||||||
|
|
||||||
// Set to false to disable base64 decoding feature
|
// Set to false to disable base64 decoding feature
|
||||||
const FEATURE_DECODE_ATTACHMENTS = true;
|
const FEATURE_DECODE_ATTACHMENTS = true;
|
||||||
|
|
@ -50,6 +51,10 @@ class GridstoreStorage {
|
||||||
transferEncoding: attachment.transferEncoding
|
transferEncoding: attachment.transferEncoding
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (!isNaN(metadata.m)) {
|
||||||
|
errors.notify(new Error('Invalid magic "' + metadata.m + '" for ' + id));
|
||||||
|
}
|
||||||
|
|
||||||
Object.keys(attachment.metadata || {}).forEach(key => {
|
Object.keys(attachment.metadata || {}).forEach(key => {
|
||||||
if (!(key in attachment.metadata)) {
|
if (!(key in attachment.metadata)) {
|
||||||
metadata[key] = attachment.metadata[key];
|
metadata[key] = attachment.metadata[key];
|
||||||
|
|
@ -193,6 +198,9 @@ class GridstoreStorage {
|
||||||
}
|
}
|
||||||
|
|
||||||
delete(id, magic, callback) {
|
delete(id, magic, callback) {
|
||||||
|
if (!isNaN(magic)) {
|
||||||
|
errors.notify(new Error('Invalid magic "' + magic + '" for ' + id));
|
||||||
|
}
|
||||||
this.gridfs.collection(this.bucketName + '.files').findOneAndUpdate({
|
this.gridfs.collection(this.bucketName + '.files').findOneAndUpdate({
|
||||||
_id: id
|
_id: id
|
||||||
}, {
|
}, {
|
||||||
|
|
@ -231,6 +239,9 @@ class GridstoreStorage {
|
||||||
}
|
}
|
||||||
|
|
||||||
update(ids, count, magic, callback) {
|
update(ids, count, magic, callback) {
|
||||||
|
if (!isNaN(magic)) {
|
||||||
|
errors.notify(new Error('Invalid magic "' + magic + '" for ' + ids));
|
||||||
|
}
|
||||||
// update attachments
|
// update attachments
|
||||||
this.gridfs.collection(this.bucketName + '.files').updateMany(
|
this.gridfs.collection(this.bucketName + '.files').updateMany(
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
/* eslint global-require: 0 */
|
/* eslint global-require: 0, no-console: 0 */
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const config = require('wild-config');
|
const config = require('wild-config');
|
||||||
|
|
@ -12,5 +12,7 @@ if (config.bugsnagCode) {
|
||||||
module.exports.notify = (...args) => {
|
module.exports.notify = (...args) => {
|
||||||
if (bugsnag) {
|
if (bugsnag) {
|
||||||
bugsnag.notify(...args);
|
bugsnag.notify(...args);
|
||||||
|
} else {
|
||||||
|
console.error(...args);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,6 @@ const packageData = require('./package.json');
|
||||||
log.level = config.log.level;
|
log.level = config.log.level;
|
||||||
require('./logger');
|
require('./logger');
|
||||||
|
|
||||||
errors.notify(new Error('Starting mail server application'));
|
|
||||||
|
|
||||||
const printLogo = () => {
|
const printLogo = () => {
|
||||||
let logo = fs
|
let logo = fs
|
||||||
.readFileSync(__dirname + '/logo.txt', 'utf-8')
|
.readFileSync(__dirname + '/logo.txt', 'utf-8')
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue