PR feedback: Better handling of real name and email
This commit is contained in:
@@ -505,9 +505,9 @@ class Achievements {
|
||||
getFormatObject(info) {
|
||||
return {
|
||||
userName: info.user.username,
|
||||
userRealName: info.user.realName(),
|
||||
userLocation: info.user.properties[UserProps.Location],
|
||||
userAffils: info.user.properties[UserProps.Affiliations],
|
||||
userRealName: info.user.realName(false) || 'N/A',
|
||||
userLocation: info.user.properties[UserProps.Location] || 'N/A',
|
||||
userAffils: info.user.properties[UserProps.Affiliations] || 'N/A',
|
||||
nodeId: info.client.node,
|
||||
title: info.details.title,
|
||||
//text : info.global ? info.details.globalText : info.details.text,
|
||||
|
||||
@@ -87,7 +87,7 @@ function getActiveConnectionList(
|
||||
//
|
||||
entry.text = ac.user?.username || 'N/A';
|
||||
entry.userName = ac.user?.username || 'N/A';
|
||||
entry.realName = ac.user?.realName() || 'N/A';
|
||||
entry.realName = ac.user?.realName(false) || 'N/A';
|
||||
entry.location = ac.user?.getProperty(UserProps.Location) || 'N/A';
|
||||
entry.affils = entry.affiliation =
|
||||
ac.user?.getProperty(UserProps.Affiliations) || 'N/A';
|
||||
|
||||
20
core/user.js
20
core/user.js
@@ -124,15 +124,29 @@ module.exports = class User {
|
||||
return isMember;
|
||||
}
|
||||
|
||||
realName() {
|
||||
return this.getProperty(UserProps.RealName) || this.username;
|
||||
realName(withUsernameFallback = true) {
|
||||
const realName = this.getProperty(UserProps.RealName);
|
||||
if (realName) {
|
||||
return realName;
|
||||
}
|
||||
if (withUsernameFallback) {
|
||||
return this.username;
|
||||
}
|
||||
}
|
||||
|
||||
getSanitizedName(type = 'username') {
|
||||
const name = 'real' === type ? this.realName() : this.username;
|
||||
const name = 'real' === type ? this.realName(true) : this.username;
|
||||
return sanatizeFilename(name) || `user${this.userId.toString()}`;
|
||||
}
|
||||
|
||||
emailAddress() {
|
||||
const email = this.getProperty(UserProps.EmailAddress);
|
||||
if (email) {
|
||||
const realName = this.realName(false);
|
||||
return realName ? `${realName} <${email}>` : email;
|
||||
}
|
||||
}
|
||||
|
||||
isAvailable() {
|
||||
return (this.statusFlags & User.StatusFlags.NotAvailable) == 0;
|
||||
}
|
||||
|
||||
@@ -93,9 +93,7 @@ module.exports = class User2FA_OTPWebRegister {
|
||||
}
|
||||
|
||||
const message = {
|
||||
to: `${user.realName()} <${user.getProperty(
|
||||
UserProps.EmailAddress
|
||||
)}>`,
|
||||
to: user.emailAddress(),
|
||||
// from will be filled in
|
||||
subject: '2-Factor Authentication Registration',
|
||||
text: textTemplate,
|
||||
|
||||
@@ -233,7 +233,7 @@ exports.getModule = class UserConfigModule extends MenuModule {
|
||||
function populateViews(callback) {
|
||||
const user = self.client.user;
|
||||
|
||||
self.setViewText('menu', MciCodeIds.RealName, user.realName());
|
||||
self.setViewText('menu', MciCodeIds.RealName, user.realName(false) || '');
|
||||
self.setViewText(
|
||||
'menu',
|
||||
MciCodeIds.BirthDate,
|
||||
|
||||
@@ -143,9 +143,7 @@ class WebPasswordReset {
|
||||
}
|
||||
|
||||
const message = {
|
||||
to: `${user.realName()} <${
|
||||
user.properties[UserProps.EmailAddress]
|
||||
}>`,
|
||||
to: user.emailAddress(),
|
||||
// from will be filled in
|
||||
subject: 'Forgot Password',
|
||||
text: textTemplate,
|
||||
|
||||
@@ -506,7 +506,7 @@ exports.getModule = class WaitingForCallerModule extends MenuModule {
|
||||
|
||||
// Current
|
||||
currentUserName: this.client.user.username,
|
||||
currentUserRealName: this.client.user.realName(),
|
||||
currentUserRealName: this.client.user.realName(false) || 'N/A',
|
||||
availIndicator: availIndicator,
|
||||
visIndicator: visIndicator,
|
||||
lastLoginUserName: lastLoginStats.userName,
|
||||
|
||||
Reference in New Issue
Block a user