PLT-6689: fix user image requests (#6946)
* fix user image requests * fix eslint errors and a few more cache busters
Этот коммит содержится в:
коммит произвёл
Christopher Speller
родитель
23a59b03dd
Коммит
673f3a1144
@@ -199,13 +199,6 @@ export default class Post extends React.PureComponent {
|
|||||||
const isSystemMessage = PostUtils.isSystemMessage(post);
|
const isSystemMessage = PostUtils.isSystemMessage(post);
|
||||||
const fromWebhook = post.props && post.props.from_webhook === 'true';
|
const fromWebhook = post.props && post.props.from_webhook === 'true';
|
||||||
|
|
||||||
let timestamp = 0;
|
|
||||||
if (!this.props.user || this.props.user.last_picture_update == null) {
|
|
||||||
timestamp = this.props.currentUser.last_picture_update;
|
|
||||||
} else {
|
|
||||||
timestamp = this.props.user.last_picture_update;
|
|
||||||
}
|
|
||||||
|
|
||||||
let status = this.props.status;
|
let status = this.props.status;
|
||||||
if (fromWebhook) {
|
if (fromWebhook) {
|
||||||
status = null;
|
status = null;
|
||||||
@@ -213,7 +206,7 @@ export default class Post extends React.PureComponent {
|
|||||||
|
|
||||||
let profilePic = (
|
let profilePic = (
|
||||||
<ProfilePicture
|
<ProfilePicture
|
||||||
src={PostUtils.getProfilePicSrcForPost(post, timestamp)}
|
src={PostUtils.getProfilePicSrcForPost(post, this.props.user)}
|
||||||
status={status}
|
status={status}
|
||||||
user={this.props.user}
|
user={this.props.user}
|
||||||
isBusy={this.props.isBusy}
|
isBusy={this.props.isBusy}
|
||||||
@@ -223,7 +216,7 @@ export default class Post extends React.PureComponent {
|
|||||||
if (fromWebhook) {
|
if (fromWebhook) {
|
||||||
profilePic = (
|
profilePic = (
|
||||||
<ProfilePicture
|
<ProfilePicture
|
||||||
src={PostUtils.getProfilePicSrcForPost(post, timestamp)}
|
src={PostUtils.getProfilePicSrcForPost(post, this.props.user)}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
} else if (PostUtils.isSystemMessage(post)) {
|
} else if (PostUtils.isSystemMessage(post)) {
|
||||||
|
|||||||
@@ -212,8 +212,6 @@ export default class RhsComment extends React.Component {
|
|||||||
const isEphemeral = Utils.isPostEphemeral(post);
|
const isEphemeral = Utils.isPostEphemeral(post);
|
||||||
const isSystemMessage = PostUtils.isSystemMessage(post);
|
const isSystemMessage = PostUtils.isSystemMessage(post);
|
||||||
|
|
||||||
var timestamp = this.props.currentUser.last_picture_update;
|
|
||||||
|
|
||||||
let status = this.props.status;
|
let status = this.props.status;
|
||||||
if (post.props && post.props.from_webhook === 'true') {
|
if (post.props && post.props.from_webhook === 'true') {
|
||||||
status = null;
|
status = null;
|
||||||
@@ -277,7 +275,7 @@ export default class RhsComment extends React.Component {
|
|||||||
|
|
||||||
let profilePic = (
|
let profilePic = (
|
||||||
<ProfilePicture
|
<ProfilePicture
|
||||||
src={PostUtils.getProfilePicSrcForPost(post, timestamp)}
|
src={PostUtils.getProfilePicSrcForPost(post, this.props.user)}
|
||||||
status={status}
|
status={status}
|
||||||
width='36'
|
width='36'
|
||||||
height='36'
|
height='36'
|
||||||
@@ -289,7 +287,7 @@ export default class RhsComment extends React.Component {
|
|||||||
if (post.props && post.props.from_webhook) {
|
if (post.props && post.props.from_webhook) {
|
||||||
profilePic = (
|
profilePic = (
|
||||||
<ProfilePicture
|
<ProfilePicture
|
||||||
src={PostUtils.getProfilePicSrcForPost(post, timestamp)}
|
src={PostUtils.getProfilePicSrcForPost(post, this.props.user)}
|
||||||
width='36'
|
width='36'
|
||||||
height='36'
|
height='36'
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -196,7 +196,6 @@ export default class RhsRootPost extends React.Component {
|
|||||||
const post = this.props.post;
|
const post = this.props.post;
|
||||||
const user = this.props.user;
|
const user = this.props.user;
|
||||||
const mattermostLogo = Constants.MATTERMOST_ICON_SVG;
|
const mattermostLogo = Constants.MATTERMOST_ICON_SVG;
|
||||||
var timestamp = user ? user.last_picture_update : 0;
|
|
||||||
var channel = ChannelStore.get(post.channel_id);
|
var channel = ChannelStore.get(post.channel_id);
|
||||||
|
|
||||||
const isEphemeral = Utils.isPostEphemeral(post);
|
const isEphemeral = Utils.isPostEphemeral(post);
|
||||||
@@ -303,7 +302,7 @@ export default class RhsRootPost extends React.Component {
|
|||||||
|
|
||||||
let profilePic = (
|
let profilePic = (
|
||||||
<ProfilePicture
|
<ProfilePicture
|
||||||
src={PostUtils.getProfilePicSrcForPost(post, timestamp)}
|
src={PostUtils.getProfilePicSrcForPost(post, user)}
|
||||||
status={status}
|
status={status}
|
||||||
width='36'
|
width='36'
|
||||||
height='36'
|
height='36'
|
||||||
@@ -315,7 +314,7 @@ export default class RhsRootPost extends React.Component {
|
|||||||
if (post.props && post.props.from_webhook) {
|
if (post.props && post.props.from_webhook) {
|
||||||
profilePic = (
|
profilePic = (
|
||||||
<ProfilePicture
|
<ProfilePicture
|
||||||
src={PostUtils.getProfilePicSrcForPost(post, timestamp)}
|
src={PostUtils.getProfilePicSrcForPost(post, user)}
|
||||||
width='36'
|
width='36'
|
||||||
height='36'
|
height='36'
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import ProfilePicture from './profile_picture.jsx';
|
|||||||
import CommentIcon from 'components/common/comment_icon.jsx';
|
import CommentIcon from 'components/common/comment_icon.jsx';
|
||||||
|
|
||||||
import TeamStore from 'stores/team_store.jsx';
|
import TeamStore from 'stores/team_store.jsx';
|
||||||
import UserStore from 'stores/user_store.jsx';
|
|
||||||
|
|
||||||
import AppDispatcher from '../dispatcher/app_dispatcher.jsx';
|
import AppDispatcher from '../dispatcher/app_dispatcher.jsx';
|
||||||
import * as GlobalActions from 'actions/global_actions.jsx';
|
import * as GlobalActions from 'actions/global_actions.jsx';
|
||||||
@@ -113,7 +112,6 @@ export default class SearchResultsItem extends React.Component {
|
|||||||
render() {
|
render() {
|
||||||
let channelName = null;
|
let channelName = null;
|
||||||
const channel = this.props.channel;
|
const channel = this.props.channel;
|
||||||
const timestamp = UserStore.getCurrentUser().last_picture_update;
|
|
||||||
const user = this.props.user || {};
|
const user = this.props.user || {};
|
||||||
const post = this.props.post;
|
const post = this.props.post;
|
||||||
|
|
||||||
@@ -154,7 +152,7 @@ export default class SearchResultsItem extends React.Component {
|
|||||||
|
|
||||||
const profilePic = (
|
const profilePic = (
|
||||||
<ProfilePicture
|
<ProfilePicture
|
||||||
src={PostUtils.getProfilePicSrcForPost(post, timestamp)}
|
src={PostUtils.getProfilePicSrcForPost(post, user)}
|
||||||
user={this.props.user}
|
user={this.props.user}
|
||||||
status={this.props.status}
|
status={this.props.status}
|
||||||
isBusy={this.props.isBusy}
|
isBusy={this.props.isBusy}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import {autocompleteUsersInChannel} from 'actions/user_actions.jsx';
|
|||||||
|
|
||||||
import AppDispatcher from 'dispatcher/app_dispatcher.jsx';
|
import AppDispatcher from 'dispatcher/app_dispatcher.jsx';
|
||||||
import * as Utils from 'utils/utils.jsx';
|
import * as Utils from 'utils/utils.jsx';
|
||||||
import {Client4} from 'mattermost-redux/client';
|
|
||||||
import {Constants, ActionTypes} from 'utils/constants.jsx';
|
import {Constants, ActionTypes} from 'utils/constants.jsx';
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
@@ -66,7 +65,7 @@ class AtMentionSuggestion extends Suggestion {
|
|||||||
icon = (
|
icon = (
|
||||||
<img
|
<img
|
||||||
className='mention__image'
|
className='mention__image'
|
||||||
src={Client4.getUsersRoute() + '/' + user.id + '/image?time=' + user.last_picture_update}
|
src={Utils.imageURLForUser(user)}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import Provider from './provider.jsx';
|
|||||||
import {autocompleteUsersInTeam} from 'actions/user_actions.jsx';
|
import {autocompleteUsersInTeam} from 'actions/user_actions.jsx';
|
||||||
|
|
||||||
import AppDispatcher from 'dispatcher/app_dispatcher.jsx';
|
import AppDispatcher from 'dispatcher/app_dispatcher.jsx';
|
||||||
import {Client4} from 'mattermost-redux/client';
|
|
||||||
import * as Utils from 'utils/utils.jsx';
|
import * as Utils from 'utils/utils.jsx';
|
||||||
import {ActionTypes} from 'utils/constants.jsx';
|
import {ActionTypes} from 'utils/constants.jsx';
|
||||||
|
|
||||||
@@ -41,7 +40,7 @@ class SearchUserSuggestion extends Suggestion {
|
|||||||
<i className='fa fa fa-plus-square'/>
|
<i className='fa fa fa-plus-square'/>
|
||||||
<img
|
<img
|
||||||
className='profile-img rounded'
|
className='profile-img rounded'
|
||||||
src={Client4.getUsersRoute() + '/' + item.id + '/image?time=' + item.last_picture_update}
|
src={Utils.imageURLForUser(item)}
|
||||||
/>
|
/>
|
||||||
<div className='mention--align'>
|
<div className='mention--align'>
|
||||||
<span>
|
<span>
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ class SwitchChannelSuggestion extends Suggestion {
|
|||||||
<div className='pull-left'>
|
<div className='pull-left'>
|
||||||
<img
|
<img
|
||||||
className='mention__image'
|
className='mention__image'
|
||||||
src={Client4.getUsersRoute() + '/' + channel.id + '/image?time=' + channel.last_picture_update}
|
src={Utils.imageURLForUser(channel)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -239,7 +239,8 @@ export default class SwitchChannelProvider extends Provider {
|
|||||||
name: user.username,
|
name: user.username,
|
||||||
id: user.id,
|
id: user.id,
|
||||||
update_at: user.update_at,
|
update_at: user.update_at,
|
||||||
type: Constants.DM_CHANNEL
|
type: Constants.DM_CHANNEL,
|
||||||
|
last_picture_update: user.last_picture_update || 0
|
||||||
},
|
},
|
||||||
name: user.username
|
name: user.username
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
import ProfilePopover from './profile_popover.jsx';
|
import ProfilePopover from './profile_popover.jsx';
|
||||||
import * as Utils from 'utils/utils.jsx';
|
import * as Utils from 'utils/utils.jsx';
|
||||||
import {Client4} from 'mattermost-redux/client';
|
|
||||||
|
|
||||||
import {OverlayTrigger} from 'react-bootstrap';
|
import {OverlayTrigger} from 'react-bootstrap';
|
||||||
|
|
||||||
@@ -59,7 +58,7 @@ export default class UserProfile extends React.Component {
|
|||||||
|
|
||||||
if (this.props.user) {
|
if (this.props.user) {
|
||||||
name = Utils.displayUsername(this.props.user.id);
|
name = Utils.displayUsername(this.props.user.id);
|
||||||
profileImg = Client4.getUsersRoute() + '/' + this.props.user.id + '/image?time=' + this.props.user.last_picture_update;
|
profileImg = Utils.imageURLForUser(this.props.user);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.props.overwriteName) {
|
if (this.props.overwriteName) {
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import SettingPicture from 'components/setting_picture.jsx';
|
|||||||
import UserStore from 'stores/user_store.jsx';
|
import UserStore from 'stores/user_store.jsx';
|
||||||
import ErrorStore from 'stores/error_store.jsx';
|
import ErrorStore from 'stores/error_store.jsx';
|
||||||
|
|
||||||
import {Client4} from 'mattermost-redux/client';
|
|
||||||
import Constants from 'utils/constants.jsx';
|
import Constants from 'utils/constants.jsx';
|
||||||
import * as Utils from 'utils/utils.jsx';
|
import * as Utils from 'utils/utils.jsx';
|
||||||
|
|
||||||
@@ -1141,7 +1140,7 @@ class UserSettingsGeneralTab extends React.Component {
|
|||||||
<SettingPicture
|
<SettingPicture
|
||||||
title={formatMessage(holders.profilePicture)}
|
title={formatMessage(holders.profilePicture)}
|
||||||
submit={this.submitPicture}
|
submit={this.submitPicture}
|
||||||
src={Client4.getUsersRoute() + '/' + user.id + '/image?time=' + user.last_picture_update}
|
src={Utils.imageURLForUser(user)}
|
||||||
serverError={serverError}
|
serverError={serverError}
|
||||||
clientError={clientError}
|
clientError={clientError}
|
||||||
updateSection={(e) => {
|
updateSection={(e) => {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
|
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
|
||||||
// See License.txt for license information.
|
// See License.txt for license information.
|
||||||
|
|
||||||
import {Client4} from 'mattermost-redux/client';
|
|
||||||
import WebSocketClient from 'client/web_websocket_client.jsx';
|
import WebSocketClient from 'client/web_websocket_client.jsx';
|
||||||
|
|
||||||
import UserStore from 'stores/user_store.jsx';
|
import UserStore from 'stores/user_store.jsx';
|
||||||
@@ -197,7 +196,7 @@ export default class WebrtcNotification extends React.Component {
|
|||||||
const user = this.state.userCalling;
|
const user = this.state.userCalling;
|
||||||
if (user) {
|
if (user) {
|
||||||
const username = Utils.displayUsername(user.id);
|
const username = Utils.displayUsername(user.id);
|
||||||
const profileImgSrc = Client4.getUsersRoute() + '/' + user.id + '/image?time=' + (user.last_picture_update || new Date().getTime());
|
const profileImgSrc = Utils.imageURLForUser(user);
|
||||||
const profileImg = (
|
const profileImg = (
|
||||||
<img
|
<img
|
||||||
className='user-popover__image'
|
className='user-popover__image'
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import UserStore from 'stores/user_store.jsx';
|
|||||||
import ChannelStore from 'stores/channel_store.jsx';
|
import ChannelStore from 'stores/channel_store.jsx';
|
||||||
import WebrtcStore from 'stores/webrtc_store.jsx';
|
import WebrtcStore from 'stores/webrtc_store.jsx';
|
||||||
|
|
||||||
import {Client4} from 'mattermost-redux/client';
|
|
||||||
import WebSocketClient from 'client/web_websocket_client.jsx';
|
import WebSocketClient from 'client/web_websocket_client.jsx';
|
||||||
import Janus from 'janus';
|
import Janus from 'janus';
|
||||||
|
|
||||||
@@ -84,14 +83,14 @@ export default class WebrtcController extends React.Component {
|
|||||||
|
|
||||||
const currentUser = UserStore.getCurrentUser();
|
const currentUser = UserStore.getCurrentUser();
|
||||||
const remoteUser = UserStore.getProfile(props.userId);
|
const remoteUser = UserStore.getProfile(props.userId);
|
||||||
const remoteUserImage = Client4.getUsersRoute() + '/' + remoteUser.id + '/image?time=' + remoteUser.last_picture_update;
|
const remoteUserImage = Utils.imageURLForUser(remoteUser);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
windowWidth: Utils.windowWidth(),
|
windowWidth: Utils.windowWidth(),
|
||||||
windowHeight: Utils.windowHeight(),
|
windowHeight: Utils.windowHeight(),
|
||||||
channelId: ChannelStore.getCurrentId(),
|
channelId: ChannelStore.getCurrentId(),
|
||||||
currentUser,
|
currentUser,
|
||||||
currentUserImage: Client4.getUsersRoute() + '/' + currentUser.id + '/image?time=' + currentUser.last_picture_update,
|
currentUserImage: Utils.imageURLForUser(currentUser),
|
||||||
remoteUserImage,
|
remoteUserImage,
|
||||||
localMediaLoaded: false,
|
localMediaLoaded: false,
|
||||||
isPaused: false,
|
isPaused: false,
|
||||||
@@ -133,7 +132,7 @@ export default class WebrtcController extends React.Component {
|
|||||||
(nextProps.userId !== this.props.userId) ||
|
(nextProps.userId !== this.props.userId) ||
|
||||||
(nextProps.isCaller !== this.props.isCaller)) {
|
(nextProps.isCaller !== this.props.isCaller)) {
|
||||||
const remoteUser = UserStore.getProfile(nextProps.userId);
|
const remoteUser = UserStore.getProfile(nextProps.userId);
|
||||||
const remoteUserImage = Client4.getUsersRoute() + '/' + remoteUser.id + '/image?time=' + remoteUser.last_picture_update;
|
const remoteUserImage = Utils.imageURLForUser(remoteUser);
|
||||||
this.setState({
|
this.setState({
|
||||||
error: null,
|
error: null,
|
||||||
remoteUserImage
|
remoteUserImage
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ import Constants from 'utils/constants.jsx';
|
|||||||
import * as GlobalActions from 'actions/global_actions.jsx';
|
import * as GlobalActions from 'actions/global_actions.jsx';
|
||||||
import ProfilePicture from 'components/profile_picture.jsx';
|
import ProfilePicture from 'components/profile_picture.jsx';
|
||||||
|
|
||||||
import {Client4} from 'mattermost-redux/client';
|
|
||||||
|
|
||||||
import {showManagementOptions} from './channel_utils.jsx';
|
import {showManagementOptions} from './channel_utils.jsx';
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
@@ -52,7 +50,7 @@ export function createGMIntroMessage(channel, centeredIntro) {
|
|||||||
pictures.push(
|
pictures.push(
|
||||||
<ProfilePicture
|
<ProfilePicture
|
||||||
key={'introprofilepicture' + profile.id}
|
key={'introprofilepicture' + profile.id}
|
||||||
src={Client4.getUsersRoute() + '/' + profile.id + '/image?time=' + profile.last_picture_update}
|
src={Utils.imageURLForUser(profile)}
|
||||||
width='50'
|
width='50'
|
||||||
height='50'
|
height='50'
|
||||||
user={profile}
|
user={profile}
|
||||||
@@ -112,7 +110,7 @@ export function createDMIntroMessage(channel, centeredIntro) {
|
|||||||
<div className={'channel-intro ' + centeredIntro}>
|
<div className={'channel-intro ' + centeredIntro}>
|
||||||
<div className='post-profile-img__container channel-intro-img'>
|
<div className='post-profile-img__container channel-intro-img'>
|
||||||
<ProfilePicture
|
<ProfilePicture
|
||||||
src={Client4.getUsersRoute() + '/' + teammate.id + '/image?time=' + teammate.last_picture_update}
|
src={Utils.imageURLForUser(teammate)}
|
||||||
width='50'
|
width='50'
|
||||||
height='50'
|
height='50'
|
||||||
user={teammate}
|
user={teammate}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
|
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
|
||||||
// See License.txt for license information.
|
// See License.txt for license information.
|
||||||
|
|
||||||
import {Client4} from 'mattermost-redux/client';
|
|
||||||
import Constants from 'utils/constants.jsx';
|
import Constants from 'utils/constants.jsx';
|
||||||
import * as Utils from 'utils/utils.jsx';
|
import * as Utils from 'utils/utils.jsx';
|
||||||
|
|
||||||
@@ -32,8 +31,14 @@ export function isEdited(post) {
|
|||||||
return post.edit_at > 0;
|
return post.edit_at > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getProfilePicSrcForPost(post, timestamp) {
|
export function getProfilePicSrcForPost(post, user) {
|
||||||
let src = Client4.getUsersRoute() + '/' + post.user_id + '/image?time=' + timestamp;
|
let src = '';
|
||||||
|
if (user && user.id === post.user_id) {
|
||||||
|
src = Utils.imageURLForUser(user);
|
||||||
|
} else {
|
||||||
|
src = Utils.imageURLForUser(post.user_id);
|
||||||
|
}
|
||||||
|
|
||||||
if (post.props && post.props.from_webhook && global.window.mm_config.EnablePostIconOverride === 'true') {
|
if (post.props && post.props.from_webhook && global.window.mm_config.EnablePostIconOverride === 'true') {
|
||||||
if (post.props.override_icon_url) {
|
if (post.props.override_icon_url) {
|
||||||
src = post.props.override_icon_url;
|
src = post.props.override_icon_url;
|
||||||
|
|||||||
@@ -1023,6 +1023,17 @@ export function displayUsernameForUser(user) {
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function imageURLForUser(userIdOrObject) {
|
||||||
|
if (typeof userIdOrObject == 'string') {
|
||||||
|
const profile = UserStore.getProfile(userIdOrObject);
|
||||||
|
if (profile) {
|
||||||
|
return imageURLForUser(profile);
|
||||||
|
}
|
||||||
|
return Client4.getUsersRoute() + '/' + userIdOrObject + '/image?_=' + Date.now();
|
||||||
|
}
|
||||||
|
return Client4.getUsersRoute() + '/' + userIdOrObject.id + '/image?_=' + (userIdOrObject.last_picture_update || 0);
|
||||||
|
}
|
||||||
|
|
||||||
// Converts a file size in bytes into a human-readable string of the form '123MB'.
|
// Converts a file size in bytes into a human-readable string of the form '123MB'.
|
||||||
export function fileSizeToString(bytes) {
|
export function fileSizeToString(bytes) {
|
||||||
// it's unlikely that we'll have files bigger than this
|
// it's unlikely that we'll have files bigger than this
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user