Init Iframe integration

pull/4028/head
Rodrigo Nascimento 10 years ago
parent d70a0e84f1
commit 17afc8920a
No known key found for this signature in database
GPG Key ID: 2C85B3AFE75D23F9
  1. 5
      client/notifications/notification.coffee
  2. 42
      packages/rocketchat-lib/i18n/en.i18n.json
  3. 7
      packages/rocketchat-lib/server/startup/settings.coffee
  4. 2
      packages/rocketchat-ui/lib/fireEvent.coffee
  5. 35
      packages/rocketchat-ui/lib/fireEvent.js
  6. 2
      packages/rocketchat-ui/package.js

@ -18,6 +18,11 @@ Meteor.startup ->
hasFocus = readMessage.isEnable()
messageIsInOpenedRoom = openedRoomId is notification.payload.rid
fireGlobalEvent 'notification',
notification: notification
fromOpenedRoom: messageIsInOpenedRoom
hasFocus: hasFocus
if !(hasFocus and messageIsInOpenedRoom)
# Play a sound.
KonchatNotification.newMessage()

@ -6,8 +6,8 @@
"500" : "Internal Server Error",
"__username__is_no_longer__role__defined_by__user_by_" : "__username__ is no longer __role__ by __user_by__",
"__username__was_set__role__by__user_by_" : "__username__ was set __role__ by __user_by__",
"Accept_with_no_online_agents" : "Accept with no online agents",
"Accept_incoming_livechat_requests_even_if_there_are_no_online_agents" : "Accept incoming livechat requests even if there are no online agents",
"Accept_with_no_online_agents" : "Accept with no online agents",
"Access_not_authorized" : "Access not authorized",
"Access_Token_URL" : "Access Token URL",
"Accessing_permissions" : "Accessing permissions",
@ -43,7 +43,6 @@
"Accounts_LoginExpiration" : "Login Expiration in Days",
"Accounts_ManuallyApproveNewUsers" : "Manually Approve New Users",
"Accounts_OAuth_Custom_Authorize_Path" : "Authorize Path",
"Accounts_OAuth_Custom_Scope" : "Scope",
"Accounts_OAuth_Custom_Button_Color" : "Button Color",
"Accounts_OAuth_Custom_Button_Label_Color" : "Button Text Color",
"Accounts_OAuth_Custom_Button_Label_Text" : "Button Text",
@ -51,6 +50,7 @@
"Accounts_OAuth_Custom_id" : "Id",
"Accounts_OAuth_Custom_Identity_Path" : "Identity Path",
"Accounts_OAuth_Custom_Login_Style" : "Login Style",
"Accounts_OAuth_Custom_Scope" : "Scope",
"Accounts_OAuth_Custom_Secret" : "Secret",
"Accounts_OAuth_Custom_Token_Path" : "Token Path",
"Accounts_OAuth_Custom_Token_Sent_Via" : "Token Sent Via",
@ -288,9 +288,9 @@
"Delete_Room_Warning" : "Deleting a room will delete all messages posted within the room. This cannot be undone.",
"Delete_User_Warning" : "Deleting a user will delete all messages from that user as well. This cannot be undone.",
"Deleted" : "Deleted!",
"Department" : "Department",
"Department_removed" : "Department removed",
"Departments" : "Departments",
"Department" : "Department",
"Deployment_ID" : "Deployment ID",
"Description" : "Description",
"Desktop" : "Desktop",
@ -348,8 +348,6 @@
"Enter_name_here" : "Enter name here",
"Enter_to" : "Enter to",
"Error" : "Error",
"Exclude_Botnames": "Exclude bots",
"Exclude_Botnames_Description": "Do not propagate messages from bots whose name matches the regular expression above. If left empty, all messages from bots will be propagated.",
"error-action-not-allowed" : "__action__ is not allowed",
"error-application-not-found" : "Application not found",
"error-archived-duplicate-name" : "There's an archived channel with name '__room_name__'",
@ -420,6 +418,8 @@
"Error_changing_password" : "Error changing password",
"Esc_to" : "Esc to",
"Example_s" : "Example: <code class=\"inline\">%s</code>",
"Exclude_Botnames": "Exclude bots",
"Exclude_Botnames_Description": "Do not propagate messages from bots whose name matches the regular expression above. If left empty, all messages from bots will be propagated.",
"False" : "False",
"Favorite_Rooms" : "Enable Favorite Rooms",
"Favorites" : "Favorites",
@ -470,6 +470,7 @@
"Global" : "Global",
"GoogleSiteVerification_id" : "Google Site Verification Id",
"GoogleTagManager_id" : "Google Tag Manager Id",
"Guest_Pool" : "Guest Pool",
"Has_more" : "Has more",
"Hash" : "Hash",
"Header" : "Header",
@ -493,6 +494,14 @@
"How_satisfied_were_you_with_this_chat" : "How satisfied were you with this chat?",
"If_you_are_sure_type_in_your_password" : "If you are sure type in your password:",
"If_you_are_sure_type_in_your_username" : "If you are sure type in your username:",
"Iframe_Integration_receive_enable" : "Enable Receive",
"Iframe_Integration_receive_enable_Description" : "Allow parent window to send commands to Rocket.Chat.",
"Iframe_Integration_receive_origin" : "Receive origins",
"Iframe_Integration_receive_origin_Description" : "Only pages with given origin will be able to send commands or `*` for all origins. You can use multiple values separated by `,`. Example `http://localhost,https://localhost`",
"Iframe_Integration_send_enable" : "Enable Send",
"Iframe_Integration_send_enable_Description" : "Send events to parent window",
"Iframe_Integration_send_target_origin" : "Send target origin",
"Iframe_Integration_send_target_origin_Description" : "Only pages with given origin will be able to listen to events or `*` for all origins. Example `http://localhost`",
"Importer_Archived" : "Archived",
"Importer_done" : "Importing complete!",
"Importer_finishing" : "Finishing up the import.",
@ -595,8 +604,6 @@
"LDAP_Custom_Domain_Search" : "Custom Domain Search",
"LDAP_Custom_Domain_Search_Description" : "A piece of JSON that governs bind and connection info and is of the form:<br/> <code>{\"filter\": \"(&(objectCategory=person)(objectclass=user)(memberOf=CN=ROCKET_ACCESS,CN=Users,DC=domain,DC=com)(sAMAccountName=#{username}))\", \"scope\": \"sub\", \"userDN\": \"rocket.service@domain.com\", \"password\": \"urpass\"}</code>",
"LDAP_Default_Domain" : "Default Domain",
"LDAP_Merge_Existing_Users" : "Merge existing users",
"LDAP_Merge_Existing_Users_Description" : "*Caution!* When importing an user from LDAP and an user with same username already exists the LDAP info and password will be set into the existing user.",
"LDAP_Description" : "LDAP is a hierarchical database that many companies use to provide single sign on - a facility for sharing one password between multiple sites and services. For advanced configuration information and examples, please consult our wiki: https://github.com/RocketChat/Rocket.Chat/wiki/LDAP-Authentication.",
"LDAP_Domain_Base" : "Domain Base",
"LDAP_Domain_Base_Description" : "The fully qualified Distinguished Name (DN) of an LDAP subtree you want to search for users and groups. You can add as many as you like; however, each group must be defined in the same domain base as the users that belong to it. If you specify restricted user groups, only users that belong to those groups will be in scope. We recommend that you specify the top level of your LDAP directory tree as your domain base and use search filter to control access.",
@ -618,6 +625,8 @@
"LDAP_Encryption_Description" : "The encryption method used to secure communications to the LDAP server. Examples include `plain` (no encryption), `SSL/LDAPS` (encrypted from the start), and `StartTLS` (upgrade to encrypted communication once connected).",
"LDAP_Host" : "Host",
"LDAP_Host_Description" : "The LDAP host, e.g. `ldap.example.com` or `10.0.0.30`.",
"LDAP_Merge_Existing_Users" : "Merge existing users",
"LDAP_Merge_Existing_Users_Description" : "*Caution!* When importing an user from LDAP and an user with same username already exists the LDAP info and password will be set into the existing user.",
"LDAP_Port" : "Port",
"LDAP_Port_Description" : "Port to access LDAP. eg: `389` or `636` for LDAPS",
"LDAP_Reject_Unauthorized" : "Reject Unauthorized",
@ -634,6 +643,7 @@
"LDAP_Use_Custom_Domain_Search_Description" : "Write your own filter to search users in the LDAP server.",
"LDAP_Username_Field" : "Username Field",
"LDAP_Username_Field_Description" : "Which field will be used as *username* for new users. Leave empty to use the username informed on login page.<br/>You can use template tags too, like `#{givenName}.#{sn}`.<br/>Default value is `sAMAccountName`.",
"Least_Amount" : "Least Amount",
"Leave_Group_Warning" : "Are you sure you want to leave the group \"%s\"?",
"Leave_Private_Warning" : "Are you sure you want to leave the discussion with \"%s\"?",
"Leave_room" : "Leave room",
@ -658,8 +668,6 @@
"Livechat_title" : "Livechat Title",
"Livechat_title_color" : "Livechat Title Background Color",
"Livechat_Users" : "Livechat Users",
"Least_Amount" : "Least Amount",
"Guest_Pool" : "Guest Pool",
"Load_more" : "Load more",
"Loading..." : "Loading...",
"Loading_more_from_history" : "Loading more from history",
@ -688,6 +696,10 @@
"Manager_removed" : "Manager removed",
"Managing_assets" : "Managing assets",
"Managing_integrations" : "Managing integrations",
"MapView_Enabled" : "Enable Mapview",
"MapView_Enabled_Description" : "Enabling mapview will display a location share button on the left of the chat input field.",
"MapView_GMapsAPIKey" : "Google Static Maps API Key",
"MapView_GMapsAPIKey_Description" : "This can be obtained from the Google Developers Console for free.",
"Mark_as_read" : "Mark as read",
"Mark_as_unread" : "Mark as unread",
"Markdown_Headers" : "Markdown Headers",
@ -810,11 +822,11 @@
"Offline_DM_Email" : "You have been direct messaged by __user__",
"Offline_form" : "Offline form",
"Offline_form_unavailable_message" : "Offline form unavailable message",
"Offline_Link_Message" : "GO TO MESSAGE",
"Offline_Mention_Email" : "You have been mentioned by __user__ in #__room__",
"Offline_message" : "Offline message",
"Offline_success_message" : "Offline success message",
"Offline_unavailable" : "Offline unavailable",
"Offline_Link_Message" : "GO TO MESSAGE",
"On" : "On",
"Online" : "Online",
"Only_you_can_see_this_message" : "Only you can see this message",
@ -937,7 +949,6 @@
"Reset_password" : "Reset password",
"Restart" : "Restart",
"Restart_the_server" : "Restart the server",
"Would_you_like_to_return_the_inquiry" : "Would you like to return the inquiry?",
"Role" : "Role",
"Role_Editing" : "Role Editing",
"Role_removed" : "Role removed",
@ -1017,6 +1028,7 @@
"Set_as_owner" : "Set as owner",
"Settings" : "Settings",
"Settings_updated" : "Settings updated",
"Share_Location_Title" : "Share Location?",
"Should_be_a_URL_of_an_image" : "Should be a URL of an image.",
"Should_exists_a_user_with_this_username" : "The user must already exist.",
"Show_all" : "Show all",
@ -1273,6 +1285,7 @@
"Welcome_to_the" : "Welcome to the",
"Why_do_you_want_to_report_question_mark" : "Why do you want to report?",
"will_be_able_to" : "will be able to",
"Would_you_like_to_return_the_inquiry" : "Would you like to return the inquiry?",
"Yes" : "Yes",
"Yes_clear_all" : "Yes, clear all!",
"Yes_delete_it" : "Yes, delete it!",
@ -1309,10 +1322,5 @@
"Your_file_has_been_deleted" : "Your file has been deleted.",
"Your_mail_was_sent_to_s" : "Your mail was sent to %s",
"Your_password_is_wrong" : "Your password is wrong!",
"Your_push_was_sent_to_s_devices" : "Your push was sent to %s devices",
"MapView_Enabled" : "Enable Mapview",
"MapView_Enabled_Description" : "Enabling mapview will display a location share button on the left of the chat input field.",
"MapView_GMapsAPIKey" : "Google Static Maps API Key",
"MapView_GMapsAPIKey_Description" : "This can be obtained from the Google Developers Console for free.",
"Share_Location_Title" : "Share Location?"
"Your_push_was_sent_to_s_devices" : "Your push was sent to %s devices"
}

