Skip to content

Commit

Permalink
SWIK-2375 use new user attribute displayName
Browse files Browse the repository at this point in the history
  • Loading branch information
dpaun committed Jul 20, 2018
1 parent 3d084a9 commit a1d7754
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions application/controllers/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,9 +383,11 @@ function insertAuthor(activity) {
} else {
rp.get({uri: Microservices.user.uri + '/user/' + activity.user_id}).then((res) => {
let username = '';
let displayName = undefined;
try {
let parsed = JSON.parse(res);
username = parsed.username;
displayName = parsed.displayName;
} catch(e) {
console.log(e);
activity.author = {
Expand All @@ -397,7 +399,8 @@ function insertAuthor(activity) {

activity.author = {
id: activity.user_id,
username: username
username: username,
displayName: displayName
};
resolve(activity);

Expand Down Expand Up @@ -446,11 +449,13 @@ function insertAuthors(activities) {
userDataArray.forEach((userData) => {
let userId = userData._id;
let username = userData.username;
let displayName = userData.displayName;
activities.forEach((activity) => {
if (parseInt(activity.user_id) === userId) {
activity.author = {
id: activity.user_id,
username: username
username: username,
displayName: displayName
};
}
});
Expand Down

0 comments on commit a1d7754

Please sign in to comment.