Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
forceMigration () {
this.setErrorMessage('')
if (this.state.migration) {
Meteor.call(MigrationMethods.forceMigration,
this.state.migration.chunks,
(err) => {
if (this.cancelRequests) return
if (err) {
logger.error(err)
// todo: notify user
this.setErrorMessage(err)
} else {
this.setState({
migrationCompleted: true,
haveRunMigration: true
})
this.updateVersions()
}
})
sendInvitation = (options) => Meteor.call("accounts/inviteShopMember", options, (error, result) => {
if (error) {
let messageKey;
// switching to use of package i18n keys (groupsInvite. namespace)
if (error.reason === "Unable to send invitation email.") {
messageKey = "admin.groupsInvite.unableToSendInvitationEmail";
} else if (error.reason === "cannot directly invite owner") {
messageKey = "admin.groupsInvite.inviteOwnerError";
} else if (error.reason === "cannot invite to group") {
messageKey = "admin.groupsInvite.cannotInvite";
} else if (error.reason === "Need to set a username or email") {
messageKey = "admin.groupsInvite.NeedToSetUsernameOrEmail";
} else {
messageKey = "admin.groupsInvite.errorSendingInvite";
}
const { alertId } = this.state;
updateMailConfiguration () {
// Try if settings exist
try {
// Get Settings collection
const settings = Settings.findOne();
// Enable/disable accounts email features based on email configuration
if (settings.mail.enabled) {
// Configure system SMTP variable for sending mail
Meteor.call('configureSmtpSettings', settings);
// Enable accounts email related features (validation, reset password)
Meteor.call('enableAccountEmailSettings');
} else {
// No email verification or reset password functionality
Meteor.call('disableAccountEmailSettings');
}
} catch (error) {
// otherwise preapare message about error
const message = `Update mail configuration: ${error}`;
// Show an error message
throw new Meteor.Error(message);
}
},
});
if (dataPoint.fields) {
influx.writePoints([
dataPoint
]).catch(err => {
if (err.message !== 'No host available') {
if (err.errno !== 'ECONNREFUSED') console.error(`Error saving data to InfluxDB! ${err.stack}`);
}
});
}
}
if (event.type === 'alert') {
let key = _.keys(event.message)[0];
let notification = 'Alert: ' + key + ' ' + event.message[key];
Meteor.call('Notifications.new',
notification,
thing.owner,
(error, document) => {
if (error) {
console.error('New notification error', error);
}
}
);
}
return !!Events.insert({
thing: {
_id: thing._id
},
event: event,
insertedAt: new Date()
deleteFeed () {
Meteor.call('liveFeed.delete', this.state.clickFeed, function (err) {
if (err) {
alert(err);
}
});
this.closeFeed();
}
render () {
action: prevent(getUser, ({ _id, username }) => {
const userModerator = RoomRoles.findOne({ rid: Session.get('openedRoom'), 'u._id': _id, roles: 'moderator' }, { fields: { _id: 1 } });
if (userModerator != null) {
return;
}
Meteor.call('addRoomModerator', Session.get('openedRoom'), _id, success(() => {
const room = ChatRoom.findOne(Session.get('openedRoom'));
toastr.success(TAPi18n.__('User__username__is_now_a_moderator_of__room_name_', { username, room_name: room.name }));
}));
}),
};
.then(() => {
Meteor.call("media/insert", fileRecord.document, (error) => {
if (error) Alerts.toast(error.reason, "error");
this.setState({ uploadProgress: null });
});
return null;
})
.catch((error) => {
'click .webdav-account-remove'(e) {
e.preventDefault();
const selectEl = document.getElementById('webdav-accounts');
const { options } = selectEl;
const selectedOption = selectEl.value;
const optionIndex = Array.from(options).findIndex((option) => option.value === selectedOption);
Meteor.call('removeWebdavAccount', selectedOption, function(error) {
if (error) {
return toastr.error(t(error.error));
}
toastr.success(t('webdav-account-removed'));
modal.close();
});
selectEl.remove(optionIndex);
},
});
'click #updateShuffledCardset': function () {
let removedCardsets = $(Cardsets.findOne({_id: Router.current().params._id}).cardGroups).not(Session.get("ShuffledCardsets")).get();
Meteor.call("updateShuffleGroups", Router.current().params._id, Session.get("ShuffledCardsets"), removedCardsets, function (error, result) {
if (error) {
BertAlertVisuals.displayBertAlert(TAPi18n.__('set-list.shuffleUpdateFailure'), 'danger', 'growl-top-left');
}
if (result) {
Session.set('activeCard', undefined);
BertAlertVisuals.displayBertAlert(TAPi18n.__('set-list.shuffleUpdateSuccess'), 'success', 'growl-top-left');
Router.go('cardsetdetailsid', {_id: Router.current().params._id});
}
});
},
'click #cancelUpdateShuffle': function () {
const markAsRead = (ids, callback) => {
Meteor.call('notifications.markAsRead', ids, callback);
};