Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NEW] Add setting to change User Agent of OEmbed calls #6753

Merged
merged 4 commits into from
Jul 27, 2017

Conversation

AhmetS
Copy link
Contributor

@AhmetS AhmetS commented Apr 21, 2017

In doing so, If we want to share a single page application, we can include requests from rocketchatbot in our server rules to redirect to something like prerender.io version of the page or our own pre-rendering server.

Example prerender.io config:

    <IfModule mod_proxy_http.c>
        RewriteCond %{HTTP_USER_AGENT} rocketchatbot|baiduspider|facebookexternalhit|twitterbot|rogerbot|linkedinbot|embedly|quora\ link\ preview|showyoubot|outbrain|pinterest|slackbot|vkShare|W3C_Validator [NC,OR]
        RewriteCond %{QUERY_STRING} _escaped_fragment_
        
        # Only proxy the request to Prerender if it's a request for HTML
        RewriteRule ^(?!.*?(\.js|\.css|\.xml|\.less|\.png|\.jpg|\.jpeg|\.gif|\.pdf|\.doc|\.txt|\.ico|\.rss|\.zip|\.mp3|\.rar|\.exe|\.wmv|\.doc|\.avi|\.ppt|\.mpg|\.mpeg|\.tif|\.wav|\.mov|\.psd|\.ai|\.xls|\.mp4|\.m4a|\.swf|\.dat|\.dmg|\.iso|\.flv|\.m4v|\.torrent|\.ttf|\.woff))(.*) http://service.prerender.io/http://example.com/$2 [P,L]
    </IfModule>

@RocketChat/core

Closes #ISSUE_NUMBER

In doing so, If we want to share a single page application, we can include requests from `rocketchatbot` in our server rules to redirect to something like prerender.io version of the page or our own pre-rendering server.

Example prerender.io config:

```
    <IfModule mod_proxy_http.c>
        RewriteCond %{HTTP_USER_AGENT} rocketchatbot|baiduspider|facebookexternalhit|twitterbot|rogerbot|linkedinbot|embedly|quora\ link\ preview|showyoubot|outbrain|pinterest|slackbot|vkShare|W3C_Validator [NC,OR]
        RewriteCond %{QUERY_STRING} _escaped_fragment_
        
        # Only proxy the request to Prerender if it's a request for HTML
        RewriteRule ^(?!.*?(\.js|\.css|\.xml|\.less|\.png|\.jpg|\.jpeg|\.gif|\.pdf|\.doc|\.txt|\.ico|\.rss|\.zip|\.mp3|\.rar|\.exe|\.wmv|\.doc|\.avi|\.ppt|\.mpg|\.mpeg|\.tif|\.wav|\.mov|\.psd|\.ai|\.xls|\.mp4|\.m4a|\.swf|\.dat|\.dmg|\.iso|\.flv|\.m4v|\.torrent|\.ttf|\.woff))(.*) http://service.prerender.io/http://example.com/$2 [P,L]
    </IfModule>
```
@CLAassistant
Copy link

CLAassistant commented Apr 21, 2017

CLA assistant check
All committers have signed the CLA.

@engelgabriel
Copy link
Member

@AhmetS Can we turn this into a setting? Save this string into a setting that can be changed in the admin panel. What to you think @rodrigok

@engelgabriel engelgabriel added this to the 0.56.0 milestone Apr 25, 2017
@AhmetS
Copy link
Contributor Author

AhmetS commented Apr 25, 2017

@engelgabriel @rodrigok - I dont see the benefit of turning this into a setting.

We could always append rocketchatbot to the existing user agent?

'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2227.0 Safari/537.36 rocketchatbot'

@engelgabriel engelgabriel modified the milestones: 0.56.0, 0.57.0 May 9, 2017
@rodrigok
Copy link
Member

IMO, a setting is always better.

@geekgonecrazy
Copy link
Contributor

Agreed. I think would be best to leave the server admin in control of that instead of forcing rocketchatbot on it. Could effect the results some websites return, and in general cause issues with oembed functionality.

@AhmetS would you be able to make this change to a setting?

@engelgabriel engelgabriel modified the milestones: 0.57.0, 0.58.0 Jun 19, 2017
Copy link
Contributor

@geekgonecrazy geekgonecrazy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 LGTM

@rodrigok rodrigok changed the title Set User Agent to rocketchatbot [NEW] Add setting to change User Agent of OEmbed calls Jul 27, 2017
@rodrigok rodrigok merged commit 0ba18f1 into RocketChat:develop Jul 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants