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