mirror of
https://github.com/wekan/wekan.git
synced 2026-02-20 23:14:07 +01:00
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
26 lines
942 B
JavaScript
26 lines
942 B
JavaScript
import { ReactiveCache } from '/imports/reactiveCache';
|
|
|
|
export async function getMembersToMap(data) {
|
|
// we will work on the list itself (an ordered array of objects) when a
|
|
// mapping is done, we add a 'wekan' field to the object representing the
|
|
// imported member
|
|
const membersToMap = data.members;
|
|
const users = data.users;
|
|
// auto-map based on username
|
|
for (const importedMember of membersToMap) {
|
|
importedMember.id = importedMember.userId;
|
|
delete importedMember.userId;
|
|
const user = users.filter(user => {
|
|
return user._id === importedMember.id;
|
|
})[0];
|
|
if (user.profile && user.profile.fullname) {
|
|
importedMember.fullName = user.profile.fullname;
|
|
}
|
|
importedMember.username = user.username;
|
|
const wekanUser = await ReactiveCache.getUser({ username: importedMember.username });
|
|
if (wekanUser) {
|
|
importedMember.wekanId = wekanUser._id;
|
|
}
|
|
}
|
|
return membersToMap;
|
|
}
|