snapshot of https://github.com/RocketChat/Rocket.Chat.git (develop, 2026-09-16; blobs > 131072B omitted)
Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 1s
Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 1s
This commit is contained in:
192
apps/meteor/ee/server/api/v1/canned-responses.ts
Normal file
192
apps/meteor/ee/server/api/v1/canned-responses.ts
Normal file
@@ -0,0 +1,192 @@
|
||||
import type { ILivechatDepartment, IOmnichannelCannedResponse, IUser } from '@rocket.chat/core-typings';
|
||||
import { isPOSTCannedResponsesProps, isCannedResponsesProps, isDELETECannedResponsesProps } from '@rocket.chat/rest-typings';
|
||||
import type { PaginatedResult, PaginatedRequest } from '@rocket.chat/rest-typings';
|
||||
|
||||
import { API } from '../../../../server/api';
|
||||
import { getPaginationItems } from '../../../../server/api/lib/getPaginationItems';
|
||||
import { removeCannedResponse } from '../../meteor-methods/removeCannedResponse';
|
||||
import { saveCannedResponse } from '../../meteor-methods/saveCannedResponse';
|
||||
import { findAllCannedResponses, findAllCannedResponsesFilter, findOneCannedResponse } from '../lib/canned-responses';
|
||||
|
||||
declare module '@rocket.chat/rest-typings' {
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
interface Endpoints {
|
||||
'/v1/canned-responses': {
|
||||
GET: (
|
||||
params: PaginatedRequest<{
|
||||
shortcut?: string;
|
||||
text?: string;
|
||||
scope?: string;
|
||||
createdBy?: IUser['username'];
|
||||
tags?: any;
|
||||
departmentId?: ILivechatDepartment['_id'];
|
||||
}>,
|
||||
) => PaginatedResult<{
|
||||
cannedResponses: IOmnichannelCannedResponse[];
|
||||
}>;
|
||||
POST: (params: {
|
||||
_id?: IOmnichannelCannedResponse['_id'];
|
||||
shortcut: string;
|
||||
text: string;
|
||||
scope: string;
|
||||
tags?: any;
|
||||
departmentId?: ILivechatDepartment['_id'];
|
||||
}) => void;
|
||||
DELETE: (params: { _id: IOmnichannelCannedResponse['_id'] }) => void;
|
||||
};
|
||||
'/v1/canned-responses/:_id': {
|
||||
GET: () => {
|
||||
cannedResponse: IOmnichannelCannedResponse;
|
||||
};
|
||||
DELETE: () => void;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
API.v1.addRoute(
|
||||
'canned-responses.get',
|
||||
{ authRequired: true, permissionsRequired: ['view-canned-responses'], license: ['canned-responses'] },
|
||||
{
|
||||
async get() {
|
||||
return API.v1.success({
|
||||
responses: await findAllCannedResponses({ userId: this.userId }),
|
||||
});
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @openapi
|
||||
* /api/v1/canned-responses:
|
||||
* delete:
|
||||
* deprecated: true
|
||||
* security:
|
||||
* $ref: '#/security/authenticated'
|
||||
* parameters:
|
||||
* - in: body
|
||||
* name: body
|
||||
* description: |
|
||||
* **_id** (required): Canned Response ID to be removed.
|
||||
* schema:
|
||||
* type: object
|
||||
* required:
|
||||
* - _id
|
||||
* properties:
|
||||
* _id:
|
||||
* type: string
|
||||
* tags:
|
||||
* - Canned_Responses
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Successful Response
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* status:
|
||||
* type: string
|
||||
* example: success
|
||||
* data:
|
||||
* type: object
|
||||
* description: The response data
|
||||
* properties:
|
||||
* success:
|
||||
* type: boolean
|
||||
* example: true
|
||||
* 401:
|
||||
* $ref: '#/responses/Unauthorized'
|
||||
* 403:
|
||||
* $ref: '#/responses/Forbidden'
|
||||
* 404:
|
||||
* $ref: '#/responses/NotFound'
|
||||
* 500:
|
||||
* $ref: '#/responses/InternalServerError'
|
||||
*/
|
||||
API.v1.addRoute(
|
||||
'canned-responses',
|
||||
{
|
||||
authRequired: true,
|
||||
permissionsRequired: { GET: ['view-canned-responses'], POST: ['save-canned-responses'], DELETE: ['remove-canned-responses'] },
|
||||
validateParams: { POST: isPOSTCannedResponsesProps, DELETE: isDELETECannedResponsesProps, GET: isCannedResponsesProps },
|
||||
license: ['canned-responses'],
|
||||
deprecations: { DELETE: { version: '8.0.0', alternatives: ['/v1/canned-responses/:_id'] } },
|
||||
},
|
||||
{
|
||||
async get() {
|
||||
const { offset, count } = await getPaginationItems(this.queryParams);
|
||||
const { sort, fields } = await this.parseJsonQuery();
|
||||
const { shortcut, text, scope, tags, departmentId, createdBy } = this.queryParams;
|
||||
const { cannedResponses, total } = await findAllCannedResponsesFilter({
|
||||
shortcut,
|
||||
text,
|
||||
scope,
|
||||
tags,
|
||||
departmentId,
|
||||
userId: this.userId,
|
||||
createdBy,
|
||||
options: {
|
||||
sort,
|
||||
offset,
|
||||
count,
|
||||
fields,
|
||||
},
|
||||
});
|
||||
return API.v1.success({
|
||||
cannedResponses,
|
||||
count: cannedResponses.length,
|
||||
offset,
|
||||
total,
|
||||
});
|
||||
},
|
||||
async post() {
|
||||
const { _id, shortcut, text, scope, departmentId, tags } = this.bodyParams;
|
||||
await saveCannedResponse(
|
||||
this.userId,
|
||||
{
|
||||
shortcut,
|
||||
text,
|
||||
scope,
|
||||
...(tags && { tags }),
|
||||
...(departmentId && { departmentId }),
|
||||
},
|
||||
_id,
|
||||
);
|
||||
return API.v1.success();
|
||||
},
|
||||
// deprecated
|
||||
async delete() {
|
||||
const { _id } = this.bodyParams;
|
||||
await removeCannedResponse(this.userId, _id);
|
||||
return API.v1.success();
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
API.v1.addRoute(
|
||||
'canned-responses/:_id',
|
||||
{
|
||||
authRequired: true,
|
||||
permissionsRequired: { GET: ['view-canned-responses'], DELETE: ['remove-canned-responses'] },
|
||||
license: ['canned-responses'],
|
||||
},
|
||||
{
|
||||
async get() {
|
||||
const { _id } = this.urlParams;
|
||||
const cannedResponse = await findOneCannedResponse({
|
||||
userId: this.userId,
|
||||
_id,
|
||||
});
|
||||
|
||||
if (!cannedResponse) {
|
||||
return API.v1.notFound();
|
||||
}
|
||||
|
||||
return API.v1.success({ cannedResponse });
|
||||
},
|
||||
async delete() {
|
||||
const { _id } = this.urlParams;
|
||||
await removeCannedResponse(this.userId, _id);
|
||||
return API.v1.success();
|
||||
},
|
||||
},
|
||||
);
|
||||
Reference in New Issue
Block a user