diff --git a/context/config.example.js b/context/config.example.js index 6a0c8d5..fdc1590 100644 --- a/context/config.example.js +++ b/context/config.example.js @@ -24,6 +24,10 @@ module.exports = { channels: { mergeDiscussionIntoParent: true, }, + posts: { + // Экспортировать посты только начиная с этой даты (ISO 8601). Если не задано - экспортируются все посты. + fromDate: '2026-05-18T00:00:00.000Z', + }, user: { globalRoleMap: { admin: 'system_admin', diff --git a/lib/rocketchat/posts.js b/lib/rocketchat/posts.js index c4d2779..4f90629 100644 --- a/lib/rocketchat/posts.js +++ b/lib/rocketchat/posts.js @@ -16,8 +16,10 @@ module.exports = async function (context) { let written = 0 let memReplyIds = {} - const total = await collection.count() - const cursor = collection.find() + const fromDate = _.get(context, 'config.define.posts.fromDate') + const query = fromDate ? { ts: { $gte: new Date(fromDate) } } : {} + const total = await collection.count(query) + const cursor = collection.find(query) while (await cursor.hasNext()) { const result = await cursor.next() let posts = await collectPostData(context, result, memReplyIds, false)