fix(task): make sure users can be assigned via quick add magic via their real name as well

See https://kolaente.dev/vikunja/frontend/issues/2196#issuecomment-36206
This commit is contained in:
kolaente 2022-09-30 21:20:26 +02:00
parent 72b731d620
commit f8450f58a4
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B

View file

@ -38,9 +38,11 @@ function findPropertyByValue(object, key, value) {
) )
} }
// Check if the user exists // Check if the user exists in the search results
function validateUsername(users: IUser[], username: IUser['username']) { function validateUser(users: IUser[], username: IUser['username']) {
return findPropertyByValue(users, 'username', username) return findPropertyByValue(users, 'username', username) ||
findPropertyByValue(users, 'name', username) ||
findPropertyByValue(users, 'email', username)
} }
// Check if the label exists // Check if the label exists
@ -67,7 +69,7 @@ async function findAssignees(parsedTaskAssignees: string[]) {
const userService = new UserService() const userService = new UserService()
const assignees = parsedTaskAssignees.map(async a => { const assignees = parsedTaskAssignees.map(async a => {
const users = await userService.getAll({}, {s: a}) const users = await userService.getAll({}, {s: a})
return validateUsername(users, a) return validateUser(users, a)
}) })
const validatedUsers = await Promise.all(assignees) const validatedUsers = await Promise.all(assignees)