From 452299123aed1e7af97503d04c6793cf0921ab9d Mon Sep 17 00:00:00 2001 From: Mark Vayngrib Date: Tue, 13 Mar 2018 17:02:41 -0400 Subject: [PATCH] fix: set-name --- src/in-house-bot/commands/addfriend.ts | 4 ++-- src/in-house-bot/plugins/set-name.ts | 17 ++++++++--------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/in-house-bot/commands/addfriend.ts b/src/in-house-bot/commands/addfriend.ts index a1aa6267f..f174fc538 100644 --- a/src/in-house-bot/commands/addfriend.ts +++ b/src/in-house-bot/commands/addfriend.ts @@ -58,8 +58,8 @@ export const command:ICommand = { await users.save({ id: userId, friend: friendStub }) } - if (user && user.friend !== friend.permalink) { - user.friend = friend.permalink + if (user && !isEqual(user.friend, friendStub)) { + user.friend = friendStub await users.merge({ id: userId, friend: friendStub }) } diff --git a/src/in-house-bot/plugins/set-name.ts b/src/in-house-bot/plugins/set-name.ts index 81fe8af0c..ac55e7041 100644 --- a/src/in-house-bot/plugins/set-name.ts +++ b/src/in-house-bot/plugins/set-name.ts @@ -27,9 +27,13 @@ export const createPlugin = ({ bot, productsAPI }: { } const trySetName = async (req) => { - const name = await getName(req) - if (name) { - req.application.applicantName = name + try { + const name = await getName(req) + if (name) { + req.application.applicantName = name + } + } catch (err) { + logger.error('failed to get applicant name', err) } } @@ -50,12 +54,7 @@ export const createPlugin = ({ bot, productsAPI }: { const { friend } = user if (!friend) return - const fRes = await bot.getResource({ - type: 'tradle.MyCloudFriend', - permalink: friend - }) - - return fRes.name + return (await bot.getResourceByStub(friend)).name } let form