mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-15 05:41:51 +00:00
utils: safety checks to resolveUser; ignore a tslint error
This commit is contained in:
parent
4f8dc4f0ae
commit
5a1cf205a7
1 changed files with 6 additions and 2 deletions
|
@ -404,7 +404,7 @@ export function downloadFile(attachmentUrl: string, retries = 3): Promise<{ path
|
|||
if (retries === 0) {
|
||||
throw httpsErr;
|
||||
} else {
|
||||
console.warn("File download failed, retrying. Error given:", httpsErr.message);
|
||||
console.warn("File download failed, retrying. Error given:", httpsErr.message); // tslint:disable-line
|
||||
resolve(downloadFile(attachmentUrl, retries - 1));
|
||||
}
|
||||
});
|
||||
|
@ -650,6 +650,10 @@ export async function resolveUser(bot: Client, value: string): Promise<User | Un
|
|||
|
||||
// If we have the user cached, return that directly
|
||||
const userId = resolveUserId(bot, value);
|
||||
if (!userId) {
|
||||
return new UnknownUser({ id: userId });
|
||||
}
|
||||
|
||||
if (bot.users.has(userId)) {
|
||||
return bot.users.get(userId);
|
||||
}
|
||||
|
@ -660,7 +664,7 @@ export async function resolveUser(bot: Client, value: string): Promise<User | Un
|
|||
return new UnknownUser({ id: userId });
|
||||
}
|
||||
|
||||
const freshUser = await bot.getRESTUser(userId);
|
||||
const freshUser = await bot.getRESTUser(userId).catch(noop);
|
||||
if (freshUser) {
|
||||
bot.users.add(freshUser, bot);
|
||||
return freshUser;
|
||||
|
|
Loading…
Add table
Reference in a new issue