fix(YouTube Node): Fix Date filters (#10725)
Some checks are pending
Test Master / install-and-build (push) Waiting to run
Test Master / Unit tests (18.x) (push) Blocked by required conditions
Test Master / Unit tests (20.x) (push) Blocked by required conditions
Test Master / Unit tests (22.4) (push) Blocked by required conditions
Test Master / Lint (push) Blocked by required conditions
Test Master / Notify Slack on failure (push) Blocked by required conditions
Benchmark Docker Image CI / build (push) Waiting to run

This commit is contained in:
Shireen Missi 2024-09-11 09:44:35 +01:00 committed by GitHub
parent 4f94319cd9
commit 21936c88a8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -10,6 +10,7 @@ import type {
} from 'n8n-workflow';
import { NodeConnectionType, BINARY_ENCODING, NodeOperationError } from 'n8n-workflow';
import { DateTime } from 'luxon';
import { googleApiRequest, googleApiRequestAllItems } from './GenericFunctions';
import { channelFields, channelOperations } from './ChannelDescription';
@ -762,6 +763,28 @@ export class YouTube implements INodeType {
qs.type = 'video';
qs.forMine = true;
if (filters.publishedAfter) {
const publishedAfter = DateTime.fromISO(filters.publishedAfter as string);
if (publishedAfter.isValid) {
filters.publishedAfter = publishedAfter.setZone(this.getTimezone()).toISO();
} else {
throw new NodeOperationError(
this.getNode(),
`The value "${filters.publishedAfter as string}" is not a valid DateTime.`,
);
}
}
if (filters.publishedBefore) {
const publishedBefore = DateTime.fromISO(filters.publishedBefore as string);
if (publishedBefore.isValid) {
filters.publishedAfter = publishedBefore.setZone(this.getTimezone()).toISO();
} else {
throw new NodeOperationError(
this.getNode(),
`The value "${filters.publishedBefore as string}" is not a valid DateTime.`,
);
}
}
Object.assign(qs, options, filters);