Skip to content

Commit

Permalink
Merge pull request RocketChat#701 from Shailesh351/sb_api_livechat_fi…
Browse files Browse the repository at this point in the history
…lter

Add livechat/filter post API Endpoint
  • Loading branch information
ear-dev authored May 20, 2021
2 parents 4feec7f + 05ddfd7 commit a4ab7b7
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions app/livechat/imports/server/rest/filters.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,31 @@
import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';

import { API } from '../../../../api/server';
import { findFilters, findFilterById } from '../../../server/api/lib/filters';

API.v1.addRoute('livechat/filter', { authRequired: true }, {
post() {
try {
check(this.bodyParams, {
name: String,
description: String,
enabled: Boolean,
regex: String,
slug: String,
});

API.v1.success(
Meteor.runAsUser(this.userId,
() => Meteor.call('livechat:saveFilter', this.bodyParams),
),
);
} catch (e) {
return API.v1.failure(e);
}
},
});

API.v1.addRoute('livechat/filters', { authRequired: true }, {
get() {
const { offset, count } = this.getPaginationItems();
Expand Down

0 comments on commit a4ab7b7

Please sign in to comment.