Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into feature/info-page-…
Browse files Browse the repository at this point in the history
…overview-cards
  • Loading branch information
hugocostadev committed Oct 23, 2023
2 parents 051e887 + c4325e8 commit 6ca2f66
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .changeset/lazy-shoes-teach.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': minor
---

chore: adding some portugueses translations to the app details page
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export type WorkspaceRegistrationData<T> = {
MAC: number;
// activeContactsBillingMonth: number;
// activeContactsYesterday: number;
statsToken?: string;
};

export async function buildWorkspaceRegistrationData<T extends string | undefined>(contactEmail: T): Promise<WorkspaceRegistrationData<T>> {
Expand Down Expand Up @@ -92,5 +93,6 @@ export async function buildWorkspaceRegistrationData<T extends string | undefine
MAC: stats.omnichannelContactsBySource?.contactsCount ?? 0,
// activeContactsBillingMonth: stats.omnichannelContactsBySource.contactsCount,
// activeContactsYesterday: stats.uniqueContactsOfYesterday.contactsCount,
statsToken: stats.statsToken,
};
}
4 changes: 3 additions & 1 deletion apps/meteor/app/statistics/server/lib/statistics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,9 @@ export const statistics = {
async save(): Promise<IStats> {
const rcStatistics = await statistics.get();
rcStatistics.createdAt = new Date();
await Statistics.insertOne(rcStatistics);
const { insertedId } = await Statistics.insertOne(rcStatistics);
rcStatistics._id = insertedId;

return rcStatistics;
},
};
8 changes: 7 additions & 1 deletion apps/meteor/packages/rocketchat-i18n/i18n/pt-BR.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -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}}",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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</1> e a <3>Política de privacidade</3>"
}
}
18 changes: 13 additions & 5 deletions apps/meteor/server/cron/statistics.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -8,9 +9,7 @@ import { settings } from '../../app/settings/server';
import { statistics } from '../../app/statistics/server';

async function generateStatistics(logger: Logger): Promise<void> {
const cronStatistics: Record<string, any> = await statistics.save();

cronStatistics.host = Meteor.absoluteUrl();
const cronStatistics = await statistics.save();

if (!settings.get('Statistics_reporting')) {
return;
Expand All @@ -20,11 +19,20 @@ async function generateStatistics(logger: Logger): Promise<void> {
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');
Expand Down
44 changes: 38 additions & 6 deletions ee/packages/license/src/license.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'];

Expand Down Expand Up @@ -303,12 +304,43 @@ export class LicenseManager extends Emitter<LicenseEvents> {
}
}

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<T extends LicenseLimitKind>(
Expand Down Expand Up @@ -408,7 +440,7 @@ export class LicenseManager extends Emitter<LicenseEvents> {
return {
license: (includeLicense && license) || undefined,
activeModules,
preventedActions: this.shouldPreventActionResultsMap,
preventedActions: await this.shouldPreventActionResultsMap(),
limits: limits as Record<LicenseLimitKind, { max: number; value: number }>,
tags: license?.information.tags || [],
trial: Boolean(license?.information.trial),
Expand Down
1 change: 1 addition & 0 deletions packages/core-typings/src/IStats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,4 +228,5 @@ export interface IStats {
webRTCEnabled: boolean;
webRTCEnabledForOmnichannel: boolean;
omnichannelWebRTCCalls: number;
statsToken?: string;
}

0 comments on commit 6ca2f66

Please sign in to comment.