mirror of
https://github.com/RocketChat/Rocket.Chat.git
synced 2025-12-28 06:47:25 +00:00
chore!: remove banners.getnew deprecated method (#36821)
This commit is contained in:
parent
4b1c9aec1f
commit
476a070b00
6
.changeset/quick-turtles-count.md
Normal file
6
.changeset/quick-turtles-count.md
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
"@rocket.chat/meteor": major
|
||||||
|
"@rocket.chat/rest-typings": major
|
||||||
|
---
|
||||||
|
|
||||||
|
Removes `/api/v1/banners.getnew` deprecated endpoint
|
||||||
@ -1,73 +1,8 @@
|
|||||||
import { Banner } from '@rocket.chat/core-services';
|
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';
|
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
|
* @openapi
|
||||||
* /api/v1/banners/{id}:
|
* /api/v1/banners/{id}:
|
||||||
|
|||||||
@ -6,76 +6,6 @@ import { getCredentials, api, request, credentials } from '../../data/api-data';
|
|||||||
describe('banners', () => {
|
describe('banners', () => {
|
||||||
before((done) => getCredentials(done));
|
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]', () => {
|
describe('[/banners.dismiss]', () => {
|
||||||
it('should fail if not logged in', (done) => {
|
it('should fail if not logged in', (done) => {
|
||||||
void request
|
void request
|
||||||
|
|||||||
@ -5,28 +5,6 @@ const ajv = new Ajv({
|
|||||||
coerceTypes: true,
|
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 = {
|
type BannersId = {
|
||||||
platform: BannerPlatform;
|
platform: BannerPlatform;
|
||||||
};
|
};
|
||||||
@ -68,13 +46,6 @@ const BannersDismissSchema = {
|
|||||||
export const isBannersDismissProps = ajv.compile<BannersDismiss>(BannersDismissSchema);
|
export const isBannersDismissProps = ajv.compile<BannersDismiss>(BannersDismissSchema);
|
||||||
|
|
||||||
export type BannersEndpoints = {
|
export type BannersEndpoints = {
|
||||||
/* @deprecated */
|
|
||||||
'/v1/banners.getNew': {
|
|
||||||
GET: (params: BannersGetNew) => {
|
|
||||||
banners: IBanner[];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
'/v1/banners/:id': {
|
'/v1/banners/:id': {
|
||||||
GET: (params: BannersId) => {
|
GET: (params: BannersId) => {
|
||||||
banners: IBanner[];
|
banners: IBanner[];
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user