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.

64 lines 2.19 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.EventFilter = void 0; const constants_1 = require("./constants"); const utils_1 = require("./utils"); class EventFilter { constructor(threadTypes, specificIds, messageContentTypes = []) { this.threadTypes = threadTypes; this.specificIds = specificIds; this.messageContentTypes = messageContentTypes; } shouldProcessMessage(message) { var _a; const threadType = this.getThreadType(message.type); if (!this.threadTypes.includes(threadType)) { return false; } if (!this.checkSpecificId(message.threadId || ((_a = message.data) === null || _a === void 0 ? void 0 : _a.uidFrom))) { return false; } if (this.messageContentTypes.length > 0) { const contentType = (0, utils_1.getMessageContentType)(message); if (!this.messageContentTypes.includes(contentType)) { return false; } } return true; } shouldProcessReaction(reaction) { var _a; const threadType = reaction.isGroup ? 'group' : 'user'; if (!this.threadTypes.includes(threadType)) { return false; } if (!this.checkSpecificId(reaction.threadId || ((_a = reaction.data) === null || _a === void 0 ? void 0 : _a.uidFrom))) { return false; } return true; } shouldProcessTyping(typing) { const threadType = this.getThreadType(typing.type); if (!this.threadTypes.includes(threadType)) { return false; } if (!this.checkSpecificId(typing.threadId)) { return false; } return true; } getThreadType(type) { return type === constants_1.ThreadTypeValue.User ? 'user' : 'group'; } checkSpecificId(threadId) { if (this.specificIds.length === 0) { return true; } if (!threadId) { return false; } return this.specificIds.includes(String(threadId)); } } exports.EventFilter = EventFilter; //# sourceMappingURL=EventFilter.js.map