Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ggazzo committed May 23, 2023
1 parent 6860ec0 commit 95957fb
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 19 deletions.
2 changes: 1 addition & 1 deletion apps/meteor/app/api/server/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ export class APIClass<TBasePath extends string = ''> extends Restivus {

try {
if (options.deprecationVersion) {
apiDeprecationLogger.endpoint(this.request.url, options.deprecationVersion, this.response);
apiDeprecationLogger.endpoint(this.request.route, options.deprecationVersion, this.response);
}

await api.enforceRateLimit(objectForRateLimitMatch, this.request, this.response, this.userId);
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/app/api/server/helpers/parseJsonQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export async function parseJsonQuery(

let fields: Record<string, 0 | 1> | undefined;
if (params.fields) {
apiDeprecationLogger.parameter(this.request.url, 'fields', '7.0.0', this.response);
apiDeprecationLogger.parameter(this.request.route, 'fields', '7.0.0', this.response);
try {
fields = JSON.parse(params.fields) as Record<string, 0 | 1>;

Expand Down Expand Up @@ -103,7 +103,7 @@ export async function parseJsonQuery(

let query: Record<string, any> = {};
if (params.query) {
apiDeprecationLogger.parameter(this.request.url, 'query', '7.0.0', this.response);
apiDeprecationLogger.parameter(this.request.route, 'query', '7.0.0', this.response);

try {
query = ejson.parse(params.query);
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/api/server/v1/oauthapps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ API.v1.addRoute(
}

if ('appId' in this.queryParams) {
apiDeprecationLogger.parameter(this.request.url, 'appId', '6.0.0', this.response);
apiDeprecationLogger.parameter(this.request.route, 'appId', '6.0.0', this.response);
}

return API.v1.success({
Expand Down
6 changes: 3 additions & 3 deletions apps/meteor/app/api/server/v1/roles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ API.v1.addRoute(
return API.v1.failure('error-invalid-role-properties');
}

apiDeprecationLogger.parameter(this.request.url, 'roleName', '6.0.0', this.response);
apiDeprecationLogger.parameter(this.request.route, 'roleName', '6.0.0', this.response);
}

const role = roleId ? await Roles.findOneById(roleId) : await Roles.findOneByIdOrName(roleName as string);
Expand Down Expand Up @@ -124,7 +124,7 @@ API.v1.addRoute(
}

apiDeprecationLogger.deprecatedParameterUsage(
this.request.url,
this.request.route,
'role',
'6.0.0',
this.response,
Expand Down Expand Up @@ -205,7 +205,7 @@ API.v1.addRoute(
return API.v1.failure('error-invalid-role-properties');
}

apiDeprecationLogger.parameter(this.request.url, 'roleName', '6.0.0', this.response);
apiDeprecationLogger.parameter(this.request.route, 'roleName', '6.0.0', this.response);
}

const user = await Users.findOneByUsername(username);
Expand Down
8 changes: 4 additions & 4 deletions apps/meteor/app/lib/server/lib/deprecationWarningLogger.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Response } from 'meteor/rocketchat:restivus';
import semver from 'semver';
import type { Response } from 'express';

import { Logger } from '../../../logger/server';

Expand All @@ -11,9 +11,9 @@ const throwErrorsForVersionsUnder = process.env.ROCKET_CHAT_DEPRECATION_THROW_ER

const writeDeprecationHeader = (res: Response | undefined, type: string, message: string, version: string) => {
if (res) {
res.header('x-deprecation-type', type);
res.header('x-deprecation-message', message);
res.header('x-deprecation-version', version);
res.setHeader('x-deprecation-type', type);
res.setHeader('x-deprecation-message', message);
res.setHeader('x-deprecation-version', version);
}
};

Expand Down
2 changes: 0 additions & 2 deletions apps/meteor/app/livechat/server/api/v1/room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,6 @@ API.v1.addRoute(
{ validateParams: isPOSTLivechatRoomTransferParams, deprecationVersion: '6.0.0' },
{
async post() {
apiDeprecationLogger.endpoint(this.request.url, '6.0.0', this.response);

const { rid, token, department } = this.bodyParams;

const guest = await findGuest(token);
Expand Down
3 changes: 1 addition & 2 deletions apps/meteor/app/livechat/server/methods/webhookTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ declare module '@rocket.chat/ui-contexts' {

Meteor.methods<ServerMethods>({
async 'livechat:webhookTest'() {
methodDeprecationLogger.info(`Method 'livechat:webhookTest' is deprecated and will be removed in future versions of Rocket.Chat`);
this.unblock();
methodDeprecationLogger.method('livechat:webhookTest', '6.0.0');

const sampleData = {
type: 'LivechatSession',
Expand Down
8 changes: 4 additions & 4 deletions apps/meteor/ee/server/apps/communication/rest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ export class AppsRestApi {

// Gets the Apps from the marketplace
if ('marketplace' in this.queryParams && this.queryParams.marketplace) {
apiDeprecationLogger.endpoint(this.request.url, '6.0.0', this.response, 'Use /apps/marketplace to get the apps list.');
apiDeprecationLogger.endpoint(this.request.route, '6.0.0', this.response, 'Use /apps/marketplace to get the apps list.');

const headers = getDefaultHeaders();
const token = await getWorkspaceAccessToken();
Expand All @@ -247,7 +247,7 @@ export class AppsRestApi {
}

if ('categories' in this.queryParams && this.queryParams.categories) {
apiDeprecationLogger.endpoint(this.request.url, '6.0.0', this.response, 'Use /apps/categories to get the categories list.');
apiDeprecationLogger.endpoint(this.request.route, '6.0.0', this.response, 'Use /apps/categories to get the categories list.');
const headers = getDefaultHeaders();
const token = await getWorkspaceAccessToken();
if (token) {
Expand Down Expand Up @@ -276,7 +276,7 @@ export class AppsRestApi {
this.queryParams.buildExternalUrl &&
this.queryParams.appId
) {
apiDeprecationLogger.endpoint(this.request.url, '6.0.0', this.response, 'Use /apps/buildExternalUrl to get the modal URLs.');
apiDeprecationLogger.endpoint(this.request.route, '6.0.0', this.response, 'Use /apps/buildExternalUrl to get the modal URLs.');
const workspaceId = settings.get('Cloud_Workspace_Id');

if (!this.queryParams.purchaseType || !purchaseTypes.has(this.queryParams.purchaseType)) {
Expand All @@ -298,7 +298,7 @@ export class AppsRestApi {
}?workspaceId=${workspaceId}&token=${token.token}&seats=${seats}`,
});
}
apiDeprecationLogger.endpoint(this.request.url, '6.0.0', this.response, 'Use /apps/installed to get the installed apps list.');
apiDeprecationLogger.endpoint(this.request.route, '6.0.0', this.response, 'Use /apps/installed to get the installed apps list.');

const apps = manager.get().map(formatAppInstanceForRest);

Expand Down

0 comments on commit 95957fb

Please sign in to comment.