Skip to content

Commit

Permalink
SAK-25024 forums > use UserDirectoryService to resolve author names d…
Browse files Browse the repository at this point in the history
…ynamically (sakaiproject#8700)
  • Loading branch information
bjones86 authored Oct 16, 2020
1 parent 1d13ba9 commit 7c43bd4
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
import org.sakaiproject.component.cover.ComponentManager;
import org.sakaiproject.tool.api.SessionManager;
import org.sakaiproject.tool.api.ToolManager;
import org.sakaiproject.user.api.User;
import org.sakaiproject.user.api.UserNotDefinedException;
import org.sakaiproject.user.cover.UserDirectoryService;

/**
Expand Down Expand Up @@ -503,7 +505,23 @@ private AnonymousManager getAnonymousManager()
*/
public String getAnonAwareAuthor()
{
return isUseAnonymousId() ? getAnonId() : message.getAuthor();
if (isUseAnonymousId())
{
return getAnonId();
}
else
{
String authorID = getAuthorEid();
try
{
User author = UserDirectoryService.getUser(authorID);
return author.getDisplayName();
}
catch (UserNotDefinedException e)
{
return message.getAuthor();
}
}
}

/**
Expand Down

0 comments on commit 7c43bd4

Please sign in to comment.