Skip to content

Commit

Permalink
fix(server): fix function templates user information (#1405)
Browse files Browse the repository at this point in the history
  • Loading branch information
HUAHUAI23 authored Jul 14, 2023
1 parent 1d22b6e commit c559cbd
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions server/src/function-template/function-template.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,24 @@ export class FunctionTemplateService {
.aggregate(pipe)
.toArray()

const user = await this.db.collection<User>('User').findOne({
_id: functionTemplate[0].uid,
})

if (user.phone && user.username) {
if (user.phone == user.username) {
user.username =
user.username.slice(0, 3) +
'x'.repeat(user.username.length - 6) +
user.username.slice(-3)
}
}

functionTemplate[0]['user'] = {
username: user?.username,
email: user?.email,
}

return functionTemplate
}

Expand Down Expand Up @@ -1615,24 +1633,6 @@ export class FunctionTemplateService {
.collection<FunctionTemplate>('FunctionTemplate')
.findOne({ _id: templateId })

const user = await this.db.collection<User>('User').findOne({
_id: res.uid,
})

if (user.phone && user.username) {
if (user.phone == user.username) {
user.username =
user.username.slice(0, 3) +
'x'.repeat(user.username.length - 6) +
user.username.slice(-3)
}
}

res['user'] = {
username: user?.username,
email: user?.email,
}

return res
}

Expand Down

0 comments on commit c559cbd

Please sign in to comment.