// allow all characters except colon, whitespace, comma, >, <, &, ", ', /, \, (, )
		// more practical than allowing specific sets of characters; also allows foreign languages
		const nameValidation = /[\s,:><&"'\/\\\(\)]/;

		// silently strip colon; this allows for uploading :soundname: as soundname
		soundData.name = soundData.name.replace(/:/g, '');

		if (nameValidation.test(soundData.name)) {
			throw new Meteor.Error('error-input-is-not-a-valid-field', `${ soundData.name } is not a valid name`, { method: 'insertOrUpdateSound', input: soundData.name, field: 'Name' });
		}

		let matchingResults = [];

		if (soundData._id) {
			matchingResults = CustomSounds.findByNameExceptID(soundData.name, soundData._id).fetch();
		} else {
			matchingResults = CustomSounds.findByName(soundData.name).fetch();
		}

		if (matchingResults.length > 0) {
			throw new Meteor.Error('Custom_Sound_Error_Name_Already_In_Use', 'The custom sound name is already in use', { method: 'insertOrUpdateSound' });
		}

		if (!soundData._id) {
			// insert sound
			const createSound = {
				name: soundData.name,
				extension: soundData.extension,
			};
import { Meteor } from 'meteor/meteor';
import { CustomSounds } from 'meteor/rocketchat:models';

Meteor.methods({
	listCustomSounds() {
		return CustomSounds.find({}).fetch();
	},
});