mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Allow link redirects inside oneboxed posts
This commit is contained in:
parent
298b54c0e7
commit
769223014c
@ -38,10 +38,9 @@ Discourse.ClickTrack = {
|
|||||||
userId = $link.data('user-id');
|
userId = $link.data('user-id');
|
||||||
|
|
||||||
if (!userId) userId = $article.data('user-id');
|
if (!userId) userId = $article.data('user-id');
|
||||||
var ownLink = userId && (userId === Discourse.User.currentProp('id'));
|
|
||||||
|
|
||||||
// Build a Redirect URL
|
var ownLink = userId && (userId === Discourse.User.currentProp('id')),
|
||||||
var trackingUrl = Discourse.getURL("/clicks/track?url=" + encodeURIComponent(href));
|
trackingUrl = Discourse.getURL("/clicks/track?url=" + encodeURIComponent(href));
|
||||||
if (postId && (!$link.data('ignore-post-id'))) {
|
if (postId && (!$link.data('ignore-post-id'))) {
|
||||||
trackingUrl += "&post_id=" + encodeURI(postId);
|
trackingUrl += "&post_id=" + encodeURI(postId);
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,11 @@ class TopicLinkClick < ActiveRecord::Base
|
|||||||
# If no link is found, return the url for relative links
|
# If no link is found, return the url for relative links
|
||||||
unless link.present?
|
unless link.present?
|
||||||
return args[:url] if args[:url] =~ /^\//
|
return args[:url] if args[:url] =~ /^\//
|
||||||
return nil
|
|
||||||
|
# If we have it somewhere else on the site, just allow the redirect. This is
|
||||||
|
# likely due to a onebox of another topic.
|
||||||
|
link = TopicLink.where(url: args[:url]).first
|
||||||
|
return link.present? ? link.url : nil
|
||||||
end
|
end
|
||||||
|
|
||||||
return args[:url] if (args[:user_id] && (link.user_id == args[:user_id]))
|
return args[:url] if (args[:user_id] && (link.user_id == args[:user_id]))
|
||||||
|
Loading…
Reference in New Issue
Block a user