From c01dd505afc8988a5aeabe678d1abe82e85ff354 Mon Sep 17 00:00:00 2001 From: ohdarling88 Date: Thu, 18 Jun 2020 10:13:15 +0800 Subject: [PATCH] add index suffix to duplicated group names --- lib/providers/dingtalk.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/providers/dingtalk.js b/lib/providers/dingtalk.js index e8d9f14..fd6307b 100644 --- a/lib/providers/dingtalk.js +++ b/lib/providers/dingtalk.js @@ -107,6 +107,17 @@ async function fetchAllDepartments() { }); allDeps = Object.values(depsMap); + const allDepNames = {}; + allDeps.forEach(v => { + let name = v.name; + let idx = 2; + while (allDepNames[name]) { + name = v.name + idx; + idx++; + } + allDepNames[name] = 1; + v.name = name; + }) saveCacheToFile('dingtalk_groups.json', allDeps); }