feat: Add `push.info` endpoint to retrieve push gateway info (#30868)

pull/31051/head^2
Matheus Barbosa Silva 2 years ago committed by GitHub
parent 40e5d4d0a0
commit 748e57984d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      .changeset/fifty-maps-deny.md
  2. 18
      apps/meteor/app/api/server/v1/push.ts
  3. 6
      packages/rest-typings/src/v1/push.ts

@ -0,0 +1,6 @@
---
"@rocket.chat/meteor": minor
"@rocket.chat/rest-typings": minor
---
Added `push.info` endpoint to enable users to retrieve info about the workspace's push gateway

@ -1,10 +1,11 @@
import { Messages, AppsTokens, Users, Rooms } from '@rocket.chat/models';
import { Messages, AppsTokens, Users, Rooms, Settings } from '@rocket.chat/models';
import { Random } from '@rocket.chat/random';
import { Match, check } from 'meteor/check';
import { Meteor } from 'meteor/meteor';
import { canAccessRoomAsync } from '../../../authorization/server/functions/canAccessRoom';
import PushNotification from '../../../push-notifications/server/lib/PushNotification';
import { settings } from '../../../settings/server';
import { API } from '../api';
API.v1.addRoute(
@ -110,3 +111,18 @@ API.v1.addRoute(
},
},
);
API.v1.addRoute(
'push.info',
{ authRequired: true },
{
async get() {
const defaultGateway = (await Settings.findOneById('Push_gateway', { projection: { packageValue: 1 } }))?.packageValue;
const defaultPushGateway = settings.get('Push_gateway') === defaultGateway;
return API.v1.success({
pushGatewayEnabled: settings.get('Push_enable'),
defaultPushGateway,
});
},
},
);

@ -65,4 +65,10 @@ export type PushEndpoints = {
};
};
};
'/v1/push.info': {
GET: () => {
pushGatewayEnabled: boolean;
defaultPushGateway: boolean;
};
};
};

Loading…
Cancel
Save