chore!: remove banners.getnew deprecated method (#36821)

This commit is contained in:
Martin Schoeler 2025-08-28 18:04:15 -03:00 committed by Guilherme Gazzo
parent 4b1c9aec1f
commit 476a070b00
4 changed files with 7 additions and 165 deletions

View File

@ -0,0 +1,6 @@
---
"@rocket.chat/meteor": major
"@rocket.chat/rest-typings": major
---
Removes `/api/v1/banners.getnew` deprecated endpoint

View File

@ -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}:

View File

@ -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

View File

@ -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;
};
@ -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[];