@ -109,6 +109,13 @@ RocketChat.settings.addGroup 'General', ->
@section 'REST API', ->
@add 'API_User_Limit', 500, { type: 'int', public: true, i18nDescription: 'API_User_Limit' }
@section 'Iframe Integration', ->
@add 'Iframe_Integration_send_enable', false, { type: 'boolean', public: true }
@add 'Iframe_Integration_send_target_origin', '*', { type: 'string', public: true, enableQuery: { _id: 'Iframe_Integration_send_enable', value: true } }
@add 'Iframe_Integration_receive_enable', false, { type: 'boolean', public: true }
@add 'Iframe_Integration_receive_origin', '*', { type: 'string', public: true, enableQuery: { _id: 'Iframe_Integration_receive_enable', value: true } }
RocketChat.settings.addGroup 'Email', ->
@section 'Header and Footer', ->

@ -1,2 +0,0 @@
window.fireGlobalEvent = (eventName, params) ->
window.dispatchEvent new CustomEvent(eventName, {detail: params})

@ -0,0 +1,35 @@
window.fireGlobalEvent = (eventName, params) => {
window.dispatchEvent(new CustomEvent(eventName, {detail: params}));
if (RocketChat.settings.get('Iframe_Integration_send_enable') === true) {
parent.postMessage({
eventName: eventName,
data: params
}, RocketChat.settings.get('Iframe_Integration_send_target_origin'));
}
}
window.addEventListener('message', (e) => {
if (RocketChat.settings.get('Iframe_Integration_receive_enable') !== true) {
return;
}
if (typeof e.data !== 'object' || typeof e.data.externalCommand !== 'string') {
return;
}
let origins = RocketChat.settings.get('Iframe_Integration_receive_origin');
if (origins !== '*' && origins.split(',').indexOf(e.origin) === -1) {
return console.error('Origin not allowed', e.origin);
}
switch (e.data.externalCommand) {
case 'go':
if (typeof e.data.path !== 'string' || e.data.path.trim().length === 0) {
return console.error('`path` not defined');
}
FlowRouter.go(e.data.path);
break;
}
});

@ -41,7 +41,7 @@ Package.onUse(function(api) {
api.addFiles('lib/constallation.js', 'client');
api.addFiles('lib/customEventPolyfill.js', 'client');
api.addFiles('lib/fileUpload.coffee', 'client');
api.addFiles('lib/fireEvent.coffee', 'client');
api.addFiles('lib/fireEvent.js', 'client');
api.addFiles('lib/jquery.swipebox.min.js', 'client');
api.addFiles('lib/menu.coffee', 'client');
api.addFiles('lib/modal.coffee', 'client');

Loading…
Cancel
Save