Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/quick-turtles-count.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@rocket.chat/meteor": major
"@rocket.chat/rest-typings": major
---

Removes `/api/v1/banners.getnew` deprecated endpoint
67 changes: 1 addition & 66 deletions apps/meteor/app/api/server/v1/banners.ts
Original file line number Diff line number Diff line change
@@ -1,73 +1,8 @@
import { Banner } from '@rocket.chat/core-services';
import { isBannersDismissProps, isBannersGetNewProps, isBannersProps } from '@rocket.chat/rest-typings';
import { isBannersDismissProps, isBannersProps } from '@rocket.chat/rest-typings';

import { API } from '../api';

/**
* @deprecated
* @openapi
* /api/v1/banners.getNew:
* get:
* description: Gets the banners to be shown to the authenticated user
* deprecated: true
* security:
* $ref: '#/security/authenticated'
* parameters:
* - name: platform
* in: query
* description: The platform rendering the banner
* required: true
* schema:
* type: string
* enum: [web, mobile]
* example: web
* - name: bid
* in: query
* description: The id of a single banner
* required: false
* schema:
* type: string
* example: ByehQjC44FwMeiLbX
* responses:
* 200:
* description: The banners matching the criteria
* content:
* application/json:
* schema:
* allOf:
* - $ref: '#/components/schemas/ApiSuccessV1'
* - type: object
* properties:
* banners:
* type: array
* items:
* $ref: '#/components/schemas/IBanner'
* default:
* description: Unexpected error
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/ApiFailureV1'
*/
API.v1.addRoute(
'banners.getNew',
{
authRequired: true,
validateParams: isBannersGetNewProps,
deprecation: { version: '8.0.0', alternatives: ['/v1/banners/:id', '/v1/banners'] },
},
{
// deprecated
async get() {
const { platform, bid: bannerId } = this.queryParams;

const banners = await Banner.getBannersForUser(this.userId, platform, bannerId ?? undefined);

return API.v1.success({ banners });
},
},
);

/**
* @openapi
* /api/v1/banners/{id}:
Expand Down
70 changes: 0 additions & 70 deletions apps/meteor/tests/end-to-end/api/banners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,76 +6,6 @@ import { getCredentials, api, request, credentials } from '../../data/api-data';
describe('banners', () => {
before((done) => getCredentials(done));

describe('[/banners.getNew]', () => {
it('should fail if not logged in', (done) => {
void request
.get(api('banners.getNew'))
.query({
platform: 'web',
})
.expect(401)
.expect((res) => {
expect(res.body).to.have.property('status', 'error');
expect(res.body).to.have.property('message');
})
.end(done);
});

it('should fail if missing platform key', (done) => {
void request
.get(api('banners.getNew'))
.set(credentials)
.expect(400)
.expect((res) => {
expect(res.body).to.have.property('success', false);
})
.end(done);
});

it('should fail if platform param is unknown', (done) => {
void request
.get(api('banners.getNew'))
.set(credentials)
.query({
platform: 'unknownPlatform',
})
.expect(400)
.expect((res) => {
expect(res.body).to.have.property('success', false);
})
.end(done);
});

it('should fail if platform param is empty', (done) => {
void request
.get(api('banners.getNew'))
.set(credentials)
.query({
platform: '',
})
.expect(400)
.expect((res) => {
expect(res.body).to.have.property('success', false);
})
.end(done);
});

it('should return banners if platform param is valid', (done) => {
void request
.get(api('banners.getNew'))
.set(credentials)
.query({
platform: 'web',
})
.expect(200)
.expect((res) => {
expect(res.body).to.have.property('success', true);
expect(res.body).to.have.property('banners').and.to.be.an('array');
})
.end(done);
});
});

describe('[/banners.dismiss]', () => {
it('should fail if not logged in', (done) => {
void request
Expand Down
29 changes: 0 additions & 29 deletions packages/rest-typings/src/v1/banners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,6 @@ const ajv = new Ajv({
coerceTypes: true,
});

type BannersGetNew = {
platform: BannerPlatform;
bid: IBanner['_id'];
};

const BannersGetNewSchema = {
type: 'object',
properties: {
platform: {
type: 'string',
enum: ['web', 'mobile'],
},
bid: {
type: 'string',
},
},
required: ['platform'],
additionalProperties: false,
};

export const isBannersGetNewProps = ajv.compile<BannersGetNew>(BannersGetNewSchema);

type BannersId = {
platform: BannerPlatform;
};
Expand Down Expand Up @@ -68,13 +46,6 @@ const BannersDismissSchema = {
export const isBannersDismissProps = ajv.compile<BannersDismiss>(BannersDismissSchema);

export type BannersEndpoints = {
/* @deprecated */
'/v1/banners.getNew': {
GET: (params: BannersGetNew) => {
banners: IBanner[];
};
};

'/v1/banners/:id': {
GET: (params: BannersId) => {
banners: IBanner[];
Expand Down
Loading