From f53040d4d91cbf0fbcd425a796a3c14b4bc38728 Mon Sep 17 00:00:00 2001 From: Marcos Spessatto Defendi Date: Thu, 14 Feb 2019 14:47:40 -0200 Subject: [PATCH] Remove dependency of RC namespace in rc-oauth2-server and message-star (#13344) * Remove some dependencies inside rocketchat-lib/client (#13210) * Move function to rc-utils * Change import from to export directly * Removing duplicated dependency and remove old code * Import some variables to remove dependency of RC namespace * Remove some dependencies inside rocketchat-lib/lib (#13212) * Move some functions from lib to rc-ui-utils * Move some functions from lib ro rc-utils * Remove hostname from RC namespace * Import variables to remove dependency of RC namespace * Remove some dependencies inside rocketchat-lib/server/functions (#13214) * Move integrations models to rc-models * Move composeMessage function to rc-utils * Move PushNotifications class to push-notifications package * Import variables to remove dependency of RC namespace * Remove some dependencies inside rocketchat-lib/server/lib (#13217) * Move integrations models to rc-models * Move composeMessage function to rc-utils * Move PushNotifications class to push-notifications package * Import variables to remove dependency of RC namespace * Import variables to remove RC namespace dependency inside rc-lib/server/lib * Remove some dependencies inside rocketchat-lib/server/methods (#13218) * Move integrations models to rc-models * Move composeMessage function to rc-utils * Move PushNotifications class to push-notifications package * Import variables to remove dependency of RC namespace * Import variables to remove RC namespace dependency inside rc-lib/server/lib * Import variables to remove RC namespace inside rc-lib/server/methods * Remove some dependencies inside rocketchat-lib/server/startup, publications... (#13222) * Move integrations models to rc-models * Move composeMessage function to rc-utils * Move PushNotifications class to push-notifications package * Import variables to remove dependency of RC namespace * Import variables to remove RC namespace dependency inside rc-lib/server/lib * Import variables to remove RC namespace inside rc-lib/server/methods * Import variables to remove dependency with RC namespace * Remove duplicated server settings (#13223) * Move integrations models to rc-models * Move composeMessage function to rc-utils * Move PushNotifications class to push-notifications package * Import variables to remove dependency of RC namespace * Import variables to remove RC namespace dependency inside rc-lib/server/lib * Import variables to remove RC namespace inside rc-lib/server/methods * Import variables to remove dependency with RC namespace * Remove duplicated server settings located in rc-lib * Export functions and lib function of rc-lib but keep it inside RC namespace (#13225) * Move integrations models to rc-models * Move composeMessage function to rc-utils * Move PushNotifications class to push-notifications package * Import variables to remove dependency of RC namespace * Import variables to remove RC namespace dependency inside rc-lib/server/lib * Import variables to remove RC namespace inside rc-lib/server/methods * Import variables to remove dependency with RC namespace * Remove duplicated server settings located in rc-lib * Export function and lib function of rc-lib but keep it inside RC namespace * Fix missed exports and re-add some functions to RC namespace * Import variables from functions and lib to remove RC namespace dependency (#13226) * Move integrations models to rc-models * Move composeMessage function to rc-utils * Move PushNotifications class to push-notifications package * Import variables to remove dependency of RC namespace * Import variables to remove RC namespace dependency inside rc-lib/server/lib * Import variables to remove RC namespace inside rc-lib/server/methods * Import variables to remove dependency with RC namespace * Remove duplicated server settings located in rc-lib * Export function and lib function of rc-lib but keep it inside RC namespace * Import variables from functions and lib to remove RC namespace dependency * Remove dependency of RC namespace in rc-sandstorm (#13227) * Move integrations models to rc-models * Move composeMessage function to rc-utils * Move PushNotifications class to push-notifications package * Import variables to remove dependency of RC namespace * Import variables to remove RC namespace dependency inside rc-lib/server/lib * Import variables to remove RC namespace inside rc-lib/server/methods * Import variables to remove dependency with RC namespace * Remove duplicated server settings located in rc-lib * Export function and lib function of rc-lib but keep it inside RC namespace * Import variables from functions and lib to remove RC namespace dependency * Remove dependency of RC namespace in rc-sandstorm * Remove dependency of RC namespace in chatpal-search (#13231) * Move integrations models to rc-models * Move composeMessage function to rc-utils * Move PushNotifications class to push-notifications package * Import variables to remove dependency of RC namespace * Import variables to remove RC namespace dependency inside rc-lib/server/lib * Import variables to remove RC namespace inside rc-lib/server/methods * Import variables to remove dependency with RC namespace * Remove duplicated server settings located in rc-lib * Export function and lib function of rc-lib but keep it inside RC namespace * Import variables from functions and lib to remove RC namespace dependency * Remove dependency of RC namespace in rc-sandstorm * Remove dependency of RC namespace in chatpal-search * Remove dependency of RC namespace in meteor saml (#13233) * Move integrations models to rc-models * Move composeMessage function to rc-utils * Move PushNotifications class to push-notifications package * Import variables to remove dependency of RC namespace * Import variables to remove RC namespace dependency inside rc-lib/server/lib * Import variables to remove RC namespace inside rc-lib/server/methods * Import variables to remove dependency with RC namespace * Remove duplicated server settings located in rc-lib * Export function and lib function of rc-lib but keep it inside RC namespace * Import variables from functions and lib to remove RC namespace dependency * Remove dependency of RC namespace in rc-sandstorm * Remove dependency of RC namespace in chatpal-search * Move CreadentialTokens model to rc-models * Move getUsernameSuggestion function and method from server/ to rc-lib * Remove dependency of RC namespace in meteor saml * Remove dependency of RC namespace in rc-theme (#13234) * Move integrations models to rc-models * Move composeMessage function to rc-utils * Move PushNotifications class to push-notifications package * Import variables to remove dependency of RC namespace * Import variables to remove RC namespace dependency inside rc-lib/server/lib * Import variables to remove RC namespace inside rc-lib/server/methods * Import variables to remove dependency with RC namespace * Remove duplicated server settings located in rc-lib * Export function and lib function of rc-lib but keep it inside RC namespace * Import variables from functions and lib to remove RC namespace dependency * Remove dependency of RC namespace in rc-sandstorm * Remove dependency of RC namespace in chatpal-search * Move CreadentialTokens model to rc-models * Move getUsernameSuggestion function and method from server/ to rc-lib * Remove dependency of RC namespace in meteor saml * Remove dependency of RC namespace in rc-theme * Remove dependency of RC namespace in rc-2fa (#13235) * Move integrations models to rc-models * Move composeMessage function to rc-utils * Move PushNotifications class to push-notifications package * Import variables to remove dependency of RC namespace * Import variables to remove RC namespace dependency inside rc-lib/server/lib * Import variables to remove RC namespace inside rc-lib/server/methods * Import variables to remove dependency with RC namespace * Remove duplicated server settings located in rc-lib * Export function and lib function of rc-lib but keep it inside RC namespace * Import variables from functions and lib to remove RC namespace dependency * Remove dependency of RC namespace in rc-sandstorm * Remove dependency of RC namespace in chatpal-search * Move CreadentialTokens model to rc-models * Move getUsernameSuggestion function and method from server/ to rc-lib * Remove dependency of RC namespace in meteor saml * Remove dependency of RC namespace in rc-theme * Move 2FA Users model to rc-models * Remove dependency of RC namespace in rc-2fa * Remove dependency of RC namespace in rc-action-links (#13236) * Move integrations models to rc-models * Move composeMessage function to rc-utils * Move PushNotifications class to push-notifications package * Import variables to remove dependency of RC namespace * Import variables to remove RC namespace dependency inside rc-lib/server/lib * Import variables to remove RC namespace inside rc-lib/server/methods * Import variables to remove dependency with RC namespace * Remove duplicated server settings located in rc-lib * Export function and lib function of rc-lib but keep it inside RC namespace * Import variables from functions and lib to remove RC namespace dependency * Remove dependency of RC namespace in rc-sandstorm * Remove dependency of RC namespace in chatpal-search * Move CreadentialTokens model to rc-models * Move getUsernameSuggestion function and method from server/ to rc-lib * Remove dependency of RC namespace in meteor saml * Remove dependency of RC namespace in rc-theme * Move 2FA Users model to rc-models * Remove dependency of RC namespace in rc-2fa * Remove dependency of RC namespace in rc-action-links * Add action links in the RC namespace * Remove dependency of RC namespace in rc-analytics and rc-assets (#13237) * Move integrations models to rc-models * Move composeMessage function to rc-utils * Move PushNotifications class to push-notifications package * Import variables to remove dependency of RC namespace * Import variables to remove RC namespace dependency inside rc-lib/server/lib * Import variables to remove RC namespace inside rc-lib/server/methods * Import variables to remove dependency with RC namespace * Remove duplicated server settings located in rc-lib * Export function and lib function of rc-lib but keep it inside RC namespace * Import variables from functions and lib to remove RC namespace dependency * Remove dependency of RC namespace in rc-sandstorm * Remove dependency of RC namespace in chatpal-search * Move CreadentialTokens model to rc-models * Move getUsernameSuggestion function and method from server/ to rc-lib * Remove dependency of RC namespace in meteor saml * Remove dependency of RC namespace in rc-theme * Move 2FA Users model to rc-models * Remove dependency of RC namespace in rc-2fa * Remove dependency of RC namespace in rc-action-links * Add action links in the RC namespace * Remove dependency of RC namespace in rc-analytics * Remove dependency of RC namespace in rc-assets * Add Assets in RC namespace * Rename Assets variable to avoid conflicts * Fix rename Assets * Remove dependency of RC namespace in rc-markdown, rc-autolinker and rc-autotranslate (#13240) * Move integrations models to rc-models * Move composeMessage function to rc-utils * Move PushNotifications class to push-notifications package * Import variables to remove dependency of RC namespace * Import variables to remove RC namespace dependency inside rc-lib/server/lib * Import variables to remove RC namespace inside rc-lib/server/methods * Import variables to remove dependency with RC namespace * Remove duplicated server settings located in rc-lib * Export function and lib function of rc-lib but keep it inside RC namespace * Import variables from functions and lib to remove RC namespace dependency * Remove dependency of RC namespace in rc-sandstorm * Remove dependency of RC namespace in chatpal-search * Move CreadentialTokens model to rc-models * Move getUsernameSuggestion function and method from server/ to rc-lib * Remove dependency of RC namespace in meteor saml * Remove dependency of RC namespace in rc-theme * Move 2FA Users model to rc-models * Remove dependency of RC namespace in rc-2fa * Remove dependency of RC namespace in rc-action-links * Add action links in the RC namespace * Remove dependency of RC namespace in rc-analytics * Remove dependency of RC namespace in rc-assets * Add Assets in RC namespace * Remove dependency of RC namespace in rc-autolinker * Move autotranslate models to rc-models * Partial remove dependency of Rc namespace in rc-autotranslate * Remove dependency of RC namespace in rc-markdown * Finish of remotion of RC namespace in rc-autotranslate * Import Autotranslate where it has been used * Fix lint * Rename Assets variable to avoid conflicts * Fix rename Assets * Fix wrong imports * Remove dependency of RC namespace in rc-blockstack, bot-helpers and cas (#13246) * Move integrations models to rc-models * Move composeMessage function to rc-utils * Move PushNotifications class to push-notifications package * Import variables to remove dependency of RC namespace * Import variables to remove RC namespace dependency inside rc-lib/server/lib * Import variables to remove RC namespace inside rc-lib/server/methods * Import variables to remove dependency with RC namespace * Remove duplicated server settings located in rc-lib * Export function and lib function of rc-lib but keep it inside RC namespace * Import variables from functions and lib to remove RC namespace dependency * Remove dependency of RC namespace in rc-sandstorm * Remove dependency of RC namespace in chatpal-search * Move CreadentialTokens model to rc-models * Move getUsernameSuggestion function and method from server/ to rc-lib * Remove dependency of RC namespace in meteor saml * Remove dependency of RC namespace in rc-theme * Move 2FA Users model to rc-models * Remove dependency of RC namespace in rc-2fa * Remove dependency of RC namespace in rc-action-links * Add action links in the RC namespace * Remove dependency of RC namespace in rc-analytics * Remove dependency of RC namespace in rc-assets * Add Assets in RC namespace * Remove dependency of RC namespace in rc-autolinker * Move autotranslate models to rc-models * Partial remove dependency of Rc namespace in rc-autotranslate * Remove dependency of RC namespace in rc-markdown * Finish of remotion of RC namespace in rc-autotranslate * Import Autotranslate where it has been used * Fix lint * Rename Assets variable to avoid conflicts * Fix rename Assets * Remove dependency of RC namespace in rc-blockstack * Remove RC dependency in bot-helpers * Remove RC dependency in rc-cas * Fix wrong imports * Remove dependency of RC namespace in rc-channel-settings (#13251) * Move integrations models to rc-models * Move composeMessage function to rc-utils * Move PushNotifications class to push-notifications package * Import variables to remove dependency of RC namespace * Import variables to remove RC namespace dependency inside rc-lib/server/lib * Import variables to remove RC namespace inside rc-lib/server/methods * Import variables to remove dependency with RC namespace * Remove duplicated server settings located in rc-lib * Export function and lib function of rc-lib but keep it inside RC namespace * Import variables from functions and lib to remove RC namespace dependency * Remove dependency of RC namespace in rc-sandstorm * Remove dependency of RC namespace in chatpal-search * Move CreadentialTokens model to rc-models * Move getUsernameSuggestion function and method from server/ to rc-lib * Remove dependency of RC namespace in meteor saml * Remove dependency of RC namespace in rc-theme * Move 2FA Users model to rc-models * Remove dependency of RC namespace in rc-2fa * Remove dependency of RC namespace in rc-action-links * Add action links in the RC namespace * Remove dependency of RC namespace in rc-analytics * Remove dependency of RC namespace in rc-assets * Add Assets in RC namespace * Remove dependency of RC namespace in rc-autolinker * Move autotranslate models to rc-models * Partial remove dependency of Rc namespace in rc-autotranslate * Remove dependency of RC namespace in rc-markdown * Finish of remotion of RC namespace in rc-autotranslate * Import Autotranslate where it has been used * Fix lint * Rename Assets variable to avoid conflicts * Fix rename Assets * Remove dependency of RC namespace in rc-blockstack * Remove RC dependency in bot-helpers * Remove RC dependency in rc-cas * Move some functions from tokenpass to channel settings and models * Move some function from livestream to channel settings * Remove dependency of RC namespace in rc-channel-settings * Fix wrong imports * readd saveRoomName to RC namespace * Remove dependency of RC namespace in rc-channel-mail-messages and cloud (#13254) * Move integrations models to rc-models * Move composeMessage function to rc-utils * Move PushNotifications class to push-notifications package * Import variables to remove dependency of RC namespace * Import variables to remove RC namespace dependency inside rc-lib/server/lib * Import variables to remove RC namespace inside rc-lib/server/methods * Import variables to remove dependency with RC namespace * Remove duplicated server settings located in rc-lib * Export function and lib function of rc-lib but keep it inside RC namespace * Import variables from functions and lib to remove RC namespace dependency * Remove dependency of RC namespace in rc-sandstorm * Remove dependency of RC namespace in chatpal-search * Move CreadentialTokens model to rc-models * Move getUsernameSuggestion function and method from server/ to rc-lib * Remove dependency of RC namespace in meteor saml * Remove dependency of RC namespace in rc-theme * Move 2FA Users model to rc-models * Remove dependency of RC namespace in rc-2fa * Remove dependency of RC namespace in rc-action-links * Add action links in the RC namespace * Remove dependency of RC namespace in rc-analytics * Remove dependency of RC namespace in rc-assets * Add Assets in RC namespace * Remove dependency of RC namespace in rc-autolinker * Move autotranslate models to rc-models * Partial remove dependency of Rc namespace in rc-autotranslate * Remove dependency of RC namespace in rc-markdown * Finish of remotion of RC namespace in rc-autotranslate * Import Autotranslate where it has been used * Fix lint * Rename Assets variable to avoid conflicts * Fix rename Assets * Remove dependency of RC namespace in rc-blockstack * Remove RC dependency in bot-helpers * Remove RC dependency in rc-cas * Move some functions from tokenpass to channel settings and models * Move some function from livestream to channel settings * Remove dependency of RC namespace in rc-channel-settings * Fix wrong imports * Remove dependency of RC namespace in rc-channel-mail-messages * Remove dependency of RC namespace in rc-cloud * Remove dependency of RC namespace in rc-colors, cors, crowd and dolphin (#13255) * Move integrations models to rc-models * Move composeMessage function to rc-utils * Move PushNotifications class to push-notifications package * Import variables to remove dependency of RC namespace * Import variables to remove RC namespace dependency inside rc-lib/server/lib * Import variables to remove RC namespace inside rc-lib/server/methods * Import variables to remove dependency with RC namespace * Remove duplicated server settings located in rc-lib * Export function and lib function of rc-lib but keep it inside RC namespace * Import variables from functions and lib to remove RC namespace dependency * Remove dependency of RC namespace in rc-sandstorm * Remove dependency of RC namespace in chatpal-search * Move CreadentialTokens model to rc-models * Move getUsernameSuggestion function and method from server/ to rc-lib * Remove dependency of RC namespace in meteor saml * Remove dependency of RC namespace in rc-theme * Move 2FA Users model to rc-models * Remove dependency of RC namespace in rc-2fa * Remove dependency of RC namespace in rc-action-links * Add action links in the RC namespace * Remove dependency of RC namespace in rc-analytics * Remove dependency of RC namespace in rc-assets * Add Assets in RC namespace * Remove dependency of RC namespace in rc-autolinker * Move autotranslate models to rc-models * Partial remove dependency of Rc namespace in rc-autotranslate * Remove dependency of RC namespace in rc-markdown * Finish of remotion of RC namespace in rc-autotranslate * Import Autotranslate where it has been used * Fix lint * Rename Assets variable to avoid conflicts * Fix rename Assets * Remove dependency of RC namespace in rc-blockstack * Remove RC dependency in bot-helpers * Remove RC dependency in rc-cas * Move some functions from tokenpass to channel settings and models * Move some function from livestream to channel settings * Remove dependency of RC namespace in rc-channel-settings * Fix wrong imports * Remove dependency of RC namespace in rc-channel-mail-messages * Remove dependency of RC namespace in rc-cloud * Remove dependency of RC namespace in rc-colors * Remove dependency of RC namespace in rc-cors * Remove dependency of RC namespace in rc-crowd * Remove dependency of RC namespace in rc-dolphin * Remove dependency of RC namespace in rc-emoji-custom and drupal (#13256) * Move integrations models to rc-models * Move composeMessage function to rc-utils * Move PushNotifications class to push-notifications package * Import variables to remove dependency of RC namespace * Import variables to remove RC namespace dependency inside rc-lib/server/lib * Import variables to remove RC namespace inside rc-lib/server/methods * Import variables to remove dependency with RC namespace * Remove duplicated server settings located in rc-lib * Export function and lib function of rc-lib but keep it inside RC namespace * Import variables from functions and lib to remove RC namespace dependency * Remove dependency of RC namespace in rc-sandstorm * Remove dependency of RC namespace in chatpal-search * Move CreadentialTokens model to rc-models * Move getUsernameSuggestion function and method from server/ to rc-lib * Remove dependency of RC namespace in meteor saml * Remove dependency of RC namespace in rc-theme * Move 2FA Users model to rc-models * Remove dependency of RC namespace in rc-2fa * Remove dependency of RC namespace in rc-action-links * Add action links in the RC namespace * Remove dependency of RC namespace in rc-analytics * Remove dependency of RC namespace in rc-assets * Add Assets in RC namespace * Remove dependency of RC namespace in rc-autolinker * Move autotranslate models to rc-models * Partial remove dependency of Rc namespace in rc-autotranslate * Remove dependency of RC namespace in rc-markdown * Finish of remotion of RC namespace in rc-autotranslate * Import Autotranslate where it has been used * Fix lint * Rename Assets variable to avoid conflicts * Fix rename Assets * Remove dependency of RC namespace in rc-blockstack * Remove RC dependency in bot-helpers * Remove RC dependency in rc-cas * Move some functions from tokenpass to channel settings and models * Move some function from livestream to channel settings * Remove dependency of RC namespace in rc-channel-settings * Fix wrong imports * Remove dependency of RC namespace in rc-channel-mail-messages * Remove dependency of RC namespace in rc-cloud * Remove dependency of RC namespace in rc-colors * Remove dependency of RC namespace in rc-cors * Remove dependency of RC namespace in rc-crowd * Remove dependency of RC namespace in rc-dolphin * Remove dependency of RC namespace in rc-drupal * Move Emoji custom server and client models to rc-models * Remove dependency of RC namespace in rc-emoji-custom * Remove dependency of RC namespace in rc-emojione, error-handler, gh-enterprise and gitlab (#13257) * Move integrations models to rc-models * Move composeMessage function to rc-utils * Move PushNotifications class to push-notifications package * Import variables to remove dependency of RC namespace * Import variables to remove RC namespace dependency inside rc-lib/server/lib * Import variables to remove RC namespace inside rc-lib/server/methods * Import variables to remove dependency with RC namespace * Remove duplicated server settings located in rc-lib * Export function and lib function of rc-lib but keep it inside RC namespace * Import variables from functions and lib to remove RC namespace dependency * Remove dependency of RC namespace in rc-sandstorm * Remove dependency of RC namespace in chatpal-search * Move CreadentialTokens model to rc-models * Move getUsernameSuggestion function and method from server/ to rc-lib * Remove dependency of RC namespace in meteor saml * Remove dependency of RC namespace in rc-theme * Move 2FA Users model to rc-models * Remove dependency of RC namespace in rc-2fa * Remove dependency of RC namespace in rc-action-links * Add action links in the RC namespace * Remove dependency of RC namespace in rc-analytics * Remove dependency of RC namespace in rc-assets * Add Assets in RC namespace * Remove dependency of RC namespace in rc-autolinker * Move autotranslate models to rc-models * Partial remove dependency of Rc namespace in rc-autotranslate * Remove dependency of RC namespace in rc-markdown * Finish of remotion of RC namespace in rc-autotranslate * Import Autotranslate where it has been used * Fix lint * Rename Assets variable to avoid conflicts * Fix rename Assets * Remove dependency of RC namespace in rc-blockstack * Remove RC dependency in bot-helpers * Remove RC dependency in rc-cas * Move some functions from tokenpass to channel settings and models * Move some function from livestream to channel settings * Remove dependency of RC namespace in rc-channel-settings * Fix wrong imports * Remove dependency of RC namespace in rc-channel-mail-messages * Remove dependency of RC namespace in rc-cloud * Remove dependency of RC namespace in rc-colors * Remove dependency of RC namespace in rc-cors * Remove dependency of RC namespace in rc-crowd * Remove dependency of RC namespace in rc-dolphin * Remove dependency of RC namespace in rc-drupal * Move Emoji custom server and client models to rc-models * Remove dependency of RC namespace in rc-emoji-custom * Remove dependency of RC namespace in rc-emojione * Remove dependency of RC namespace in rc-error-handler * Remove dependency of RC namespace in rc-gh-enterprise * Remove dependency of RC namespace in rc-gitlab * Remove dependency of RC namespace in rc-google-natural-language, grant, google-vision and highlight-words (#13258) * Move integrations models to rc-models * Move composeMessage function to rc-utils * Move PushNotifications class to push-notifications package * Import variables to remove dependency of RC namespace * Import variables to remove RC namespace dependency inside rc-lib/server/lib * Import variables to remove RC namespace inside rc-lib/server/methods * Import variables to remove dependency with RC namespace * Remove duplicated server settings located in rc-lib * Export function and lib function of rc-lib but keep it inside RC namespace * Import variables from functions and lib to remove RC namespace dependency * Remove dependency of RC namespace in rc-sandstorm * Remove dependency of RC namespace in chatpal-search * Move CreadentialTokens model to rc-models * Move getUsernameSuggestion function and method from server/ to rc-lib * Remove dependency of RC namespace in meteor saml * Remove dependency of RC namespace in rc-theme * Move 2FA Users model to rc-models * Remove dependency of RC namespace in rc-2fa * Remove dependency of RC namespace in rc-action-links * Add action links in the RC namespace * Remove dependency of RC namespace in rc-analytics * Remove dependency of RC namespace in rc-assets * Add Assets in RC namespace * Remove dependency of RC namespace in rc-autolinker * Move autotranslate models to rc-models * Partial remove dependency of Rc namespace in rc-autotranslate * Remove dependency of RC namespace in rc-markdown * Finish of remotion of RC namespace in rc-autotranslate * Import Autotranslate where it has been used * Fix lint * Rename Assets variable to avoid conflicts * Fix rename Assets * Remove dependency of RC namespace in rc-blockstack * Remove RC dependency in bot-helpers * Remove RC dependency in rc-cas * Move some functions from tokenpass to channel settings and models * Move some function from livestream to channel settings * Remove dependency of RC namespace in rc-channel-settings * Fix wrong imports * Remove dependency of RC namespace in rc-channel-mail-messages * Remove dependency of RC namespace in rc-cloud * Remove dependency of RC namespace in rc-colors * Remove dependency of RC namespace in rc-cors * Remove dependency of RC namespace in rc-crowd * Remove dependency of RC namespace in rc-dolphin * Remove dependency of RC namespace in rc-drupal * Move Emoji custom server and client models to rc-models * Remove dependency of RC namespace in rc-emoji-custom * Remove dependency of RC namespace in rc-emojione * Remove dependency of RC namespace in rc-error-handler * Remove dependency of RC namespace in rc-gh-enterprise * Remove dependency of RC namespace in rc-gitlab * Remove dependency of RC namespace in rc-google-natural-language * Remove dependency of RC namespace in rc-grant * Remove dependency of RC namespace in rc-highlight-words * Remove dependency of RC namespace in rc-google-vision * Fix lint * Remove dependency of RC namespace in rc-iframe-login and all imports, except hipchat-enterprise (#13259) * Move integrations models to rc-models * Move composeMessage function to rc-utils * Move PushNotifications class to push-notifications package * Import variables to remove dependency of RC namespace * Import variables to remove RC namespace dependency inside rc-lib/server/lib * Import variables to remove RC namespace inside rc-lib/server/methods * Import variables to remove dependency with RC namespace * Remove duplicated server settings located in rc-lib * Export function and lib function of rc-lib but keep it inside RC namespace * Import variables from functions and lib to remove RC namespace dependency * Remove dependency of RC namespace in rc-sandstorm * Remove dependency of RC namespace in chatpal-search * Move CreadentialTokens model to rc-models * Move getUsernameSuggestion function and method from server/ to rc-lib * Remove dependency of RC namespace in meteor saml * Remove dependency of RC namespace in rc-theme * Move 2FA Users model to rc-models * Remove dependency of RC namespace in rc-2fa * Remove dependency of RC namespace in rc-action-links * Add action links in the RC namespace * Remove dependency of RC namespace in rc-analytics * Remove dependency of RC namespace in rc-assets * Add Assets in RC namespace * Remove dependency of RC namespace in rc-autolinker * Move autotranslate models to rc-models * Partial remove dependency of Rc namespace in rc-autotranslate * Remove dependency of RC namespace in rc-markdown * Finish of remotion of RC namespace in rc-autotranslate * Import Autotranslate where it has been used * Fix lint * Rename Assets variable to avoid conflicts * Fix rename Assets * Remove dependency of RC namespace in rc-blockstack * Remove RC dependency in bot-helpers * Remove RC dependency in rc-cas * Move some functions from tokenpass to channel settings and models * Move some function from livestream to channel settings * Remove dependency of RC namespace in rc-channel-settings * Fix wrong imports * Remove dependency of RC namespace in rc-channel-mail-messages * Remove dependency of RC namespace in rc-cloud * Remove dependency of RC namespace in rc-colors * Remove dependency of RC namespace in rc-cors * Remove dependency of RC namespace in rc-crowd * Remove dependency of RC namespace in rc-dolphin * Remove dependency of RC namespace in rc-drupal * Move Emoji custom server and client models to rc-models * Remove dependency of RC namespace in rc-emoji-custom * Remove dependency of RC namespace in rc-emojione * Remove dependency of RC namespace in rc-error-handler * Remove dependency of RC namespace in rc-gh-enterprise * Remove dependency of RC namespace in rc-gitlab * Remove dependency of RC namespace in rc-google-natural-language * Remove dependency of RC namespace in rc-grant * Remove dependency of RC namespace in rc-highlight-words * Remove dependency of RC namespace in rc-google-vision * Fix lint * Remove dependency of RC namespace in rc-iframe-login * Remove dependency of RC namespace in all importes, except hipchat-enterprise * Move RestAPI client to rc-api package * Remove dependency of RC namespace in rc-api/helpers and api.js * Remove dependency of RC namespace on half of api files * Partial Remove dependency of RC namespace in rc-api * import API where it was being used by the RC namespace * Move processWebhookMessage function to rc-lib package * Remove API from RC namespace and import missing function that was being used with namespace * Remove dependency of RC namespace in rc-graphql * Fix import from wrong package * Remove dependency of RC namespace in rc-importer * Remove dependency of RC namespace in rc-issue-links * Remove dependency of RC namespace in rc-katex * Move templateVarHandler fn to rc-utils * Remove dependency of RC namespace in rc-ldap * Remove dependency of RC namespace in rc-livestream * Remove dependency of RC namespace in rc-mail-messages * Remove dependency of RC namespace in rc-mapview * Remove dependency of RC namespace in rc-mentions * Remove dependency of RC namespace in rc-mentions-flextab * Remove depedency of RC namespace in rc-message-attachements * Remove dependdency of RC namespace in rc-message-mark-as-unread * Remove dependency of RC namespace in rc-message-pin * Fix templateVarHandler that was in wrong folder * Remove namespace in the new livechat endpoint * Remove dependency of RC namespace in rc-message-snippet * Remove dependency of RC namespace in rc-message-star * Remove dependency of RC namespace in rc-oauth2 * Remove dependency of RC namespace in rc-api/helpers and api.js (#13273) * Move RestAPI client to rc-api package * Remove dependency of RC namespace in rc-api/helpers and api.js * Remove dependency of RC namespace on half of api files (#13275) * Move RestAPI client to rc-api package * Remove dependency of RC namespace in rc-api/helpers and api.js * Remove dependency of RC namespace on half of api files * Partial Remove dependency of RC namespace in rc-api (#13277) * Move RestAPI client to rc-api package * Remove dependency of RC namespace in rc-api/helpers and api.js * Remove dependency of RC namespace on half of api files * Partial Remove dependency of RC namespace in rc-api * Remove dependency of RC namespace in rc-api (#13278) * Move RestAPI client to rc-api package * Remove dependency of RC namespace in rc-api/helpers and api.js * Remove dependency of RC namespace on half of api files * Partial Remove dependency of RC namespace in rc-api * import API where it was being used by the RC namespace * Move processWebhookMessage function to rc-lib package * Remove API from RC namespace and import missing function that was being used with namespace * Remove namespace in the new livechat endpoint * Remove dependency of RC namespace in rc-graphql (#13279) * Move RestAPI client to rc-api package * Remove dependency of RC namespace in rc-api/helpers and api.js * Remove dependency of RC namespace on half of api files * Partial Remove dependency of RC namespace in rc-api * import API where it was being used by the RC namespace * Move processWebhookMessage function to rc-lib package * Remove API from RC namespace and import missing function that was being used with namespace * Remove dependency of RC namespace in rc-graphql * Fix import from wrong package * Remove namespace in the new livechat endpoint * Remove dependency of RC namespace in rc-importer (#13280) * Move RestAPI client to rc-api package * Remove dependency of RC namespace in rc-api/helpers and api.js * Remove dependency of RC namespace on half of api files * Partial Remove dependency of RC namespace in rc-api * import API where it was being used by the RC namespace * Move processWebhookMessage function to rc-lib package * Remove API from RC namespace and import missing function that was being used with namespace * Remove dependency of RC namespace in rc-graphql * Fix import from wrong package * Remove dependency of RC namespace in rc-importer * Remove namespace in the new livechat endpoint * Remove dependency of RC namespace in rc-ldap, katex and issue-links (#13281) * Move RestAPI client to rc-api package * Remove dependency of RC namespace in rc-api/helpers and api.js * Remove dependency of RC namespace on half of api files * Partial Remove dependency of RC namespace in rc-api * import API where it was being used by the RC namespace * Move processWebhookMessage function to rc-lib package * Remove API from RC namespace and import missing function that was being used with namespace * Remove dependency of RC namespace in rc-graphql * Fix import from wrong package * Remove dependency of RC namespace in rc-importer * Remove dependency of RC namespace in rc-issue-links * Remove dependency of RC namespace in rc-katex * Move templateVarHandler fn to rc-utils * Remove dependency of RC namespace in rc-ldap * Fix templateVarHandler that was in wrong folder * Remove namespace in the new livechat endpoint * Remove dependency of RC namespace in rc-livestream and rc-mail-messages (#13320) * Move RestAPI client to rc-api package * Remove dependency of RC namespace in rc-api/helpers and api.js * Remove dependency of RC namespace on half of api files * Partial Remove dependency of RC namespace in rc-api * import API where it was being used by the RC namespace * Move processWebhookMessage function to rc-lib package * Remove API from RC namespace and import missing function that was being used with namespace * Remove dependency of RC namespace in rc-graphql * Fix import from wrong package * Remove dependency of RC namespace in rc-importer * Remove dependency of RC namespace in rc-issue-links * Remove dependency of RC namespace in rc-katex * Move templateVarHandler fn to rc-utils * Remove dependency of RC namespace in rc-ldap * Remove dependency of RC namespace in rc-livestream * Remove dependency of RC namespace in rc-mail-messages * Fix templateVarHandler that was in wrong folder * Remove namespace in the new livechat endpoint --- .../client/actionButton.js | 24 ++++++++++--------- .../client/starMessage.js | 8 +++---- .../rocketchat-message-star/client/tabBar.js | 4 ++-- packages/rocketchat-message-star/package.js | 4 ++++ .../rocketchat-message-star/server/index.js | 1 - .../server/models/Rooms.js | 23 ------------------ .../server/publications/starredMessages.js | 6 ++--- .../server/settings.js | 4 ++-- .../server/starMessage.js | 14 ++++++----- .../server/startup/indexes.js | 4 ++-- packages/rocketchat-models/server/index.js | 2 ++ .../server/models/OAuthApps.js | 9 +++++++ .../rocketchat-models/server/models/Rooms.js | 21 ++++++++++++++++ .../client/admin/startup.js | 7 +++--- .../client/admin/views/oauthApp.js | 8 +++---- .../client/admin/views/oauthApps.js | 4 ++-- .../package.js | 4 +++- .../server/admin/methods/addOAuthApp.js | 9 +++---- .../server/admin/methods/deleteOAuthApp.js | 9 +++---- .../server/admin/methods/updateOAuthApp.js | 13 +++++----- .../server/admin/publications/oauthApps.js | 7 +++--- .../server/index.js | 1 - .../server/models/OAuthApps.js | 17 ------------- .../server/oauth/default-services.js | 6 ++--- .../server/oauth/oauth2-server.js | 10 ++++---- 25 files changed, 112 insertions(+), 107 deletions(-) delete mode 100644 packages/rocketchat-message-star/server/models/Rooms.js create mode 100644 packages/rocketchat-models/server/models/OAuthApps.js delete mode 100644 packages/rocketchat-oauth2-server-config/server/models/OAuthApps.js diff --git a/packages/rocketchat-message-star/client/actionButton.js b/packages/rocketchat-message-star/client/actionButton.js index 097f4a26d41..c5ce3c2751c 100644 --- a/packages/rocketchat-message-star/client/actionButton.js +++ b/packages/rocketchat-message-star/client/actionButton.js @@ -1,12 +1,14 @@ import { Meteor } from 'meteor/meteor'; import { Template } from 'meteor/templating'; import { TAPi18n } from 'meteor/tap:i18n'; -import { RocketChat, handleError } from 'meteor/rocketchat:lib'; -import { RoomHistoryManager } from 'meteor/rocketchat:ui'; +import { handleError } from 'meteor/rocketchat:utils'; +import { Subscriptions } from 'meteor/rocketchat:models'; +import { settings } from 'meteor/rocketchat:settings'; +import { RoomHistoryManager, MessageAction } from 'meteor/rocketchat:ui-utils'; import toastr from 'toastr'; Meteor.startup(function() { - RocketChat.MessageAction.addButton({ + MessageAction.addButton({ id: 'star-message', icon: 'star', label: 'Star_Message', @@ -21,7 +23,7 @@ Meteor.startup(function() { }); }, condition(message) { - if (RocketChat.models.Subscriptions.findOne({ rid: message.rid }) == null && RocketChat.settings.get('Message_AllowStarring')) { + if (Subscriptions.findOne({ rid: message.rid }) == null && settings.get('Message_AllowStarring')) { return false; } @@ -31,7 +33,7 @@ Meteor.startup(function() { group: 'menu', }); - RocketChat.MessageAction.addButton({ + MessageAction.addButton({ id: 'unstar-message', icon: 'star', label: 'Unstar_Message', @@ -46,7 +48,7 @@ Meteor.startup(function() { }); }, condition(message) { - if (RocketChat.models.Subscriptions.findOne({ rid: message.rid }) == null && RocketChat.settings.get('Message_AllowStarring')) { + if (Subscriptions.findOne({ rid: message.rid }) == null && settings.get('Message_AllowStarring')) { return false; } @@ -56,7 +58,7 @@ Meteor.startup(function() { group: 'menu', }); - RocketChat.MessageAction.addButton({ + MessageAction.addButton({ id: 'jump-to-star-message', icon: 'jump', label: 'Jump_to_message', @@ -69,7 +71,7 @@ Meteor.startup(function() { RoomHistoryManager.getSurroundingMessages(message, 50); }, condition(message) { - if (RocketChat.models.Subscriptions.findOne({ rid: message.rid }) == null) { + if (Subscriptions.findOne({ rid: message.rid }) == null) { return false; } return true; @@ -78,7 +80,7 @@ Meteor.startup(function() { group: 'menu', }); - RocketChat.MessageAction.addButton({ + MessageAction.addButton({ id: 'permalink-star', icon: 'permalink', label: 'Permalink', @@ -86,11 +88,11 @@ Meteor.startup(function() { context: ['starred'], async action(event) { const message = this._arguments[1]; - $(event.currentTarget).attr('data-clipboard-text', await RocketChat.MessageAction.getPermaLink(message._id)); + $(event.currentTarget).attr('data-clipboard-text', await MessageAction.getPermaLink(message._id)); toastr.success(TAPi18n.__('Copied')); }, condition(message) { - if (RocketChat.models.Subscriptions.findOne({ rid: message.rid }) == null) { + if (Subscriptions.findOne({ rid: message.rid }) == null) { return false; } return true; diff --git a/packages/rocketchat-message-star/client/starMessage.js b/packages/rocketchat-message-star/client/starMessage.js index 349470f0998..cd9066bca7c 100644 --- a/packages/rocketchat-message-star/client/starMessage.js +++ b/packages/rocketchat-message-star/client/starMessage.js @@ -1,16 +1,16 @@ import { Meteor } from 'meteor/meteor'; -import { RocketChat } from 'meteor/rocketchat:lib'; -import { ChatMessage } from 'meteor/rocketchat:ui'; +import { settings } from 'meteor/rocketchat:settings'; +import { ChatMessage, Subscriptions } from 'meteor/rocketchat:models'; Meteor.methods({ starMessage(message) { if (!Meteor.userId()) { return false; } - if (RocketChat.models.Subscriptions.findOne({ rid: message.rid }) == null) { + if (Subscriptions.findOne({ rid: message.rid }) == null) { return false; } - if (!RocketChat.settings.get('Message_AllowStarring')) { + if (!settings.get('Message_AllowStarring')) { return false; } return ChatMessage.update({ diff --git a/packages/rocketchat-message-star/client/tabBar.js b/packages/rocketchat-message-star/client/tabBar.js index f93f2701654..87cfbb61f2a 100644 --- a/packages/rocketchat-message-star/client/tabBar.js +++ b/packages/rocketchat-message-star/client/tabBar.js @@ -1,8 +1,8 @@ import { Meteor } from 'meteor/meteor'; -import { RocketChat } from 'meteor/rocketchat:lib'; +import { TabBar } from 'meteor/rocketchat:ui-utils'; Meteor.startup(function() { - RocketChat.TabBar.addButton({ + TabBar.addButton({ groups: ['channel', 'group', 'direct'], id: 'starred-messages', i18nTitle: 'Starred_Messages', diff --git a/packages/rocketchat-message-star/package.js b/packages/rocketchat-message-star/package.js index cf7bb6d3c53..03dfd647fe1 100644 --- a/packages/rocketchat-message-star/package.js +++ b/packages/rocketchat-message-star/package.js @@ -10,6 +10,10 @@ Package.onUse(function(api) { 'mongo', 'ecmascript', 'rocketchat:lib', + 'rocketchat:utils', + 'rocketchat:models', + 'rocketchat:settings', + 'rocketchat:ui-utils', 'templating', ]); api.addFiles('client/views/stylesheets/messagestar.css', 'client'); diff --git a/packages/rocketchat-message-star/server/index.js b/packages/rocketchat-message-star/server/index.js index 9b347ac8584..ceeedf7d866 100644 --- a/packages/rocketchat-message-star/server/index.js +++ b/packages/rocketchat-message-star/server/index.js @@ -1,4 +1,3 @@ -import './models/Rooms'; import './settings'; import './starMessage'; import './publications/starredMessages'; diff --git a/packages/rocketchat-message-star/server/models/Rooms.js b/packages/rocketchat-message-star/server/models/Rooms.js deleted file mode 100644 index f011f896892..00000000000 --- a/packages/rocketchat-message-star/server/models/Rooms.js +++ /dev/null @@ -1,23 +0,0 @@ -import { RocketChat } from 'meteor/rocketchat:lib'; - -RocketChat.models.Rooms.updateLastMessageStar = function(roomId, userId, starred) { - let update; - const query = { _id: roomId }; - - if (starred) { - update = { - $addToSet: { - 'lastMessage.starred': { _id: userId }, - }, - }; - } else { - update = { - $pull: { - 'lastMessage.starred': { _id: userId }, - }, - }; - } - - return this.update(query, update); -}; - diff --git a/packages/rocketchat-message-star/server/publications/starredMessages.js b/packages/rocketchat-message-star/server/publications/starredMessages.js index 20795c44922..1a9dfe00e1b 100644 --- a/packages/rocketchat-message-star/server/publications/starredMessages.js +++ b/packages/rocketchat-message-star/server/publications/starredMessages.js @@ -1,19 +1,19 @@ import { Meteor } from 'meteor/meteor'; -import { RocketChat } from 'meteor/rocketchat:lib'; +import { Users, Messages } from 'meteor/rocketchat:models'; Meteor.publish('starredMessages', function(rid, limit = 50) { if (!this.userId) { return this.ready(); } const publication = this; - const user = RocketChat.models.Users.findOneById(this.userId); + const user = Users.findOneById(this.userId); if (!user) { return this.ready(); } if (!Meteor.call('canAccessRoom', rid, this.userId)) { return this.ready(); } - const cursorHandle = RocketChat.models.Messages.findStarredByUserAtRoom(this.userId, rid, { + const cursorHandle = Messages.findStarredByUserAtRoom(this.userId, rid, { sort: { ts: -1, }, diff --git a/packages/rocketchat-message-star/server/settings.js b/packages/rocketchat-message-star/server/settings.js index f83b9f82d43..f4a18790d3a 100644 --- a/packages/rocketchat-message-star/server/settings.js +++ b/packages/rocketchat-message-star/server/settings.js @@ -1,8 +1,8 @@ import { Meteor } from 'meteor/meteor'; -import { RocketChat } from 'meteor/rocketchat:lib'; +import { settings } from 'meteor/rocketchat:settings'; Meteor.startup(function() { - return RocketChat.settings.add('Message_AllowStarring', true, { + return settings.add('Message_AllowStarring', true, { type: 'boolean', group: 'Message', public: true, diff --git a/packages/rocketchat-message-star/server/starMessage.js b/packages/rocketchat-message-star/server/starMessage.js index 7cad3581642..b174ed83ff1 100644 --- a/packages/rocketchat-message-star/server/starMessage.js +++ b/packages/rocketchat-message-star/server/starMessage.js @@ -1,5 +1,7 @@ import { Meteor } from 'meteor/meteor'; -import { RocketChat } from 'meteor/rocketchat:lib'; +import { settings } from 'meteor/rocketchat:settings'; +import { isTheLastMessage } from 'meteor/rocketchat:lib'; +import { Subscriptions, Rooms, Messages } from 'meteor/rocketchat:models'; Meteor.methods({ starMessage(message) { @@ -9,22 +11,22 @@ Meteor.methods({ }); } - if (!RocketChat.settings.get('Message_AllowStarring')) { + if (!settings.get('Message_AllowStarring')) { throw new Meteor.Error('error-action-not-allowed', 'Message starring not allowed', { method: 'pinMessage', action: 'Message_starring', }); } - const subscription = RocketChat.models.Subscriptions.findOneByRoomIdAndUserId(message.rid, Meteor.userId(), { fields: { _id: 1 } }); + const subscription = Subscriptions.findOneByRoomIdAndUserId(message.rid, Meteor.userId(), { fields: { _id: 1 } }); if (!subscription) { return false; } const room = Meteor.call('canAccessRoom', message.rid, Meteor.userId()); - if (RocketChat.isTheLastMessage(room, message)) { - RocketChat.models.Rooms.updateLastMessageStar(room._id, Meteor.userId(), message.starred); + if (isTheLastMessage(room, message)) { + Rooms.updateLastMessageStar(room._id, Meteor.userId(), message.starred); } - return RocketChat.models.Messages.updateUserStarById(message._id, Meteor.userId(), message.starred); + return Messages.updateUserStarById(message._id, Meteor.userId(), message.starred); }, }); diff --git a/packages/rocketchat-message-star/server/startup/indexes.js b/packages/rocketchat-message-star/server/startup/indexes.js index 6b45c173eac..bfebc7dc00b 100644 --- a/packages/rocketchat-message-star/server/startup/indexes.js +++ b/packages/rocketchat-message-star/server/startup/indexes.js @@ -1,9 +1,9 @@ import { Meteor } from 'meteor/meteor'; -import { RocketChat } from 'meteor/rocketchat:lib'; +import { Messages } from 'meteor/rocketchat:models'; Meteor.startup(function() { return Meteor.defer(function() { - return RocketChat.models.Messages.tryEnsureIndex({ + return Messages.tryEnsureIndex({ 'starred._id': 1, }, { sparse: 1, diff --git a/packages/rocketchat-models/server/index.js b/packages/rocketchat-models/server/index.js index 55f01c48ba3..2abc6e8718c 100644 --- a/packages/rocketchat-models/server/index.js +++ b/packages/rocketchat-models/server/index.js @@ -19,6 +19,7 @@ import Integrations from './models/Integrations'; import IntegrationHistory from './models/IntegrationHistory'; import CredentialTokens from './models/CredentialTokens'; import EmojiCustom from './models/EmojiCustom'; +import OAuthApps from './models/OAuthApps'; export { Base, @@ -42,4 +43,5 @@ export { IntegrationHistory, CredentialTokens, EmojiCustom, + OAuthApps, }; diff --git a/packages/rocketchat-models/server/models/OAuthApps.js b/packages/rocketchat-models/server/models/OAuthApps.js new file mode 100644 index 00000000000..6aedffb63ae --- /dev/null +++ b/packages/rocketchat-models/server/models/OAuthApps.js @@ -0,0 +1,9 @@ +import { Base } from './_Base'; + +export class OAuthApps extends Base { + constructor() { + super('oauth_apps'); + } +} + +export default new OAuthApps(); diff --git a/packages/rocketchat-models/server/models/Rooms.js b/packages/rocketchat-models/server/models/Rooms.js index 42f0846ecdb..79fd2927750 100644 --- a/packages/rocketchat-models/server/models/Rooms.js +++ b/packages/rocketchat-models/server/models/Rooms.js @@ -26,6 +26,27 @@ export class Rooms extends Base { return this.findOne(query, options); } + updateLastMessageStar(roomId, userId, starred) { + let update; + const query = { _id: roomId }; + + if (starred) { + update = { + $addToSet: { + 'lastMessage.starred': { _id: userId }, + }, + }; + } else { + update = { + $pull: { + 'lastMessage.starred': { _id: userId }, + }, + }; + } + + return this.update(query, update); + } + setLastMessageSnippeted(roomId, message, snippetName, snippetedBy, snippeted, snippetedAt) { const query = { _id: roomId }; diff --git a/packages/rocketchat-oauth2-server-config/client/admin/startup.js b/packages/rocketchat-oauth2-server-config/client/admin/startup.js index 1d3eb2cbdff..7643e8231c9 100644 --- a/packages/rocketchat-oauth2-server-config/client/admin/startup.js +++ b/packages/rocketchat-oauth2-server-config/client/admin/startup.js @@ -1,10 +1,11 @@ -import { RocketChat } from 'meteor/rocketchat:lib'; +import { AdminBox } from 'meteor/rocketchat:ui-utils'; +import { hasAllPermission } from 'meteor/rocketchat:authorization'; -RocketChat.AdminBox.addOption({ +AdminBox.addOption({ href: 'admin-oauth-apps', i18nLabel: 'OAuth Apps', icon: 'discover', permissionGranted() { - return RocketChat.authz.hasAllPermission('manage-oauth-apps'); + return hasAllPermission('manage-oauth-apps'); }, }); diff --git a/packages/rocketchat-oauth2-server-config/client/admin/views/oauthApp.js b/packages/rocketchat-oauth2-server-config/client/admin/views/oauthApp.js index 706f6d73a50..5dace4435db 100644 --- a/packages/rocketchat-oauth2-server-config/client/admin/views/oauthApp.js +++ b/packages/rocketchat-oauth2-server-config/client/admin/views/oauthApp.js @@ -3,9 +3,9 @@ import { ReactiveVar } from 'meteor/reactive-var'; import { FlowRouter } from 'meteor/kadira:flow-router'; import { Template } from 'meteor/templating'; import { TAPi18n } from 'meteor/tap:i18n'; -import { RocketChat, handleError } from 'meteor/rocketchat:lib'; -import { modal } from 'meteor/rocketchat:ui'; -import { t } from 'meteor/rocketchat:utils'; +import { hasAllPermission } from 'meteor/rocketchat:authorization'; +import { modal } from 'meteor/rocketchat:ui-utils'; +import { t, handleError } from 'meteor/rocketchat:utils'; import { ChatOAuthApps } from '../collection'; import toastr from 'toastr'; @@ -18,7 +18,7 @@ Template.oauthApp.onCreated(function() { Template.oauthApp.helpers({ hasPermission() { - return RocketChat.authz.hasAllPermission('manage-oauth-apps'); + return hasAllPermission('manage-oauth-apps'); }, data() { const instance = Template.instance(); diff --git a/packages/rocketchat-oauth2-server-config/client/admin/views/oauthApps.js b/packages/rocketchat-oauth2-server-config/client/admin/views/oauthApps.js index c779e6b08d7..cabdf6e76ee 100644 --- a/packages/rocketchat-oauth2-server-config/client/admin/views/oauthApps.js +++ b/packages/rocketchat-oauth2-server-config/client/admin/views/oauthApps.js @@ -1,5 +1,5 @@ import { Template } from 'meteor/templating'; -import { RocketChat } from 'meteor/rocketchat:lib'; +import { hasAllPermission } from 'meteor/rocketchat:authorization'; import { ChatOAuthApps } from '../collection'; import moment from 'moment'; @@ -9,7 +9,7 @@ Template.oauthApps.onCreated(function() { Template.oauthApps.helpers({ hasPermission() { - return RocketChat.authz.hasAllPermission('manage-oauth-apps'); + return hasAllPermission('manage-oauth-apps'); }, applications() { return ChatOAuthApps.find(); diff --git a/packages/rocketchat-oauth2-server-config/package.js b/packages/rocketchat-oauth2-server-config/package.js index 6533759629a..efa8a1cffb4 100644 --- a/packages/rocketchat-oauth2-server-config/package.js +++ b/packages/rocketchat-oauth2-server-config/package.js @@ -10,7 +10,9 @@ Package.onUse(function(api) { 'webapp', 'mongo', 'rocketchat:utils', - 'rocketchat:lib', + 'rocketchat:models', + 'rocketchat:ui-utils', + 'rocketchat:authorization', 'rocketchat:api', 'rocketchat:theme', 'rocketchat:oauth2-server', diff --git a/packages/rocketchat-oauth2-server-config/server/admin/methods/addOAuthApp.js b/packages/rocketchat-oauth2-server-config/server/admin/methods/addOAuthApp.js index 75c08982cac..c847bc51a95 100644 --- a/packages/rocketchat-oauth2-server-config/server/admin/methods/addOAuthApp.js +++ b/packages/rocketchat-oauth2-server-config/server/admin/methods/addOAuthApp.js @@ -1,11 +1,12 @@ import { Meteor } from 'meteor/meteor'; import { Random } from 'meteor/random'; -import { RocketChat } from 'meteor/rocketchat:lib'; +import { hasPermission } from 'meteor/rocketchat:authorization'; +import { Users, OAuthApps } from 'meteor/rocketchat:models'; import _ from 'underscore'; Meteor.methods({ addOAuthApp(application) { - if (!RocketChat.authz.hasPermission(this.userId, 'manage-oauth-apps')) { + if (!hasPermission(this.userId, 'manage-oauth-apps')) { throw new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'addOAuthApp' }); } if (!_.isString(application.name) || application.name.trim() === '') { @@ -20,8 +21,8 @@ Meteor.methods({ application.clientId = Random.id(); application.clientSecret = Random.secret(); application._createdAt = new Date; - application._createdBy = RocketChat.models.Users.findOne(this.userId, { fields: { username: 1 } }); - application._id = RocketChat.models.OAuthApps.insert(application); + application._createdBy = Users.findOne(this.userId, { fields: { username: 1 } }); + application._id = OAuthApps.insert(application); return application; }, }); diff --git a/packages/rocketchat-oauth2-server-config/server/admin/methods/deleteOAuthApp.js b/packages/rocketchat-oauth2-server-config/server/admin/methods/deleteOAuthApp.js index d1fabde3b8c..1a1a2b88bad 100644 --- a/packages/rocketchat-oauth2-server-config/server/admin/methods/deleteOAuthApp.js +++ b/packages/rocketchat-oauth2-server-config/server/admin/methods/deleteOAuthApp.js @@ -1,16 +1,17 @@ import { Meteor } from 'meteor/meteor'; -import { RocketChat } from 'meteor/rocketchat:lib'; +import { hasPermission } from 'meteor/rocketchat:authorization'; +import { OAuthApps } from 'meteor/rocketchat:models'; Meteor.methods({ deleteOAuthApp(applicationId) { - if (!RocketChat.authz.hasPermission(this.userId, 'manage-oauth-apps')) { + if (!hasPermission(this.userId, 'manage-oauth-apps')) { throw new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'deleteOAuthApp' }); } - const application = RocketChat.models.OAuthApps.findOne(applicationId); + const application = OAuthApps.findOne(applicationId); if (application == null) { throw new Meteor.Error('error-application-not-found', 'Application not found', { method: 'deleteOAuthApp' }); } - RocketChat.models.OAuthApps.remove({ _id: applicationId }); + OAuthApps.remove({ _id: applicationId }); return true; }, }); diff --git a/packages/rocketchat-oauth2-server-config/server/admin/methods/updateOAuthApp.js b/packages/rocketchat-oauth2-server-config/server/admin/methods/updateOAuthApp.js index 788fbebd2cc..c5e85cdcc27 100644 --- a/packages/rocketchat-oauth2-server-config/server/admin/methods/updateOAuthApp.js +++ b/packages/rocketchat-oauth2-server-config/server/admin/methods/updateOAuthApp.js @@ -1,10 +1,11 @@ import { Meteor } from 'meteor/meteor'; -import { RocketChat } from 'meteor/rocketchat:lib'; +import { hasPermission } from 'meteor/rocketchat:authorization'; +import { OAuthApps, Users } from 'meteor/rocketchat:models'; import _ from 'underscore'; Meteor.methods({ updateOAuthApp(applicationId, application) { - if (!RocketChat.authz.hasPermission(this.userId, 'manage-oauth-apps')) { + if (!hasPermission(this.userId, 'manage-oauth-apps')) { throw new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'updateOAuthApp' }); } if (!_.isString(application.name) || application.name.trim() === '') { @@ -16,23 +17,23 @@ Meteor.methods({ if (!_.isBoolean(application.active)) { throw new Meteor.Error('error-invalid-arguments', 'Invalid arguments', { method: 'updateOAuthApp' }); } - const currentApplication = RocketChat.models.OAuthApps.findOne(applicationId); + const currentApplication = OAuthApps.findOne(applicationId); if (currentApplication == null) { throw new Meteor.Error('error-application-not-found', 'Application not found', { method: 'updateOAuthApp' }); } - RocketChat.models.OAuthApps.update(applicationId, { + OAuthApps.update(applicationId, { $set: { name: application.name, active: application.active, redirectUri: application.redirectUri, _updatedAt: new Date, - _updatedBy: RocketChat.models.Users.findOne(this.userId, { + _updatedBy: Users.findOne(this.userId, { fields: { username: 1, }, }), }, }); - return RocketChat.models.OAuthApps.findOne(applicationId); + return OAuthApps.findOne(applicationId); }, }); diff --git a/packages/rocketchat-oauth2-server-config/server/admin/publications/oauthApps.js b/packages/rocketchat-oauth2-server-config/server/admin/publications/oauthApps.js index c6f872421f3..1125675026c 100644 --- a/packages/rocketchat-oauth2-server-config/server/admin/publications/oauthApps.js +++ b/packages/rocketchat-oauth2-server-config/server/admin/publications/oauthApps.js @@ -1,12 +1,13 @@ import { Meteor } from 'meteor/meteor'; -import { RocketChat } from 'meteor/rocketchat:lib'; +import { hasPermission } from 'meteor/rocketchat:authorization'; +import { OAuthApps } from 'meteor/rocketchat:models'; Meteor.publish('oauthApps', function() { if (!this.userId) { return this.ready(); } - if (!RocketChat.authz.hasPermission(this.userId, 'manage-oauth-apps')) { + if (!hasPermission(this.userId, 'manage-oauth-apps')) { this.error(Meteor.Error('error-not-allowed', 'Not allowed', { publish: 'oauthApps' })); } - return RocketChat.models.OAuthApps.find(); + return OAuthApps.find(); }); diff --git a/packages/rocketchat-oauth2-server-config/server/index.js b/packages/rocketchat-oauth2-server-config/server/index.js index 0ca7e49a690..4fe04df84ed 100644 --- a/packages/rocketchat-oauth2-server-config/server/index.js +++ b/packages/rocketchat-oauth2-server-config/server/index.js @@ -1,4 +1,3 @@ -import './models/OAuthApps'; import './oauth/oauth2-server'; import './oauth/default-services'; import './admin/publications/oauthApps'; diff --git a/packages/rocketchat-oauth2-server-config/server/models/OAuthApps.js b/packages/rocketchat-oauth2-server-config/server/models/OAuthApps.js deleted file mode 100644 index 4d889bbd974..00000000000 --- a/packages/rocketchat-oauth2-server-config/server/models/OAuthApps.js +++ /dev/null @@ -1,17 +0,0 @@ -import { RocketChat } from 'meteor/rocketchat:lib'; - -RocketChat.models.OAuthApps = new class extends RocketChat.models._Base { - constructor() { - super('oauth_apps'); - } -}; - - -// FIND -// findByRole: (role, options) -> -// query = -// roles: role - -// return @find query, options - -// CREATE diff --git a/packages/rocketchat-oauth2-server-config/server/oauth/default-services.js b/packages/rocketchat-oauth2-server-config/server/oauth/default-services.js index 156d7992021..380d3711d36 100644 --- a/packages/rocketchat-oauth2-server-config/server/oauth/default-services.js +++ b/packages/rocketchat-oauth2-server-config/server/oauth/default-services.js @@ -1,7 +1,7 @@ -import { RocketChat } from 'meteor/rocketchat:lib'; +import { OAuthApps } from 'meteor/rocketchat:models'; -if (!RocketChat.models.OAuthApps.findOne('zapier')) { - RocketChat.models.OAuthApps.insert({ +if (!OAuthApps.findOne('zapier')) { + OAuthApps.insert({ _id: 'zapier', name: 'Zapier', active: true, diff --git a/packages/rocketchat-oauth2-server-config/server/oauth/oauth2-server.js b/packages/rocketchat-oauth2-server-config/server/oauth/oauth2-server.js index b8b79807b1c..ed6f8be4348 100644 --- a/packages/rocketchat-oauth2-server-config/server/oauth/oauth2-server.js +++ b/packages/rocketchat-oauth2-server-config/server/oauth/oauth2-server.js @@ -1,6 +1,6 @@ import { Meteor } from 'meteor/meteor'; import { WebApp } from 'meteor/webapp'; -import { RocketChat } from 'meteor/rocketchat:lib'; +import { OAuthApps, Users } from 'meteor/rocketchat:models'; import { OAuth2Server } from 'meteor/rocketchat:oauth2-server'; import { API } from 'meteor/rocketchat:api'; @@ -8,7 +8,7 @@ const oauth2server = new OAuth2Server({ accessTokensCollectionName: 'rocketchat_oauth_access_tokens', refreshTokensCollectionName: 'rocketchat_oauth_refresh_tokens', authCodesCollectionName: 'rocketchat_oauth_auth_codes', - clientsCollection: RocketChat.models.OAuthApps.model, + clientsCollection: OAuthApps.model, debug: true, }); @@ -25,7 +25,7 @@ oauth2server.routes.get('/oauth/userinfo', function(req, res) { if (token == null) { return res.sendStatus(401).send('Invalid Token'); } - const user = RocketChat.models.Users.findOneById(token.userId); + const user = Users.findOneById(token.userId); if (user == null) { return res.sendStatus(401).send('Invalid Token'); } @@ -46,7 +46,7 @@ Meteor.publish('oauthClient', function(clientId) { if (!this.userId) { return this.ready(); } - return RocketChat.models.OAuthApps.find({ + return OAuthApps.find({ clientId, active: true, }, { @@ -79,7 +79,7 @@ API.v1.addAuthMethod(function() { if ((accessToken.expires != null) && accessToken.expires !== 0 && accessToken.expires < new Date()) { return; } - const user = RocketChat.models.Users.findOne(accessToken.userId); + const user = Users.findOne(accessToken.userId); if (user == null) { return; }