mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-23 19:03:09 +02:00
parent
43f3f8a058
commit
2a9de356db
1 changed files with 36 additions and 28 deletions
|
@ -30,7 +30,12 @@ export async function importUserLists(job: Bull.Job, done: any): Promise<void> {
|
|||
|
||||
const csv = await downloadTextFile(file.url);
|
||||
|
||||
let linenum = 0;
|
||||
|
||||
for (const line of csv.trim().split('\n')) {
|
||||
linenum++;
|
||||
|
||||
try {
|
||||
const listName = line.split(',')[0].trim();
|
||||
const { username, host } = parseAcct(line.split(',')[1].trim());
|
||||
|
||||
|
@ -64,6 +69,9 @@ export async function importUserLists(job: Bull.Job, done: any): Promise<void> {
|
|||
if (await UserListJoinings.findOne({ userListId: list.id, userId: target.id }) != null) continue;
|
||||
|
||||
pushUserToUserList(target, list);
|
||||
} catch (e) {
|
||||
logger.warn(`Error in line:${linenum} ${e}`);
|
||||
}
|
||||
}
|
||||
|
||||
logger.succ('Imported');
|
||||
|
|
Loading…
Reference in a new issue