diff --git a/packages/rocketchat-google-natural-language/server/index.js b/packages/rocketchat-google-natural-language/server/index.js index 454f7a91d363..679ccad8cb0b 100644 --- a/packages/rocketchat-google-natural-language/server/index.js +++ b/packages/rocketchat-google-natural-language/server/index.js @@ -2,9 +2,9 @@ import './settings.js'; import './models/Rooms.js'; const getMessageSentiment = function(message) { - const Language = Npm.require('@google-cloud/language'); + const googleLanguage = Npm.require('@google-cloud/language'); - const languageClient = Language({ + const languageClient = googleLanguage({ credentials: JSON.parse(RocketChat.settings.get('GoogleNaturalLanguage_ServiceAccount')) }); diff --git a/packages/rocketchat-google-natural-language/server/settings.js b/packages/rocketchat-google-natural-language/server/settings.js index 49180748500f..4541ba662fad 100644 --- a/packages/rocketchat-google-natural-language/server/settings.js +++ b/packages/rocketchat-google-natural-language/server/settings.js @@ -2,17 +2,19 @@ Meteor.startup(function() { RocketChat.settings.add('GoogleNaturalLanguage_Enabled', false, { type: 'boolean', group: 'Message', - section: 'GoogleNaturalLanguage', - public: true + section: 'Google Natural Language', + public: true, + i18nLabel: 'Enabled' }); RocketChat.settings.add('GoogleNaturalLanguage_ServiceAccount', '', { type: 'string', group: 'Message', - section: 'GoogleNaturalLanguage', + section: 'Google Natural Language', multiline: true, enableQuery: { _id: 'GoogleNaturalLanguage_Enabled', value: true - } + }, + i18nLabel: 'Service_account_key' }); }); diff --git a/packages/rocketchat-i18n/i18n/en.i18n.json b/packages/rocketchat-i18n/i18n/en.i18n.json index 733b6dfa4ae8..a6e4d82af2c4 100644 --- a/packages/rocketchat-i18n/i18n/en.i18n.json +++ b/packages/rocketchat-i18n/i18n/en.i18n.json @@ -612,6 +612,7 @@ "Give_the_application_a_name_This_will_be_seen_by_your_users": "Give the application a name. This will be seen by your users.", "Global": "Global", "GoogleCloudStorage": "Google Cloud Storage", + "GoogleNaturalLanguage_ServiceAccount_Description": "Service account key JSON file. More information can be found [here](https://cloud.google.com/natural-language/docs/common/auth#set_up_a_service_account)", "GoogleTagManager_id": "Google Tag Manager Id", "Guest_Pool": "Guest Pool", "Hash": "Hash", @@ -1304,6 +1305,7 @@ "Sending": "Sending...", "Served_By": "Served By", "Service": "Service", + "Service_account_key": "Service account key", "Set_as_moderator": "Set as moderator", "Set_as_owner": "Set as owner", "Settings": "Settings", diff --git a/packages/rocketchat-ui/client/views/app/room.coffee b/packages/rocketchat-ui/client/views/app/room.coffee index 4014d9b0efc8..2fbac9b16769 100644 --- a/packages/rocketchat-ui/client/views/app/room.coffee +++ b/packages/rocketchat-ui/client/views/app/room.coffee @@ -15,7 +15,7 @@ userCanDrop = (_id) -> Template.room.helpers sentimentSmile: -> - room = ChatRoom.findOne this._id + room = ChatRoom.findOne this._id, fields: sentiment: 1 if room.sentiment >= 0.3 return ':)'