Skip to content

Commit

Permalink
fix: set-name
Browse files Browse the repository at this point in the history
  • Loading branch information
mvayngrib committed Mar 13, 2018
1 parent 0632346 commit 4522991
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/in-house-bot/commands/addfriend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
}

Expand Down
17 changes: 8 additions & 9 deletions src/in-house-bot/plugins/set-name.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand All @@ -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
Expand Down

0 comments on commit 4522991

Please sign in to comment.