Fix bad condition on hiding email addresses and update user etag to include privacy settings (#3327)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
a0cc913b85
Коммит
8f87e60231
@@ -795,11 +795,11 @@ func getMe(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
c.RemoveSessionCookie(w, r)
|
||||
l4g.Error(utils.T("api.user.get_me.getting.error"), c.Session.UserId)
|
||||
return
|
||||
} else if HandleEtag(result.Data.(*model.User).Etag(), w, r) {
|
||||
} else if HandleEtag(result.Data.(*model.User).Etag(utils.Cfg.PrivacySettings.ShowFullName, utils.Cfg.PrivacySettings.ShowEmailAddress), w, r) {
|
||||
return
|
||||
} else {
|
||||
result.Data.(*model.User).Sanitize(map[string]bool{})
|
||||
w.Header().Set(model.HEADER_ETAG_SERVER, result.Data.(*model.User).Etag())
|
||||
w.Header().Set(model.HEADER_ETAG_SERVER, result.Data.(*model.User).Etag(utils.Cfg.PrivacySettings.ShowFullName, utils.Cfg.PrivacySettings.ShowEmailAddress))
|
||||
w.Write([]byte(result.Data.(*model.User).ToJson()))
|
||||
return
|
||||
}
|
||||
@@ -906,11 +906,11 @@ func getUser(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
if result := <-Srv.Store.User().Get(id); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return
|
||||
} else if HandleEtag(result.Data.(*model.User).Etag(), w, r) {
|
||||
} else if HandleEtag(result.Data.(*model.User).Etag(utils.Cfg.PrivacySettings.ShowFullName, utils.Cfg.PrivacySettings.ShowEmailAddress), w, r) {
|
||||
return
|
||||
} else {
|
||||
result.Data.(*model.User).Sanitize(map[string]bool{})
|
||||
w.Header().Set(model.HEADER_ETAG_SERVER, result.Data.(*model.User).Etag())
|
||||
w.Header().Set(model.HEADER_ETAG_SERVER, result.Data.(*model.User).Etag(utils.Cfg.PrivacySettings.ShowFullName, utils.Cfg.PrivacySettings.ShowEmailAddress))
|
||||
w.Write([]byte(result.Data.(*model.User).ToJson()))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -244,8 +244,8 @@ func (u *User) ToJson() string {
|
||||
}
|
||||
|
||||
// Generate a valid strong etag so the browser can cache the results
|
||||
func (u *User) Etag() string {
|
||||
return Etag(u.Id, u.UpdateAt)
|
||||
func (u *User) Etag(showFullName, showEmail bool) string {
|
||||
return Etag(u.Id, u.UpdateAt, showFullName, showEmail)
|
||||
}
|
||||
|
||||
func (u *User) IsOffline() bool {
|
||||
|
||||
@@ -33,7 +33,7 @@ func TestUserJson(t *testing.T) {
|
||||
func TestUserPreSave(t *testing.T) {
|
||||
user := User{Password: "test"}
|
||||
user.PreSave()
|
||||
user.Etag()
|
||||
user.Etag(true, true)
|
||||
}
|
||||
|
||||
func TestUserPreUpdate(t *testing.T) {
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/mattermost/platform/model"
|
||||
"github.com/mattermost/platform/utils"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -485,9 +486,9 @@ func (s SqlUserStore) GetEtagForDirectProfiles(userId string) StoreChannel {
|
||||
ORDER BY UpdateAt DESC LIMIT 1
|
||||
`, map[string]interface{}{"UserId": userId})
|
||||
if err != nil {
|
||||
result.Data = fmt.Sprintf("%v.%v", model.CurrentVersion, model.GetMillis())
|
||||
result.Data = fmt.Sprintf("%v.%v.%v.%v", model.CurrentVersion, model.GetMillis(), utils.Cfg.PrivacySettings.ShowFullName, utils.Cfg.PrivacySettings.ShowEmailAddress)
|
||||
} else {
|
||||
result.Data = fmt.Sprintf("%v.%v", model.CurrentVersion, updateAt)
|
||||
result.Data = fmt.Sprintf("%v.%v.%v.%v", model.CurrentVersion, updateAt, utils.Cfg.PrivacySettings.ShowFullName, utils.Cfg.PrivacySettings.ShowEmailAddress)
|
||||
}
|
||||
|
||||
storeChannel <- result
|
||||
@@ -505,9 +506,9 @@ func (s SqlUserStore) GetEtagForAllProfiles() StoreChannel {
|
||||
|
||||
updateAt, err := s.GetReplica().SelectInt("SELECT UpdateAt FROM Users ORDER BY UpdateAt DESC LIMIT 1")
|
||||
if err != nil {
|
||||
result.Data = fmt.Sprintf("%v.%v", model.CurrentVersion, model.GetMillis())
|
||||
result.Data = fmt.Sprintf("%v.%v.%v.%v", model.CurrentVersion, model.GetMillis(), utils.Cfg.PrivacySettings.ShowFullName, utils.Cfg.PrivacySettings.ShowEmailAddress)
|
||||
} else {
|
||||
result.Data = fmt.Sprintf("%v.%v", model.CurrentVersion, updateAt)
|
||||
result.Data = fmt.Sprintf("%v.%v.%v.%v", model.CurrentVersion, updateAt, utils.Cfg.PrivacySettings.ShowFullName, utils.Cfg.PrivacySettings.ShowEmailAddress)
|
||||
}
|
||||
|
||||
storeChannel <- result
|
||||
@@ -557,9 +558,9 @@ func (s SqlUserStore) GetEtagForProfiles(teamId string) StoreChannel {
|
||||
|
||||
updateAt, err := s.GetReplica().SelectInt("SELECT UpdateAt FROM Users, TeamMembers WHERE TeamMembers.TeamId = :TeamId AND Users.Id = TeamMembers.UserId ORDER BY UpdateAt DESC LIMIT 1", map[string]interface{}{"TeamId": teamId})
|
||||
if err != nil {
|
||||
result.Data = fmt.Sprintf("%v.%v", model.CurrentVersion, model.GetMillis())
|
||||
result.Data = fmt.Sprintf("%v.%v.%v.%v", model.CurrentVersion, model.GetMillis(), utils.Cfg.PrivacySettings.ShowFullName, utils.Cfg.PrivacySettings.ShowEmailAddress)
|
||||
} else {
|
||||
result.Data = fmt.Sprintf("%v.%v", model.CurrentVersion, updateAt)
|
||||
result.Data = fmt.Sprintf("%v.%v.%v.%v", model.CurrentVersion, updateAt, utils.Cfg.PrivacySettings.ShowFullName, utils.Cfg.PrivacySettings.ShowEmailAddress)
|
||||
}
|
||||
|
||||
storeChannel <- result
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
import * as Utils from 'utils/utils.jsx';
|
||||
import Client from 'utils/web_client.jsx';
|
||||
|
||||
import {FormattedMessage} from 'react-intl';
|
||||
|
||||
import {Popover, OverlayTrigger} from 'react-bootstrap';
|
||||
|
||||
var id = 0;
|
||||
@@ -22,6 +20,7 @@ export default class UserProfile extends React.Component {
|
||||
super(props);
|
||||
this.uniqueId = nextId();
|
||||
}
|
||||
|
||||
shouldComponentUpdate(nextProps) {
|
||||
if (!Utils.areObjectsEqual(nextProps.user, this.props.user)) {
|
||||
return true;
|
||||
@@ -45,6 +44,7 @@ export default class UserProfile extends React.Component {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
render() {
|
||||
let name = '...';
|
||||
let email = '';
|
||||
@@ -78,19 +78,7 @@ export default class UserProfile extends React.Component {
|
||||
/>
|
||||
);
|
||||
|
||||
if (!global.window.mm_config.ShowEmailAddress === 'true') {
|
||||
dataContent.push(
|
||||
<div
|
||||
className='text-nowrap'
|
||||
key='user-popover-no-email'
|
||||
>
|
||||
<FormattedMessage
|
||||
id='user_profile.notShared'
|
||||
defaultMessage='Email not shared'
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
} else {
|
||||
if (global.window.mm_config.ShowEmailAddress === 'true') {
|
||||
dataContent.push(
|
||||
<div
|
||||
data-toggle='tooltip'
|
||||
|
||||
@@ -1455,7 +1455,6 @@
|
||||
"user.settings.security.title": "Security Settings",
|
||||
"user.settings.security.viewHistory": "View Access History",
|
||||
"user_list.notFound": "No users found",
|
||||
"user_profile.notShared": "Email not shared",
|
||||
"view_image.loading": "Loading ",
|
||||
"view_image_popover.download": "Download",
|
||||
"view_image_popover.file": "File {count} of {total}",
|
||||
|
||||
@@ -1444,7 +1444,6 @@
|
||||
"user.settings.security.title": "Configuración de Seguridad",
|
||||
"user.settings.security.viewHistory": "Visualizar historial de acceso",
|
||||
"user_list.notFound": "No se encontraron usuarios",
|
||||
"user_profile.notShared": "Correo no compartido",
|
||||
"view_image.loading": "Cargando ",
|
||||
"view_image_popover.download": "Descargar",
|
||||
"view_image_popover.file": "Archivo {count} de {total}",
|
||||
|
||||
@@ -1442,7 +1442,6 @@
|
||||
"user.settings.security.title": "Paramètres de sécurité",
|
||||
"user.settings.security.viewHistory": "Voir l'historique des accès",
|
||||
"user_list.notFound": "Aucun utilisateur trouvé.",
|
||||
"user_profile.notShared": "L'adresse électronique n'est pas partagée",
|
||||
"view_image.loading": "Chargement ",
|
||||
"view_image_popover.download": "Télécharger",
|
||||
"view_image_popover.file": "Fichier {count} sur {total}",
|
||||
|
||||
@@ -1442,7 +1442,6 @@
|
||||
"user.settings.security.title": "セキュリティーの設定",
|
||||
"user.settings.security.viewHistory": "アクセス履歴を見る",
|
||||
"user_list.notFound": "ユーザーが見付かりません",
|
||||
"user_profile.notShared": "電子メールは共有されません",
|
||||
"view_image.loading": "読み込み中です ",
|
||||
"view_image_popover.download": "ダウンロードする",
|
||||
"view_image_popover.file": "ファイル {count} / {total}",
|
||||
|
||||
@@ -1442,7 +1442,6 @@
|
||||
"user.settings.security.title": "Configurações de Segurança",
|
||||
"user.settings.security.viewHistory": "Ver Histórico de Acesso",
|
||||
"user_list.notFound": "Nenhum usuário encontrado",
|
||||
"user_profile.notShared": "E-mail não compartilhado",
|
||||
"view_image.loading": "Carregando ",
|
||||
"view_image_popover.download": "Download",
|
||||
"view_image_popover.file": "Arquivo {count} de {total}",
|
||||
|
||||
Ссылка в новой задаче
Block a user