From b98b99e7a29a2673bbdd9cbeb8f448e3c053072d Mon Sep 17 00:00:00 2001 From: Guilherme Gazzo Date: Fri, 20 Oct 2023 21:04:37 -0300 Subject: [PATCH 1/3] feat: make sure every preventActions contains a value (#30708) --- ee/packages/license/src/license.ts | 44 ++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/ee/packages/license/src/license.ts b/ee/packages/license/src/license.ts index e8be1df85eac..fb290d541cfb 100644 --- a/ee/packages/license/src/license.ts +++ b/ee/packages/license/src/license.ts @@ -27,6 +27,7 @@ import { isBehaviorsInResult } from './validation/isBehaviorsInResult'; import { isReadyForValidation } from './validation/isReadyForValidation'; import { runValidation } from './validation/runValidation'; import { validateFormat } from './validation/validateFormat'; +import { validateLicenseLimits } from './validation/validateLicenseLimits'; const globalLimitKinds: LicenseLimitKind[] = ['activeUsers', 'guestUsers', 'privateApps', 'marketplaceApps', 'monthlyActiveContacts']; @@ -303,12 +304,43 @@ export class LicenseManager extends Emitter { } } - public get shouldPreventActionResultsMap(): { + public async shouldPreventActionResultsMap(): Promise<{ [key in LicenseLimitKind]: boolean; - } { - return Object.fromEntries(this.shouldPreventActionResults.entries()) as { - [key in LicenseLimitKind]: boolean; - }; + }> { + const keys: LicenseLimitKind[] = [ + 'activeUsers', + 'guestUsers', + 'roomsPerGuest', + 'privateApps', + 'marketplaceApps', + 'monthlyActiveContacts', + ]; + + const items = await Promise.all( + keys.map(async (limit) => { + const cached = this.shouldPreventActionResults.get(limit as LicenseLimitKind); + + if (cached !== undefined) { + return [limit as LicenseLimitKind, cached]; + } + + const fresh = this._license + ? isBehaviorsInResult( + await validateLicenseLimits.call(this, this._license, { + behaviors: ['prevent_action'], + limits: [limit], + }), + ['prevent_action'], + ) + : false; + + this.shouldPreventActionResults.set(limit as LicenseLimitKind, fresh); + + return [limit as LicenseLimitKind, fresh]; + }), + ); + + return Object.fromEntries(items); } public async shouldPreventAction( @@ -408,7 +440,7 @@ export class LicenseManager extends Emitter { return { license: (includeLicense && license) || undefined, activeModules, - preventedActions: this.shouldPreventActionResultsMap, + preventedActions: await this.shouldPreventActionResultsMap(), limits: limits as Record, tags: license?.information.tags || [], trial: Boolean(license?.information.trial), From 47303b5232393a9e8b0e5b6130f0746788955b12 Mon Sep 17 00:00:00 2001 From: Allan RIbeiro <35040806+AllanPazRibeiro@users.noreply.github.com> Date: Mon, 23 Oct 2023 09:36:14 -0300 Subject: [PATCH 2/3] chore: just some portuguese translations (#30647) --- .changeset/lazy-shoes-teach.md | 5 +++++ apps/meteor/packages/rocketchat-i18n/i18n/pt-BR.i18n.json | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 .changeset/lazy-shoes-teach.md diff --git a/.changeset/lazy-shoes-teach.md b/.changeset/lazy-shoes-teach.md new file mode 100644 index 000000000000..7737f39cd671 --- /dev/null +++ b/.changeset/lazy-shoes-teach.md @@ -0,0 +1,5 @@ +--- +'@rocket.chat/meteor': minor +--- + +chore: adding some portugueses translations to the app details page diff --git a/apps/meteor/packages/rocketchat-i18n/i18n/pt-BR.i18n.json b/apps/meteor/packages/rocketchat-i18n/i18n/pt-BR.i18n.json index 8da04e7c4e67..9812ddc46db3 100644 --- a/apps/meteor/packages/rocketchat-i18n/i18n/pt-BR.i18n.json +++ b/apps/meteor/packages/rocketchat-i18n/i18n/pt-BR.i18n.json @@ -2833,6 +2833,7 @@ "Mark_read": "Marcar como Lido", "Mark_unread": "Marcar como não lido", "Marketplace": "Marketplace", + "Marketplace_app_last_updated": "Ultima atualização {{lastUpdated}}", "Marketplace_view_marketplace": "Ver Marketplace", "Marketplace_error": "Não é possível conectar à internet, ou seu espaço de trabalho pode ser uma instalação offline.", "MAU_value": "MAU {{value}}", @@ -3522,6 +3523,7 @@ "Regular_Expressions": "Expressões regulares", "Reject_call": "Rejeitar chamada", "Release": "Versão", + "Releases": "Versões", "Religious": "Religioso", "Reload": "Recarregar", "Reload_page": "Recarregar página", @@ -3575,6 +3577,10 @@ "Request_comment_when_closing_conversation": "Solicitar comentário ao encerrar a conversa", "Request_comment_when_closing_conversation_description": "Se ativado, o agente precisará informar um comentário antes que a conversa seja encerrada.", "Request_tag_before_closing_chat": "Solicitar tag(s) antes de encerrar a conversa", + "request": "solicitar", + "requests": "solicitações", + "Requests": "Solicitações", + "Requested": "Solicitado", "Requested_At": "Solicitado em", "Requested_By": "Solicitado por", "Require": "Exigir", @@ -4972,4 +4978,4 @@ "RegisterWorkspace_Features_Omnichannel_Title": "Omnichannel", "RegisterWorkspace_Setup_Label": "E-mail da conta da nuvem", "cloud.RegisterWorkspace_Setup_Terms_Privacy": "Eu concordo com os <1>Termos e condições e a <3>Política de privacidade" -} \ No newline at end of file +} From c4325e82a734c624650fcaedbff8d02058e6da25 Mon Sep 17 00:00:00 2001 From: Marcos Spessatto Defendi Date: Mon, 23 Oct 2023 09:40:37 -0300 Subject: [PATCH 3/3] feat: add statsToken to statistics and send it to the sync process (#30181) --- .../server/functions/buildRegistrationData.ts | 2 ++ .../app/statistics/server/lib/statistics.ts | 4 +++- apps/meteor/server/cron/statistics.ts | 18 +++++++++++++----- packages/core-typings/src/IStats.ts | 1 + 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/apps/meteor/app/cloud/server/functions/buildRegistrationData.ts b/apps/meteor/app/cloud/server/functions/buildRegistrationData.ts index c2bd91e82dd8..ea94db8d17a1 100644 --- a/apps/meteor/app/cloud/server/functions/buildRegistrationData.ts +++ b/apps/meteor/app/cloud/server/functions/buildRegistrationData.ts @@ -38,6 +38,7 @@ export type WorkspaceRegistrationData = { MAC: number; // activeContactsBillingMonth: number; // activeContactsYesterday: number; + statsToken?: string; }; export async function buildWorkspaceRegistrationData(contactEmail: T): Promise> { @@ -92,5 +93,6 @@ export async function buildWorkspaceRegistrationData { const rcStatistics = await statistics.get(); rcStatistics.createdAt = new Date(); - await Statistics.insertOne(rcStatistics); + const { insertedId } = await Statistics.insertOne(rcStatistics); + rcStatistics._id = insertedId; + return rcStatistics; }, }; diff --git a/apps/meteor/server/cron/statistics.ts b/apps/meteor/server/cron/statistics.ts index 7e7dea6adbc7..44dcb554824c 100644 --- a/apps/meteor/server/cron/statistics.ts +++ b/apps/meteor/server/cron/statistics.ts @@ -1,5 +1,6 @@ import { cronJobs } from '@rocket.chat/cron'; import type { Logger } from '@rocket.chat/logger'; +import { Statistics } from '@rocket.chat/models'; import { serverFetch as fetch } from '@rocket.chat/server-fetch'; import { Meteor } from 'meteor/meteor'; @@ -8,9 +9,7 @@ import { settings } from '../../app/settings/server'; import { statistics } from '../../app/statistics/server'; async function generateStatistics(logger: Logger): Promise { - const cronStatistics: Record = await statistics.save(); - - cronStatistics.host = Meteor.absoluteUrl(); + const cronStatistics = await statistics.save(); if (!settings.get('Statistics_reporting')) { return; @@ -20,11 +19,20 @@ async function generateStatistics(logger: Logger): Promise { const token = await getWorkspaceAccessToken(); const headers = { ...(token && { Authorization: `Bearer ${token}` }) }; - await fetch('https://collector.rocket.chat/', { + const response = await fetch('https://collector.rocket.chat/', { method: 'POST', - body: cronStatistics, + body: { + ...cronStatistics, + host: Meteor.absoluteUrl(), + }, headers, }); + + const { statsToken } = await response.json(); + + if (statsToken != null) { + await Statistics.updateOne({ _id: cronStatistics._id }, { $set: { statsToken } }); + } } catch (error) { /* error*/ logger.warn('Failed to send usage report'); diff --git a/packages/core-typings/src/IStats.ts b/packages/core-typings/src/IStats.ts index 7fd5cd8218bc..0df389f2dd86 100644 --- a/packages/core-typings/src/IStats.ts +++ b/packages/core-typings/src/IStats.ts @@ -227,4 +227,5 @@ export interface IStats { webRTCEnabled: boolean; webRTCEnabledForOmnichannel: boolean; omnichannelWebRTCCalls: number; + statsToken?: string; }