Remove dependency of RC namespace in rc-statistics and tokenpass (#13359)

* 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-oembed

* Remove dependency of RC namespace in rc-otr

* Remove dependency of RC namespace in rc-reactions

* Remove dependency of RC namespace in rc-retention-policy

* Remove dependency of RC namespace in rc-earch

* Remove dependency of RC namespace in rc-setup-wizard

* Remove dependency of RC namespace in rc-slackbridge

* Remove dependency of Rc namespace in slashcommands-asciiarts

* Remove depedency of RC namespace in rc-slash-archiveroom

* Remove dependency of RC namespace in rc-slash-create

* Remove dependency of RC namespace in rc-slash-help

* Remove dependency of RC namespace in rc-slash-hide

* Remove dependency of RC namespace in rc-slash-invite

* Remove dependency of RC namespace in rc-slash-inviteall

* Remove dependency of RC namespace in rc-slash-join

* Remove dependency of RC namespace in rc-slash-kick

* Remove dependency of RC namespace in rc-slash-leave

* Remove dependency of RC namespace in rc-slash-me

* Remove dependency of RC namespace in rc-slash-msg

* Remove dependency of RC namespace in rc-slash-mute

* Remove dependency of RC namespace in rc-slash-open

* Remove dependency of RC namespace in rc-slash-topic

* Remove dependency of RC namespace in rc-slash-unarchiveroom

* Remove dependency of RC namespace in rc-smarsh-connector

* Remove dependency of RC namespace in rc-sms

* Remove dependency of RC namespace in rc-spotify

* Remove dependency of RC namespace in rc-statistics

* Move tokenpass models methods to rc-models

* Remove dependency of RC namespace in rc-tokenpass

* import tokenpass inside rc-lib

*  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
pull/13361/head^2
Marcos Spessatto Defendi 6 years ago committed by Rodrigo Nascimento
parent 763c128451
commit 2ab4ce61ce
  1. 1
      packages/rocketchat-lib/package.js
  2. 5
      packages/rocketchat-lib/server/methods/joinRoom.js
  3. 33
      packages/rocketchat-models/server/models/Rooms.js
  4. 16
      packages/rocketchat-models/server/models/Subscriptions.js
  5. 24
      packages/rocketchat-models/server/models/Users.js
  6. 2
      packages/rocketchat-statistics/client/index.js
  7. 4
      packages/rocketchat-statistics/lib/rocketchat.js
  8. 8
      packages/rocketchat-statistics/package.js
  9. 69
      packages/rocketchat-statistics/server/functions/get.js
  10. 13
      packages/rocketchat-statistics/server/functions/save.js
  11. 3
      packages/rocketchat-statistics/server/index.js
  12. 10
      packages/rocketchat-statistics/server/methods/getStatistics.js
  13. 4
      packages/rocketchat-statistics/server/models/import.js
  14. 5
      packages/rocketchat-tokenpass/client/roomType.js
  15. 7
      packages/rocketchat-tokenpass/client/startup.js
  16. 4
      packages/rocketchat-tokenpass/client/tokenChannelsList.js
  17. 5
      packages/rocketchat-tokenpass/client/tokenpassChannelSettings.js
  18. 8
      packages/rocketchat-tokenpass/lib/common.js
  19. 5
      packages/rocketchat-tokenpass/package.js
  20. 4
      packages/rocketchat-tokenpass/server/Tokenpass.js
  21. 23
      packages/rocketchat-tokenpass/server/cronRemoveUsers.js
  22. 6
      packages/rocketchat-tokenpass/server/functions/getProtectedTokenpassBalances.js
  23. 6
      packages/rocketchat-tokenpass/server/functions/getPublicTokenpassBalances.js
  24. 6
      packages/rocketchat-tokenpass/server/functions/saveRoomTokensMinimumBalance.js
  25. 12
      packages/rocketchat-tokenpass/server/functions/updateUserTokenpassBalances.js
  26. 8
      packages/rocketchat-tokenpass/server/index.js
  27. 7
      packages/rocketchat-tokenpass/server/methods/findTokenChannels.js
  28. 4
      packages/rocketchat-tokenpass/server/methods/getChannelTokenpass.js
  29. 33
      packages/rocketchat-tokenpass/server/models/Rooms.js
  30. 17
      packages/rocketchat-tokenpass/server/models/Subscriptions.js
  31. 25
      packages/rocketchat-tokenpass/server/models/Users.js
  32. 6
      packages/rocketchat-tokenpass/server/models/indexes.js
  33. 21
      packages/rocketchat-tokenpass/server/startup.js
  34. 7
      server/startup/cron.js
  35. 4
      server/startup/migrations/v059.js

@ -56,6 +56,7 @@ Package.onUse(function(api) {
api.use('rocketchat:assets');
api.use('rocketchat:markdown');
api.use('rocketchat:channel-settings');
api.use('rocketchat:tokenpass');
api.use('templating', 'client');
api.use('kadira:flow-router');

@ -2,6 +2,7 @@ import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import { hasPermission, canAccessRoom } from 'meteor/rocketchat:authorization';
import { Rooms } from 'meteor/rocketchat:models';
import { Tokenpass, updateUserTokenpassBalances } from 'meteor/rocketchat:tokenpass';
import { addUserToRoom } from '../functions';
Meteor.methods({
@ -21,9 +22,9 @@ Meteor.methods({
// TODO we should have a 'beforeJoinRoom' call back so external services can do their own validations
const user = Meteor.user();
if (room.tokenpass && user && user.services && user.services.tokenpass) {
const balances = RocketChat.updateUserTokenpassBalances(user);
const balances = updateUserTokenpassBalances(user);
if (!RocketChat.Tokenpass.validateAccess(room.tokenpass, balances)) {
if (!Tokenpass.validateAccess(room.tokenpass, balances)) {
throw new Meteor.Error('error-not-allowed', 'Token required', { method: 'joinRoom' });
}
} else {

@ -12,6 +12,7 @@ export class Rooms extends Base {
this.tryEnsureIndex({ default: 1 });
this.tryEnsureIndex({ t: 1 });
this.tryEnsureIndex({ 'u._id': 1 });
this.tryEnsureIndex({ 'tokenpass.tokens.token': 1 });
}
findOneByIdOrName(_idOrName, options) {
@ -26,6 +27,38 @@ export class Rooms extends Base {
return this.findOne(query, options);
}
findByTokenpass(tokens) {
const query = {
'tokenpass.tokens.token': {
$in: tokens,
},
};
return this._db.find(query).fetch();
}
setTokensById(_id, tokens) {
const update = {
$set: {
'tokenpass.tokens.token': tokens,
},
};
return this.update({ _id }, update);
}
findAllTokenChannels() {
const query = {
tokenpass: { $exists: true },
};
const options = {
fields: {
tokenpass: 1,
},
};
return this._db.find(query, options);
}
setReactionsInLastMessage(roomId, lastMessage) {
return this.update({ _id: roomId }, { $set: { lastMessage } });
}

@ -30,6 +30,22 @@ export class Subscriptions extends Base {
this.tryEnsureIndex({ 'userHighlights.0': 1 }, { sparse: 1 });
}
findByRoomIds(roomIds) {
const query = {
rid: {
$in: roomIds,
},
};
const options = {
fields: {
'u._id': 1,
rid: 1,
},
};
return this._db.find(query, options);
}
updateAutoTranslateById(_id, autoTranslate) {
const query = {
_id,

@ -26,6 +26,30 @@ export class Users extends Base {
});
}
setTokenpassTcaBalances(_id, tcaBalances) {
const update = {
$set: {
'services.tokenpass.tcaBalances': tcaBalances,
},
};
return this.update(_id, update);
}
getTokenBalancesByUserId(userId) {
const query = {
_id: userId,
};
const options = {
fields: {
'services.tokenpass.tcaBalances': 1,
},
};
return this.findOne(query, options);
}
roleBaseQuery(userId) {
return { _id: userId };
}

@ -1 +1 @@
import '../lib/rocketchat';
export { statistics } from '../lib/rocketchat';

@ -1,3 +1 @@
import { RocketChat } from 'meteor/rocketchat:lib';
RocketChat.statistics = {};
export const statistics = {};

@ -9,8 +9,14 @@ Package.onUse(function(api) {
api.use([
'mongo',
'ecmascript',
'rocketchat:lib',
'littledata:synced-cron',
'accounts-base',
'rocketchat:migrations',
'rocketchat:utils',
'rocketchat:settings',
'rocketchat:authorization',
'rocketchat:models',
'rocketchat:logger',
'konecty:multiple-instances-status',
]);
api.mainModule('client/index.js', 'client');

@ -3,9 +3,12 @@ import { MongoInternals } from 'meteor/mongo';
import _ from 'underscore';
import os from 'os';
import LivechatVisitors from 'meteor/rocketchat:livechat/server/models/LivechatVisitors';
import { RocketChat } from 'meteor/rocketchat:lib';
import { InstanceStatus } from 'meteor/konecty:multiple-instances-status';
import { Sessions } from 'meteor/rocketchat:models';
import { Sessions, Settings, Users, Rooms, Subscriptions, Uploads, Messages } from 'meteor/rocketchat:models';
import { settings } from 'meteor/rocketchat:settings';
import { Info } from 'meteor/rocketchat:utils';
import { Migrations } from 'meteor/rocketchat:migrations';
import { statistics } from '../../lib/rocketchat';
const wizardFields = [
'Organization_Type',
@ -20,37 +23,37 @@ const wizardFields = [
'Allow_Marketing_Emails',
];
RocketChat.statistics.get = function _getStatistics() {
statistics.get = function _getStatistics() {
const statistics = {};
// Setup Wizard
statistics.wizard = {};
wizardFields.forEach((field) => {
const record = RocketChat.models.Settings.findOne(field);
const record = Settings.findOne(field);
if (record) {
const wizardField = field.replace(/_/g, '').replace(field[0], field[0].toLowerCase());
statistics.wizard[wizardField] = record.value;
}
});
const firstUser = RocketChat.models.Users.getOldest({ name: 1, emails: 1 });
const firstUser = Users.getOldest({ name: 1, emails: 1 });
statistics.wizard.contactName = firstUser && firstUser.name;
statistics.wizard.contactEmail = firstUser && firstUser.emails && firstUser.emails[0].address;
if (RocketChat.settings.get('Organization_Email')) {
statistics.wizard.contactEmail = RocketChat.settings.get('Organization_Email');
if (settings.get('Organization_Email')) {
statistics.wizard.contactEmail = settings.get('Organization_Email');
}
// Version
statistics.uniqueId = RocketChat.settings.get('uniqueID');
if (RocketChat.models.Settings.findOne('uniqueID')) {
statistics.installedAt = RocketChat.models.Settings.findOne('uniqueID').createdAt;
statistics.uniqueId = settings.get('uniqueID');
if (Settings.findOne('uniqueID')) {
statistics.installedAt = Settings.findOne('uniqueID').createdAt;
}
if (RocketChat.Info) {
statistics.version = RocketChat.Info.version;
statistics.tag = RocketChat.Info.tag;
statistics.branch = RocketChat.Info.branch;
if (Info) {
statistics.version = Info.version;
statistics.tag = Info.tag;
statistics.branch = Info.branch;
}
// User statistics
@ -62,31 +65,31 @@ RocketChat.statistics.get = function _getStatistics() {
statistics.offlineUsers = statistics.totalUsers - statistics.onlineUsers - statistics.awayUsers;
// Room statistics
statistics.totalRooms = RocketChat.models.Rooms.find().count();
statistics.totalChannels = RocketChat.models.Rooms.findByType('c').count();
statistics.totalPrivateGroups = RocketChat.models.Rooms.findByType('p').count();
statistics.totalDirect = RocketChat.models.Rooms.findByType('d').count();
statistics.totalLivechat = RocketChat.models.Rooms.findByType('l').count();
statistics.totalRooms = Rooms.find().count();
statistics.totalChannels = Rooms.findByType('c').count();
statistics.totalPrivateGroups = Rooms.findByType('p').count();
statistics.totalDirect = Rooms.findByType('d').count();
statistics.totalLivechat = Rooms.findByType('l').count();
// livechat visitors
statistics.totalLivechatVisitors = LivechatVisitors.find().count();
// livechat agents
statistics.totalLivechatAgents = RocketChat.models.Users.findAgents().count();
statistics.totalLivechatAgents = Users.findAgents().count();
// livechat enabled
statistics.livechatEnabled = RocketChat.settings.get('Livechat_enabled');
statistics.livechatEnabled = settings.get('Livechat_enabled');
// Message statistics
statistics.totalMessages = RocketChat.models.Messages.find().count();
statistics.totalChannelMessages = _.reduce(RocketChat.models.Rooms.findByType('c', { fields: { msgs: 1 } }).fetch(), function _countChannelMessages(num, room) { return num + room.msgs; }, 0);
statistics.totalPrivateGroupMessages = _.reduce(RocketChat.models.Rooms.findByType('p', { fields: { msgs: 1 } }).fetch(), function _countPrivateGroupMessages(num, room) { return num + room.msgs; }, 0);
statistics.totalDirectMessages = _.reduce(RocketChat.models.Rooms.findByType('d', { fields: { msgs: 1 } }).fetch(), function _countDirectMessages(num, room) { return num + room.msgs; }, 0);
statistics.totalLivechatMessages = _.reduce(RocketChat.models.Rooms.findByType('l', { fields: { msgs: 1 } }).fetch(), function _countLivechatMessages(num, room) { return num + room.msgs; }, 0);
statistics.totalMessages = Messages.find().count();
statistics.totalChannelMessages = _.reduce(Rooms.findByType('c', { fields: { msgs: 1 } }).fetch(), function _countChannelMessages(num, room) { return num + room.msgs; }, 0);
statistics.totalPrivateGroupMessages = _.reduce(Rooms.findByType('p', { fields: { msgs: 1 } }).fetch(), function _countPrivateGroupMessages(num, room) { return num + room.msgs; }, 0);
statistics.totalDirectMessages = _.reduce(Rooms.findByType('d', { fields: { msgs: 1 } }).fetch(), function _countDirectMessages(num, room) { return num + room.msgs; }, 0);
statistics.totalLivechatMessages = _.reduce(Rooms.findByType('l', { fields: { msgs: 1 } }).fetch(), function _countLivechatMessages(num, room) { return num + room.msgs; }, 0);
statistics.lastLogin = RocketChat.models.Users.getLastLogin();
statistics.lastMessageSentAt = RocketChat.models.Messages.getLastTimestamp();
statistics.lastSeenSubscription = RocketChat.models.Subscriptions.getLastSeen();
statistics.lastLogin = Users.getLastLogin();
statistics.lastMessageSentAt = Messages.getLastTimestamp();
statistics.lastSeenSubscription = Subscriptions.getLastSeen();
statistics.os = {
type: os.type(),
@ -111,16 +114,16 @@ RocketChat.statistics.get = function _getStatistics() {
platform: process.env.DEPLOY_PLATFORM || 'selfinstall',
};
statistics.uploadsTotal = RocketChat.models.Uploads.find().count();
const [result] = Promise.await(RocketChat.models.Uploads.model.rawCollection().aggregate([{ $group: { _id: 'total', total: { $sum: '$size' } } }]).toArray());
statistics.uploadsTotal = Uploads.find().count();
const [result] = Promise.await(Uploads.model.rawCollection().aggregate([{ $group: { _id: 'total', total: { $sum: '$size' } } }]).toArray());
statistics.uploadsTotalSize = result ? result.total : 0;
statistics.migration = RocketChat.Migrations._getControl();
statistics.migration = Migrations._getControl();
statistics.instanceCount = InstanceStatus.getCollection().find({ _updatedAt: { $gt: new Date(Date.now() - process.uptime() * 1000 - 2000) } }).count();
const { mongo } = MongoInternals.defaultRemoteCollectionDriver();
if (mongo._oplogHandle && mongo._oplogHandle.onOplogEntry && RocketChat.settings.get('Force_Disable_OpLog_For_Cache') !== true) {
if (mongo._oplogHandle && mongo._oplogHandle.onOplogEntry && settings.get('Force_Disable_OpLog_For_Cache') !== true) {
statistics.oplogEnabled = true;
}

@ -1,8 +1,9 @@
import { RocketChat } from 'meteor/rocketchat:lib';
import { Statistics } from 'meteor/rocketchat:models';
import { statistics } from '../../lib/rocketchat';
RocketChat.statistics.save = function() {
const statistics = RocketChat.statistics.get();
statistics.createdAt = new Date;
RocketChat.models.Statistics.insert(statistics);
return statistics;
statistics.save = function() {
const rcStatistics = statistics.get();
rcStatistics.createdAt = new Date;
Statistics.insert(rcStatistics);
return rcStatistics;
};

@ -1,5 +1,4 @@
import '../lib/rocketchat';
import './models/import';
export { statistics } from '../lib/rocketchat';
import './functions/get';
import './functions/save';
import './methods/getStatistics';

@ -1,5 +1,7 @@
import { Meteor } from 'meteor/meteor';
import { RocketChat } from 'meteor/rocketchat:lib';
import { hasPermission } from 'meteor/rocketchat:authorization';
import { Statistics } from 'meteor/rocketchat:models';
import { statistics } from '../../lib/rocketchat';
Meteor.methods({
getStatistics(refresh) {
@ -7,14 +9,14 @@ Meteor.methods({
throw new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'getStatistics' });
}
if (RocketChat.authz.hasPermission(Meteor.userId(), 'view-statistics') !== true) {
if (hasPermission(Meteor.userId(), 'view-statistics') !== true) {
throw new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'getStatistics' });
}
if (refresh) {
return RocketChat.statistics.save();
return statistics.save();
} else {
return RocketChat.models.Statistics.findLast();
return Statistics.findLast();
}
},
});

@ -1,4 +0,0 @@
import { RocketChat } from 'meteor/rocketchat:lib';
import { Statistics } from 'meteor/rocketchat:models';
RocketChat.models.Statistics = Statistics;

@ -1,6 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { RoomTypeConfig } from 'meteor/rocketchat:lib';
import { RocketChat } from 'meteor/rocketchat:lib';
import { roomTypes, RoomTypeConfig } from 'meteor/rocketchat:utils';
class TokenPassRoomType extends RoomTypeConfig {
constructor() {
@ -20,4 +19,4 @@ class TokenPassRoomType extends RoomTypeConfig {
}
}
RocketChat.roomTypes.add(new TokenPassRoomType());
roomTypes.add(new TokenPassRoomType());

@ -1,14 +1,15 @@
import { Meteor } from 'meteor/meteor';
import { RocketChat } from 'meteor/rocketchat:lib';
import { ChannelSettings } from 'meteor/rocketchat:channel-settings';
import { Rooms } from 'meteor/rocketchat:models';
Meteor.startup(function() {
RocketChat.ChannelSettings.addOption({
ChannelSettings.addOption({
group: ['room'],
id: 'tokenpass',
template: 'channelSettings__tokenpass',
validation(data) {
if (data && data.rid) {
const room = RocketChat.models.Rooms.findOne(data.rid, { fields: { tokenpass: 1 } });
const room = Rooms.findOne(data.rid, { fields: { tokenpass: 1 } });
return room && room.tokenpass;
}

@ -2,11 +2,11 @@ import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';
import { Tracker } from 'meteor/tracker';
import { Template } from 'meteor/templating';
import { RocketChat } from 'meteor/rocketchat:lib';
import { Subscriptions } from 'meteor/rocketchat:models';
Template.tokenChannelsList.helpers({
rooms() {
return Template.instance().tokenpassRooms.get().filter((room) => RocketChat.models.Subscriptions.find({ rid: room._id }).count() === 0);
return Template.instance().tokenpassRooms.get().filter((room) => Subscriptions.find({ rid: room._id }).count() === 0);
},
});

@ -2,9 +2,8 @@ import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';
import { Template } from 'meteor/templating';
import { TAPi18n } from 'meteor/tap:i18n';
import { handleError } from 'meteor/rocketchat:lib';
import { ChatRoom } from 'meteor/rocketchat:ui';
import { t } from 'meteor/rocketchat:utils';
import { t, handleError } from 'meteor/rocketchat:utils';
import { ChatRoom } from 'meteor/rocketchat:ui-utils';
import toastr from 'toastr';
Template.channelSettings__tokenpass.helpers({

@ -1,6 +1,6 @@
import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';
import { RocketChat } from 'meteor/rocketchat:lib';
import { settings } from 'meteor/rocketchat:settings';
import { CustomOAuth } from 'meteor/rocketchat:custom-oauth';
const config = {
@ -22,7 +22,7 @@ const Tokenpass = new CustomOAuth('tokenpass', config);
if (Meteor.isServer) {
Meteor.startup(function() {
RocketChat.settings.get('API_Tokenpass_URL', function(key, value) {
settings.get('API_Tokenpass_URL', function(key, value) {
config.serverURL = value;
Tokenpass.configure(config);
});
@ -30,8 +30,8 @@ if (Meteor.isServer) {
} else {
Meteor.startup(function() {
Tracker.autorun(function() {
if (RocketChat.settings.get('API_Tokenpass_URL')) {
config.serverURL = RocketChat.settings.get('API_Tokenpass_URL');
if (settings.get('API_Tokenpass_URL')) {
config.serverURL = settings.get('API_Tokenpass_URL');
Tokenpass.configure(config);
}
});

@ -13,7 +13,10 @@ Package.onUse(function(api) {
'templating',
'littledata:synced-cron',
'rocketchat:utils',
'rocketchat:lib',
'rocketchat:ui-utils',
'rocketchat:models',
'rocketchat:settings',
'rocketchat:callbacks',
'rocketchat:authorization',
'rocketchat:custom-oauth',
'rocketchat:channel-settings',

@ -1,6 +1,4 @@
import { RocketChat } from 'meteor/rocketchat:lib';
RocketChat.Tokenpass = {
export const Tokenpass = {
validateAccess(tokenpass, balances) {
const compFunc = tokenpass.require === 'any' ? 'some' : 'every';
return tokenpass.tokens[compFunc]((config) => balances.some((userToken) => config.token === userToken.asset && parseFloat(config.balance) <= parseFloat(userToken.balance)));

@ -1,17 +1,20 @@
import { Meteor } from 'meteor/meteor';
import { RocketChat } from 'meteor/rocketchat:lib';
import { Rooms, Subscriptions, Users } from 'meteor/rocketchat:models';
import { SyncedCron } from 'meteor/littledata:synced-cron';
import { updateUserTokenpassBalances } from './functions/updateUserTokenpassBalances';
import { Tokenpass } from './Tokenpass';
function removeUsersFromTokenChannels() {
async function removeUsersFromTokenChannels() {
const rooms = {};
const { removeUserFromRoom } = await import('meteor/rocketchat:lib');
RocketChat.models.Rooms.findAllTokenChannels().forEach((room) => {
Rooms.findAllTokenChannels().forEach((room) => {
rooms[room._id] = room.tokenpass;
});
const users = {};
RocketChat.models.Subscriptions.findByRoomIds(Object.keys(rooms)).forEach((sub) => {
Subscriptions.findByRoomIds(Object.keys(rooms)).forEach((sub) => {
if (!users[sub.u._id]) {
users[sub.u._id] = [];
}
@ -19,16 +22,16 @@ function removeUsersFromTokenChannels() {
});
Object.keys(users).forEach((user) => {
const userInfo = RocketChat.models.Users.findOneById(user);
const userInfo = Users.findOneById(user);
if (userInfo && userInfo.services && userInfo.services.tokenpass) {
const balances = RocketChat.updateUserTokenpassBalances(userInfo);
const balances = updateUserTokenpassBalances(userInfo);
users[user].forEach((roomId) => {
const valid = RocketChat.Tokenpass.validateAccess(rooms[roomId], balances);
const valid = Tokenpass.validateAccess(rooms[roomId], balances);
if (!valid) {
RocketChat.removeUserFromRoom(roomId, userInfo);
removeUserFromRoom(roomId, userInfo);
}
});
}
@ -36,8 +39,8 @@ function removeUsersFromTokenChannels() {
}
Meteor.startup(function() {
Meteor.defer(function() {
removeUsersFromTokenChannels();
Meteor.defer(async function() {
await removeUsersFromTokenChannels();
SyncedCron.add({
name: 'Remove users from Token Channels',

@ -1,14 +1,14 @@
import { Meteor } from 'meteor/meteor';
import { HTTP } from 'meteor/http';
import { RocketChat } from 'meteor/rocketchat:lib';
import { settings } from 'meteor/rocketchat:settings';
let userAgent = 'Meteor';
if (Meteor.release) { userAgent += `/${ Meteor.release }`; }
RocketChat.getProtectedTokenpassBalances = function(accessToken) {
export const getProtectedTokenpassBalances = function(accessToken) {
try {
return HTTP.get(
`${ RocketChat.settings.get('API_Tokenpass_URL') }/api/v1/tca/protected/balances`, {
`${ settings.get('API_Tokenpass_URL') }/api/v1/tca/protected/balances`, {
headers: {
Accept: 'application/json',
'User-Agent': userAgent,

@ -1,14 +1,14 @@
import { Meteor } from 'meteor/meteor';
import { HTTP } from 'meteor/http';
import { RocketChat } from 'meteor/rocketchat:lib';
import { settings } from 'meteor/rocketchat:settings';
let userAgent = 'Meteor';
if (Meteor.release) { userAgent += `/${ Meteor.release }`; }
RocketChat.getPublicTokenpassBalances = function(accessToken) {
export const getPublicTokenpassBalances = function(accessToken) {
try {
return HTTP.get(
`${ RocketChat.settings.get('API_Tokenpass_URL') }/api/v1/tca/public/balances`, {
`${ settings.get('API_Tokenpass_URL') }/api/v1/tca/public/balances`, {
headers: {
Accept: 'application/json',
'User-Agent': userAgent,

@ -1,9 +1,9 @@
import { Meteor } from 'meteor/meteor';
import { Match } from 'meteor/check';
import { RocketChat } from 'meteor/rocketchat:lib';
import { Rooms } from 'meteor/rocketchat:models';
import s from 'underscore.string';
RocketChat.saveRoomTokensMinimumBalance = function(rid, roomTokensMinimumBalance) {
export const saveRoomTokensMinimumBalance = function(rid, roomTokensMinimumBalance) {
if (!Match.test(rid, String)) {
throw new Meteor.Error('invalid-room', 'Invalid room', {
function: 'RocketChat.saveRoomTokensMinimumBalance',
@ -12,5 +12,5 @@ RocketChat.saveRoomTokensMinimumBalance = function(rid, roomTokensMinimumBalance
const minimumTokenBalance = parseFloat(s.escapeHTML(roomTokensMinimumBalance));
return RocketChat.models.Rooms.setMinimumTokenBalanceById(rid, minimumTokenBalance);
return Rooms.setMinimumTokenBalanceById(rid, minimumTokenBalance);
};

@ -1,14 +1,16 @@
import { RocketChat } from 'meteor/rocketchat:lib';
import { Users } from 'meteor/rocketchat:models';
import { getPublicTokenpassBalances } from './getPublicTokenpassBalances';
import { getProtectedTokenpassBalances } from './getProtectedTokenpassBalances';
import _ from 'underscore';
RocketChat.updateUserTokenpassBalances = function(user) {
export const updateUserTokenpassBalances = function(user) {
if (user && user.services && user.services.tokenpass) {
const tcaPublicBalances = RocketChat.getPublicTokenpassBalances(user.services.tokenpass.accessToken);
const tcaProtectedBalances = RocketChat.getProtectedTokenpassBalances(user.services.tokenpass.accessToken);
const tcaPublicBalances = getPublicTokenpassBalances(user.services.tokenpass.accessToken);
const tcaProtectedBalances = getProtectedTokenpassBalances(user.services.tokenpass.accessToken);
const balances = _.uniq(_.union(tcaPublicBalances, tcaProtectedBalances), false, (item) => item.asset);
RocketChat.models.Users.setTokenpassTcaBalances(user._id, balances);
Users.setTokenpassTcaBalances(user._id, balances);
return balances;
}

@ -3,12 +3,8 @@ import './startup';
import './functions/getProtectedTokenpassBalances';
import './functions/getPublicTokenpassBalances';
import './functions/saveRoomTokensMinimumBalance';
import './functions/updateUserTokenpassBalances';
import './models/indexes';
import './models/Rooms';
import './models/Subscriptions';
import './models/Users';
export { updateUserTokenpassBalances } from './functions/updateUserTokenpassBalances';
import './methods/findTokenChannels';
import './methods/getChannelTokenpass';
import './cronRemoveUsers';
import './Tokenpass';
export { Tokenpass } from './Tokenpass';

@ -1,5 +1,6 @@
import { Meteor } from 'meteor/meteor';
import { RocketChat } from 'meteor/rocketchat:lib';
import { Rooms } from 'meteor/rocketchat:models';
import { Tokenpass } from '../Tokenpass';
Meteor.methods({
findTokenChannels() {
@ -15,8 +16,8 @@ Meteor.methods({
tokens[token.asset] = 1;
});
return RocketChat.models.Rooms.findByTokenpass(Object.keys(tokens))
.filter((room) => RocketChat.Tokenpass.validateAccess(room.tokenpass, user.services.tokenpass.tcaBalances));
return Rooms.findByTokenpass(Object.keys(tokens))
.filter((room) => Tokenpass.validateAccess(room.tokenpass, user.services.tokenpass.tcaBalances));
}
return [];

@ -1,6 +1,6 @@
import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import { RocketChat } from 'meteor/rocketchat:lib';
import { Rooms } from 'meteor/rocketchat:models';
Meteor.methods({
getChannelTokenpass(rid) {
@ -10,7 +10,7 @@ Meteor.methods({
throw new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'getChannelTokenpass' });
}
const room = RocketChat.models.Rooms.findOneById(rid);
const room = Rooms.findOneById(rid);
if (!room) {
throw new Meteor.Error('error-invalid-room', 'Invalid room', { method: 'getChannelTokenpass' });

@ -1,33 +0,0 @@
import { RocketChat } from 'meteor/rocketchat:lib';
RocketChat.models.Rooms.findByTokenpass = function(tokens) {
const query = {
'tokenpass.tokens.token': {
$in: tokens,
},
};
return this._db.find(query).fetch();
};
RocketChat.models.Rooms.setTokensById = function(_id, tokens) {
const update = {
$set: {
'tokenpass.tokens.token': tokens,
},
};
return this.update({ _id }, update);
};
RocketChat.models.Rooms.findAllTokenChannels = function() {
const query = {
tokenpass: { $exists: true },
};
const options = {
fields: {
tokenpass: 1,
},
};
return this._db.find(query, options);
};

@ -1,17 +0,0 @@
import { RocketChat } from 'meteor/rocketchat:lib';
RocketChat.models.Subscriptions.findByRoomIds = function(roomIds) {
const query = {
rid: {
$in: roomIds,
},
};
const options = {
fields: {
'u._id': 1,
rid: 1,
},
};
return this._db.find(query, options);
};

@ -1,25 +0,0 @@
import { RocketChat } from 'meteor/rocketchat:lib';
RocketChat.models.Users.setTokenpassTcaBalances = function(_id, tcaBalances) {
const update = {
$set: {
'services.tokenpass.tcaBalances': tcaBalances,
},
};
return this.update(_id, update);
};
RocketChat.models.Users.getTokenBalancesByUserId = function(userId) {
const query = {
_id: userId,
};
const options = {
fields: {
'services.tokenpass.tcaBalances': 1,
},
};
return this.findOne(query, options);
};

@ -1,6 +0,0 @@
import { Meteor } from 'meteor/meteor';
import { RocketChat } from 'meteor/rocketchat:lib';
Meteor.startup(function() {
RocketChat.models.Rooms.tryEnsureIndex({ 'tokenpass.tokens.token': 1 });
});

@ -1,8 +1,13 @@
import { Meteor } from 'meteor/meteor';
import { Accounts } from 'meteor/accounts-base';
import { RocketChat } from 'meteor/rocketchat:lib';
RocketChat.settings.addGroup('OAuth', function() {
import { settings } from 'meteor/rocketchat:settings';
import { addRoomAccessValidator } from 'meteor/rocketchat:authorization';
import { Users } from 'meteor/rocketchat:models';
import { callbacks } from 'meteor/rocketchat:callbacks';
import { updateUserTokenpassBalances } from './functions/updateUserTokenpassBalances';
import { Tokenpass } from './Tokenpass';
settings.addGroup('OAuth', function() {
this.section('Tokenpass', function() {
const enableQuery = {
_id: 'Accounts_OAuth_Tokenpass',
@ -22,21 +27,21 @@ function validateTokenAccess(userData, roomData) {
return false;
}
return RocketChat.Tokenpass.validateAccess(roomData.tokenpass, userData.services.tokenpass.tcaBalances);
return Tokenpass.validateAccess(roomData.tokenpass, userData.services.tokenpass.tcaBalances);
}
Meteor.startup(function() {
RocketChat.authz.addRoomAccessValidator(function(room, user) {
addRoomAccessValidator(function(room, user) {
if (!room || !room.tokenpass || !user) {
return false;
}
const userData = RocketChat.models.Users.getTokenBalancesByUserId(user._id);
const userData = Users.getTokenBalancesByUserId(user._id);
return validateTokenAccess(userData, room);
});
RocketChat.callbacks.add('beforeJoinRoom', function(user, room) {
callbacks.add('beforeJoinRoom', function(user, room) {
if (room.tokenpass && !validateTokenAccess(user, room)) {
throw new Meteor.Error('error-not-allowed', 'Token required', { method: 'joinRoom' });
}
@ -47,6 +52,6 @@ Meteor.startup(function() {
Accounts.onLogin(function({ user }) {
if (user && user.services && user.services.tokenpass) {
RocketChat.updateUserTokenpassBalances(user);
updateUserTokenpassBalances(user);
}
});

@ -3,6 +3,7 @@ import { HTTP } from 'meteor/http';
import { Logger } from 'meteor/rocketchat:logger';
import { getWorkspaceAccessToken } from 'meteor/rocketchat:cloud';
import { SyncedCron } from 'meteor/littledata:synced-cron';
import { statistics } from 'meteor/rocketchat:statistics';
const logger = new Logger('SyncedCron');
@ -14,9 +15,9 @@ SyncedCron.config({
});
function generateStatistics() {
const statistics = RocketChat.statistics.save();
const cronStatistics = statistics.save();
statistics.host = Meteor.absoluteUrl();
cronStatistics.host = Meteor.absoluteUrl();
if (RocketChat.settings.get('Statistics_reporting')) {
try {
@ -28,7 +29,7 @@ function generateStatistics() {
}
HTTP.post('https://collector.rocket.chat/', {
data: statistics,
data: cronStatistics,
headers,
});
} catch (error) {

@ -1,3 +1,5 @@
import { Statistics } from 'meteor/rocketchat:models';
RocketChat.Migrations.add({
version: 59,
up() {
@ -5,7 +7,7 @@ RocketChat.Migrations.add({
if (users && users.length > 0) {
const { createdAt } = users[0];
RocketChat.models.Settings.update({ createdAt: { $exists: 0 } }, { $set: { createdAt } }, { multi: true });
RocketChat.models.Statistics.update({ installedAt: { $exists: 0 } }, { $set: { installedAt: createdAt } }, { multi: true });
Statistics.update({ installedAt: { $exists: 0 } }, { $set: { installedAt: createdAt } }, { multi: true });
}
},
});

Loading…
Cancel
Save