fix(YouTube Node): Issue in published before and after dates filters (#11741)

This commit is contained in:
Shireen Missi
2024-11-14 16:02:26 +00:00
committed by GitHub
parent d9259a2d93
commit 7381c28af0
3 changed files with 69 additions and 26 deletions

View File

@@ -1,16 +1,18 @@
import type {
IExecuteFunctions,
ILoadOptionsFunctions,
ICredentialTestFunctions,
IDataObject,
IPollFunctions,
IRequestOptions,
import {
type IExecuteFunctions,
type ILoadOptionsFunctions,
type ICredentialTestFunctions,
type IDataObject,
type IPollFunctions,
type IRequestOptions,
NodeOperationError,
} from 'n8n-workflow';
import moment from 'moment-timezone';
import * as jwt from 'jsonwebtoken';
import { formatPrivateKey } from '@utils/utilities';
import { DateTime } from 'luxon';
const googleServiceAccountScopes = {
bigquery: ['https://www.googleapis.com/auth/bigquery'],
@@ -110,3 +112,20 @@ export async function getGoogleAccessToken(
return await this.helpers.request(options);
}
export function validateAndSetDate(
filter: IDataObject,
key: string,
timezone: string,
context: IExecuteFunctions,
) {
const date = DateTime.fromISO(filter[key] as string);
if (date.isValid) {
filter[key] = date.setZone(timezone).toISO();
} else {
throw new NodeOperationError(
context.getNode(),
`The value "${filter[key] as string}" is not a valid DateTime.`,
);
}
}