UNPKG

n8n-nodes-zalo-nnt

Version:

Unofficial Zalo integration for n8n - Send messages, manage groups, user operations with QR login. No API key required, works via browser simulation.

71 lines 2.6 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.validateQuote = validateQuote; exports.validateMentions = validateMentions; exports.validateStyles = validateStyles; exports.isValidUrl = isValidUrl; exports.validateThreadId = validateThreadId; function validateQuote(quoteData) { const requiredFields = ['msgId', 'uidFrom', 'content', 'cliMsgId', 'ts']; const missingFields = requiredFields.filter(field => !quoteData[field] || quoteData[field] === ''); if (missingFields.length > 0) { throw new Error(`Quote message missing required fields: ${missingFields.join(', ')}. ` + `Please fill in all required fields from the message you want to quote.`); } } function validateMentions(mentions, messageLength) { if (!mentions || mentions.length === 0) return; let totalMentionLen = 0; for (const mention of mentions) { if (!mention.uid) { throw new Error('Mention must have uid field'); } if (mention.len <= 0) { throw new Error(`Invalid mention length: ${mention.len}`); } if (mention.pos < 0) { throw new Error(`Invalid mention position: ${mention.pos}`); } if (mention.pos + mention.len > messageLength) { throw new Error(`Mention at position ${mention.pos} with length ${mention.len} ` + `exceeds message length (${messageLength})`); } totalMentionLen += mention.len; } if (totalMentionLen > messageLength) { throw new Error(`Invalid mentions: total mention length (${totalMentionLen}) ` + `exceeds message length (${messageLength})`); } } function validateStyles(styles, messageLength) { if (!styles || styles.length === 0) return; for (const style of styles) { if (style.start < 0) { throw new Error(`Invalid style start position: ${style.start}`); } if (style.len <= 0) { throw new Error(`Invalid style length: ${style.len}`); } if (style.start + style.len > messageLength) { throw new Error(`Style at position ${style.start} with length ${style.len} ` + `exceeds message length (${messageLength})`); } } } function isValidUrl(url) { try { new URL(url); return true; } catch { return false; } } function validateThreadId(threadId) { if (!threadId || threadId.trim() === '') { throw new Error('Thread ID cannot be empty'); } } //# sourceMappingURL=validator.js.map