mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-02 14:38:49 +00:00
fix: updated logging for validators
This commit is contained in:
1 parent
22109823e1
commit
57fc1e3ee8
23 files changed
+118
-70
No files matched your search
@@ -1,6 +1,11 @@
|
||||
const logger = require('../../services/logger');
|
||||
exports.transformQuery = async ({ query, executionId }) => {
|
||||
const logger = require('../../services/logger').child({
|
||||
source: 'searchQueryValidator.js',
|
||||
module: 'validator',
|
||||
name: 'transformQuery',
|
||||
executionId: executionId
|
||||
});
|
||||
|
||||
exports.transformQuery = async (query) => {
|
||||
if (query.startsWith('https://open.spotify.com/')) {
|
||||
try {
|
||||
// regex to check for country-based Spotify url
|
||||
@@ -11,13 +16,13 @@ exports.transformQuery = async (query) => {
|
||||
|
||||
// if country-based, transform to normal Spotify url
|
||||
if (isCountryBased) {
|
||||
logger.debug(`Transforming country-based Spotify url to normal Spotify url from query ${query}.`);
|
||||
logger.debug(`Transforming country-based Spotify url to normal Spotify url from query '${query}'.`);
|
||||
const type = query.match(regex)[2];
|
||||
const trackId = query.match(regex)[3];
|
||||
query = `https://open.spotify.com/${type}/${trackId}`;
|
||||
}
|
||||
} catch (error) {
|
||||
logger.error(error);
|
||||
logger.error(error, 'Error while validating or transforming Spotify url.');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user