summaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
authorCorey Hulen <corey@hulen.com>2015-10-08 09:49:29 -0700
committerCorey Hulen <corey@hulen.com>2015-10-08 09:49:29 -0700
commit26252ccebf23d8e0ce6cd0f6b79b268e5c3b90fd (patch)
treee82aedf48df06bd9802c22a3a8c66e9c5eae2ee0 /web
parentd30a694d11a0a7ae3474674b8a1a0e3472d4eae1 (diff)
parente640bf7b6c1f6b3f20db954b27430261c18accda (diff)
downloadchat-26252ccebf23d8e0ce6cd0f6b79b268e5c3b90fd.tar.gz
chat-26252ccebf23d8e0ce6cd0f6b79b268e5c3b90fd.tar.bz2
chat-26252ccebf23d8e0ce6cd0f6b79b268e5c3b90fd.zip
Merge pull request #971 from mattermost/PLT-567
PLT-567 auto join open channels
Diffstat (limited to 'web')
-rw-r--r--web/react/utils/markdown.jsx10
-rw-r--r--web/react/utils/text_formatting.jsx7
-rw-r--r--web/web.go19
3 files changed, 30 insertions, 6 deletions
diff --git a/web/react/utils/markdown.jsx b/web/react/utils/markdown.jsx
index 7e88f8644..aff776d05 100644
--- a/web/react/utils/markdown.jsx
+++ b/web/react/utils/markdown.jsx
@@ -2,6 +2,7 @@
// See License.txt for license information.
const TextFormatting = require('./text_formatting.jsx');
+const Utils = require('./utils.jsx');
const marked = require('marked');
@@ -39,7 +40,14 @@ export class MattermostMarkdownRenderer extends marked.Renderer {
if (title) {
output += ' title="' + title + '"';
}
- output += ' target="_blank">' + text + '</a>';
+
+ if (outHref.lastIndexOf(Utils.getTeamURLFromAddressBar(), 0) === 0) {
+ output += '>';
+ } else {
+ output += ' target="_blank">';
+ }
+
+ output += text + '</a>';
return output;
}
diff --git a/web/react/utils/text_formatting.jsx b/web/react/utils/text_formatting.jsx
index 34e42cbae..b8ed58258 100644
--- a/web/react/utils/text_formatting.jsx
+++ b/web/react/utils/text_formatting.jsx
@@ -96,8 +96,13 @@ function autolinkUrls(text, tokens) {
const index = tokens.size;
const alias = `MM_LINK${index}`;
+ var target = 'target="_blank"';
+ if (url.lastIndexOf(Utils.getTeamURLFromAddressBar(), 0) === 0) {
+ target = '';
+ }
+
tokens.set(alias, {
- value: `<a class='theme' target='_blank' href='${url}'>${linkText}</a>`,
+ value: '<a class="theme"' + target + ' href="${url}">${linkText}</a>',
originalText: linkText
});
diff --git a/web/web.go b/web/web.go
index 87c96659d..8dfac4a8d 100644
--- a/web/web.go
+++ b/web/web.go
@@ -372,11 +372,22 @@ func getChannel(c *api.Context, w http.ResponseWriter, r *http.Request) {
return
}
- //api.Handle404(w, r)
- //Bad channel urls just redirect to the town-square for now
+ // We will attempt to auto-join open channels
+ if cr := <-api.Srv.Store.Channel().GetByName(c.Session.TeamId, name); cr.Err != nil {
+ http.Redirect(w, r, c.GetTeamURL()+"/channels/town-square", http.StatusFound)
+ } else {
+ channel := cr.Data.(*model.Channel)
+ if channel.Type == model.CHANNEL_OPEN {
+ api.JoinChannel(c, channel.Id, "")
+ if c.Err != nil {
+ return
+ }
- http.Redirect(w, r, c.GetTeamURL()+"/channels/town-square", http.StatusFound)
- return
+ channelId = channel.Id
+ } else {
+ http.Redirect(w, r, c.GetTeamURL()+"/channels/town-square", http.StatusFound)
+ }
+ }
}
}