Skip to content

Commit

Permalink
Merge pull request #6753 from AhmetS/patch-1
Browse files Browse the repository at this point in the history
[NEW] Add setting to change User Agent of OEmbed calls
  • Loading branch information
rodrigok authored Jul 27, 2017
2 parents 82b7845 + ffdcf7d commit 0ba18f1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@
"API_Drupal_URL": "Drupal Server URL",
"API_Drupal_URL_Description": "Example: https://domain.com (excluding trailing slash)",
"API_Embed": "Embed Link Previews",
"API_Embed_UserAgent": "Embed request user agent",
"API_Embed_Description": "Whether embedded link previews are enabled or not when a user posts a link to a website.",
"API_EmbedCacheExpirationDays": "Embed cache expiration days",
"API_EmbedDisabledFor": "Disable Embed for Users",
Expand Down
4 changes: 4 additions & 0 deletions packages/rocketchat-lib/server/startup/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,10 @@ RocketChat.settings.addGroup('Message', function() {
type: 'boolean',
'public': true
});
this.add('API_Embed_UserAgent', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2227.0 Safari/537.36', {
type: 'string',
'public': true
});
this.add('API_EmbedCacheExpirationDays', 30, {
type: 'int',
'public': false
Expand Down
2 changes: 1 addition & 1 deletion packages/rocketchat-oembed/server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const getUrlContent = function(urlObj, redirectCount = 5, callback) {
gzip: true,
maxRedirects: redirectCount,
headers: {
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2227.0 Safari/537.36'
'User-Agent': RocketChat.settings.get('API_Embed_UserAgent')
}
};
let headers = null;
Expand Down

0 comments on commit 0ba18f1

Please sign in to comment.