summaryrefslogtreecommitdiffstats
path: root/webapp/utils/post_utils.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'webapp/utils/post_utils.jsx')
-rw-r--r--webapp/utils/post_utils.jsx32
1 files changed, 32 insertions, 0 deletions
diff --git a/webapp/utils/post_utils.jsx b/webapp/utils/post_utils.jsx
new file mode 100644
index 000000000..f5111d72d
--- /dev/null
+++ b/webapp/utils/post_utils.jsx
@@ -0,0 +1,32 @@
+// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+import Client from 'utils/web_client.jsx';
+
+import Constants from 'utils/constants.jsx';
+
+export function isSystemMessage(post) {
+ return post.type && (post.type.lastIndexOf(Constants.SYSTEM_MESSAGE_PREFIX) === 0);
+}
+
+export function isComment(post) {
+ if ('root_id' in post) {
+ return post.root_id !== '' && post.root_id != null;
+ }
+ return false;
+}
+
+export function getProfilePicSrcForPost(post, timestamp) {
+ let src = Client.getUsersRoute() + '/' + post.user_id + '/image?time=' + timestamp;
+ if (post.props && post.props.from_webhook && global.window.mm_config.EnablePostIconOverride === 'true') {
+ if (post.props.override_icon_url) {
+ src = post.props.override_icon_url;
+ } else {
+ src = Constants.DEFAULT_WEBHOOK_LOGO;
+ }
+ } else if (isSystemMessage(post)) {
+ src = Constants.SYSTEM_MESSAGE_PROFILE_IMAGE;
+ }
+
+ return src;
+}