mirror of
https://iceshrimp.dev/crimekillz/trashposs
synced 2024-11-22 17:03:49 +01:00
parent
c0927a24be
commit
949ed1e48a
@ -28,7 +28,12 @@ export async function importFollowing(job: Bull.Job, done: any): Promise<void> {
|
||||
|
||||
const csv = await downloadTextFile(url);
|
||||
|
||||
let linenum = 0;
|
||||
|
||||
for (const line of csv.trim().split('\n')) {
|
||||
linenum++;
|
||||
|
||||
try {
|
||||
const { username, host } = parseAcct(line.trim());
|
||||
|
||||
let target = isSelfHost(host) ? await User.findOne({
|
||||
@ -45,12 +50,19 @@ export async function importFollowing(job: Bull.Job, done: any): Promise<void> {
|
||||
target = await resolveUser(username, host);
|
||||
}
|
||||
|
||||
if (target == null) {
|
||||
throw `cannot resolve user: @${username}@${host}`;
|
||||
}
|
||||
|
||||
// skip myself
|
||||
if (target._id.equals(job.data.user._id)) continue;
|
||||
|
||||
logger.info(`Follow ${target._id} ...`);
|
||||
logger.info(`Follow[${linenum}] ${target._id} ...`);
|
||||
|
||||
follow(user, target);
|
||||
} catch (e) {
|
||||
logger.warn(`Error in line:${linenum} ${e}`);
|
||||
}
|
||||
}
|
||||
|
||||
logger.succ('Imported');
|
||||
|
Loading…
Reference in New Issue
Block a user