Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/rospirotorg.ru/bitrix/js/pull/connector/src/codec/ |
Upload File : |
export class ChannelManager { constructor(params) { this.publicIds = {}; this.restClient = params.restClient ?? BX.rest; this.getPublicListMethod = params.getPublicListMethod; } /** * * @param {Array} users Array of user ids. * @return {Promise} */ getPublicIds(users): Promise { const now = new Date(); const result = {}; const unknownUsers = []; for (const userId of users) { if (this.publicIds[userId] && this.publicIds[userId].end > now) { result[userId] = this.publicIds[userId]; } else { unknownUsers.push(userId); } } if (unknownUsers.length === 0) { return Promise.resolve(result); } return new Promise((resolve, reject) => { this.restClient.callMethod(this.getPublicListMethod, { users: unknownUsers }).then((response) => { if (response.error()) { resolve({}); } else { const data = response.data(); this.setPublicIds(Object.values(data)); for (const userId of unknownUsers) { result[userId] = this.publicIds[userId]; } resolve(result); } }).catch((e) => reject(e)); }); } /** * * @param {object[]} publicIds * @param {integer} publicIds.user_id * @param {string} publicIds.public_id * @param {string} publicIds.signature * @param {Date} publicIds.start * @param {Date} publicIds.end */ setPublicIds(publicIds) { for (const publicIdDescriptor of publicIds) { const userId = publicIdDescriptor.user_id; this.publicIds[userId] = { userId, publicId: publicIdDescriptor.public_id, signature: publicIdDescriptor.signature, start: new Date(publicIdDescriptor.start), end: new Date(publicIdDescriptor.end), }; } } }