Add setting to change User Agent of OEmbed calls

pull/6753/head
Rodrigo Nascimento 8 years ago
parent 7f8afff3d7
commit ffdcf7d2e3
  1. 1
      packages/rocketchat-i18n/i18n/en.i18n.json
  2. 4
      packages/rocketchat-lib/server/startup/settings.js
  3. 2
      packages/rocketchat-oembed/server/server.js

@ -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",

@ -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

@ -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;

Loading…
Cancel
Save