diff options
author | Angelo Gallarello <angelo.gallarell@gmail.com> | 2019-02-12 23:40:12 +0100 |
---|---|---|
committer | Angelo Gallarello <angelo.gallarell@gmail.com> | 2019-02-12 23:40:12 +0100 |
commit | 477d71e0b90d15b54945a1a04cb0a649344075ae (patch) | |
tree | 3eccde9b00ff3d35b98e960cbb755c177ee14bda /models/wekanmapper.js | |
parent | d22964bcfd46ea4fd4860528b0c5e6f5d90812b6 (diff) | |
download | wekan-477d71e0b90d15b54945a1a04cb0a649344075ae.tar.gz wekan-477d71e0b90d15b54945a1a04cb0a649344075ae.tar.bz2 wekan-477d71e0b90d15b54945a1a04cb0a649344075ae.zip |
Fixes
Diffstat (limited to 'models/wekanmapper.js')
-rw-r--r-- | models/wekanmapper.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/models/wekanmapper.js b/models/wekanmapper.js new file mode 100644 index 00000000..f4c110f7 --- /dev/null +++ b/models/wekanmapper.js @@ -0,0 +1,24 @@ +export 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 + membersToMap.forEach((importedMember) => { + 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 = Users.findOne({ username: importedMember.username }); + if (wekanUser) { + importedMember.wekanId = wekanUser._id; + } + }); + return membersToMap; +} |