2022-04-07 10:25:56 +02:00
|
|
|
import Attachments from '/models/attachments';
|
2021-04-06 12:42:15 +02:00
|
|
|
import { ObjectID } from 'bson';
|
|
|
|
|
|
Update ReactiveCache call sites to use async/await for Meteor 3.0
Part 3 of ReactiveCache async migration:
- Add await before all ReactiveCache.getX() calls
- Make functions containing ReactiveCache calls async
- Convert forEach/map/filter loops with async callbacks to for...of
- Update model helpers, Meteor methods, JsonRoutes handlers
- Update collection hooks (.before/.after insert/update/remove)
- Update .allow() callbacks to async
Files updated across models/ and server/ directories:
- Model files: cards, boards, lists, swimlanes, activities, users,
checklists, checklistItems, customFields, attachments, integrations,
cardComments, settings files, creators, exporters, and more
- Server files: publications, methods, notifications, routes, migrations
2026-02-01 00:54:38 +02:00
|
|
|
Meteor.publish('attachmentsList', async function(limit) {
|
2025-12-29 17:03:02 +02:00
|
|
|
const userId = this.userId;
|
|
|
|
|
|
|
|
|
|
// Get boards the user has access to
|
Update ReactiveCache call sites to use async/await for Meteor 3.0
Part 3 of ReactiveCache async migration:
- Add await before all ReactiveCache.getX() calls
- Make functions containing ReactiveCache calls async
- Convert forEach/map/filter loops with async callbacks to for...of
- Update model helpers, Meteor methods, JsonRoutes handlers
- Update collection hooks (.before/.after insert/update/remove)
- Update .allow() callbacks to async
Files updated across models/ and server/ directories:
- Model files: cards, boards, lists, swimlanes, activities, users,
checklists, checklistItems, customFields, attachments, integrations,
cardComments, settings files, creators, exporters, and more
- Server files: publications, methods, notifications, routes, migrations
2026-02-01 00:54:38 +02:00
|
|
|
const userBoards = (await ReactiveCache.getBoards({
|
2025-12-29 17:03:02 +02:00
|
|
|
$or: [
|
|
|
|
|
{ permission: 'public' },
|
|
|
|
|
{ members: { $elemMatch: { userId, isActive: true } } }
|
|
|
|
|
]
|
Update ReactiveCache call sites to use async/await for Meteor 3.0
Part 3 of ReactiveCache async migration:
- Add await before all ReactiveCache.getX() calls
- Make functions containing ReactiveCache calls async
- Convert forEach/map/filter loops with async callbacks to for...of
- Update model helpers, Meteor methods, JsonRoutes handlers
- Update collection hooks (.before/.after insert/update/remove)
- Update .allow() callbacks to async
Files updated across models/ and server/ directories:
- Model files: cards, boards, lists, swimlanes, activities, users,
checklists, checklistItems, customFields, attachments, integrations,
cardComments, settings files, creators, exporters, and more
- Server files: publications, methods, notifications, routes, migrations
2026-02-01 00:54:38 +02:00
|
|
|
})).map(board => board._id);
|
2025-12-29 17:03:02 +02:00
|
|
|
|
|
|
|
|
if (userBoards.length === 0) {
|
|
|
|
|
// User has no access to any boards, return empty cursor
|
|
|
|
|
return this.ready();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get cards from those boards
|
Update ReactiveCache call sites to use async/await for Meteor 3.0
Part 3 of ReactiveCache async migration:
- Add await before all ReactiveCache.getX() calls
- Make functions containing ReactiveCache calls async
- Convert forEach/map/filter loops with async callbacks to for...of
- Update model helpers, Meteor methods, JsonRoutes handlers
- Update collection hooks (.before/.after insert/update/remove)
- Update .allow() callbacks to async
Files updated across models/ and server/ directories:
- Model files: cards, boards, lists, swimlanes, activities, users,
checklists, checklistItems, customFields, attachments, integrations,
cardComments, settings files, creators, exporters, and more
- Server files: publications, methods, notifications, routes, migrations
2026-02-01 00:54:38 +02:00
|
|
|
const userCards = (await ReactiveCache.getCards({
|
2025-12-29 17:03:02 +02:00
|
|
|
boardId: { $in: userBoards },
|
|
|
|
|
archived: false
|
Update ReactiveCache call sites to use async/await for Meteor 3.0
Part 3 of ReactiveCache async migration:
- Add await before all ReactiveCache.getX() calls
- Make functions containing ReactiveCache calls async
- Convert forEach/map/filter loops with async callbacks to for...of
- Update model helpers, Meteor methods, JsonRoutes handlers
- Update collection hooks (.before/.after insert/update/remove)
- Update .allow() callbacks to async
Files updated across models/ and server/ directories:
- Model files: cards, boards, lists, swimlanes, activities, users,
checklists, checklistItems, customFields, attachments, integrations,
cardComments, settings files, creators, exporters, and more
- Server files: publications, methods, notifications, routes, migrations
2026-02-01 00:54:38 +02:00
|
|
|
})).map(card => card._id);
|
2025-12-29 17:03:02 +02:00
|
|
|
|
|
|
|
|
if (userCards.length === 0) {
|
|
|
|
|
// No cards found, return empty cursor
|
|
|
|
|
return this.ready();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Only return attachments for cards the user has access to
|
Update ReactiveCache call sites to use async/await for Meteor 3.0
Part 3 of ReactiveCache async migration:
- Add await before all ReactiveCache.getX() calls
- Make functions containing ReactiveCache calls async
- Convert forEach/map/filter loops with async callbacks to for...of
- Update model helpers, Meteor methods, JsonRoutes handlers
- Update collection hooks (.before/.after insert/update/remove)
- Update .allow() callbacks to async
Files updated across models/ and server/ directories:
- Model files: cards, boards, lists, swimlanes, activities, users,
checklists, checklistItems, customFields, attachments, integrations,
cardComments, settings files, creators, exporters, and more
- Server files: publications, methods, notifications, routes, migrations
2026-02-01 00:54:38 +02:00
|
|
|
const ret = (await ReactiveCache.getAttachments(
|
2025-12-29 17:03:02 +02:00
|
|
|
{ 'meta.cardId': { $in: userCards } },
|
2021-04-06 12:42:15 +02:00
|
|
|
{
|
|
|
|
|
fields: {
|
|
|
|
|
_id: 1,
|
2022-04-07 10:25:56 +02:00
|
|
|
name: 1,
|
|
|
|
|
size: 1,
|
|
|
|
|
type: 1,
|
|
|
|
|
meta: 1,
|
2022-04-08 00:27:56 +02:00
|
|
|
path: 1,
|
|
|
|
|
versions: 1,
|
2021-04-06 12:42:15 +02:00
|
|
|
},
|
|
|
|
|
sort: {
|
2022-04-07 10:25:56 +02:00
|
|
|
name: 1,
|
2021-04-06 12:42:15 +02:00
|
|
|
},
|
2022-04-08 00:27:56 +02:00
|
|
|
limit: limit,
|
2021-04-06 12:42:15 +02:00
|
|
|
},
|
2023-03-12 18:33:38 +01:00
|
|
|
true,
|
Update ReactiveCache call sites to use async/await for Meteor 3.0
Part 3 of ReactiveCache async migration:
- Add await before all ReactiveCache.getX() calls
- Make functions containing ReactiveCache calls async
- Convert forEach/map/filter loops with async callbacks to for...of
- Update model helpers, Meteor methods, JsonRoutes handlers
- Update collection hooks (.before/.after insert/update/remove)
- Update .allow() callbacks to async
Files updated across models/ and server/ directories:
- Model files: cards, boards, lists, swimlanes, activities, users,
checklists, checklistItems, customFields, attachments, integrations,
cardComments, settings files, creators, exporters, and more
- Server files: publications, methods, notifications, routes, migrations
2026-02-01 00:54:38 +02:00
|
|
|
)).cursor;
|
2022-04-07 10:25:56 +02:00
|
|
|
return ret;
|
2021-04-06 12:42:15 +02:00
|
|
|
});
|