Chore: Use only LivechatTriggerRaw model (#23974)
* Use only LivechatTriggerRaw model * Remove importpull/23993/head
parent
b1e1508b7c
commit
955d67e06f
@ -1,17 +1,19 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
import { check } from 'meteor/check'; |
||||
|
||||
import { hasPermission } from '../../../authorization'; |
||||
import { LivechatTrigger } from '../../../models'; |
||||
import { hasPermission } from '../../../authorization/server'; |
||||
import { LivechatTrigger } from '../../../models/server/raw'; |
||||
|
||||
Meteor.methods({ |
||||
'livechat:removeTrigger'(triggerId) { |
||||
async 'livechat:removeTrigger'(triggerId) { |
||||
if (!Meteor.userId() || !hasPermission(Meteor.userId(), 'view-livechat-manager')) { |
||||
throw new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'livechat:removeTrigger' }); |
||||
} |
||||
|
||||
check(triggerId, String); |
||||
|
||||
return LivechatTrigger.removeById(triggerId); |
||||
await LivechatTrigger.removeById(triggerId); |
||||
|
||||
return true; |
||||
}, |
||||
}); |
||||
|
||||
@ -1,34 +0,0 @@ |
||||
import { Base } from './_Base'; |
||||
|
||||
/** |
||||
* Livechat Trigger model |
||||
*/ |
||||
export class LivechatTrigger extends Base { |
||||
constructor() { |
||||
super('livechat_trigger'); |
||||
|
||||
this.tryEnsureIndex({ enabled: 1 }); |
||||
} |
||||
|
||||
updateById(_id, data) { |
||||
return this.update({ _id }, { $set: data }); |
||||
} |
||||
|
||||
removeAll() { |
||||
return this.remove({}); |
||||
} |
||||
|
||||
findById(_id) { |
||||
return this.find({ _id }); |
||||
} |
||||
|
||||
removeById(_id) { |
||||
return this.remove({ _id }); |
||||
} |
||||
|
||||
findEnabled() { |
||||
return this.find({ enabled: true }); |
||||
} |
||||
} |
||||
|
||||
export default new LivechatTrigger(); |
||||
@ -1,6 +1,18 @@ |
||||
import { BaseRaw } from './BaseRaw'; |
||||
import { Cursor, UpdateWriteOpResult } from 'mongodb'; |
||||
|
||||
import { BaseRaw, IndexSpecification } from './BaseRaw'; |
||||
import { ILivechatTrigger } from '../../../../definition/ILivechatTrigger'; |
||||
|
||||
export class LivechatTriggerRaw extends BaseRaw<ILivechatTrigger> { |
||||
protected indexes: IndexSpecification[] = [ |
||||
{ key: { enabled: 1 } }, |
||||
]; |
||||
|
||||
findEnabled(): Cursor<ILivechatTrigger> { |
||||
return this.find({ enabled: true }); |
||||
} |
||||
|
||||
updateById(_id: string, data: ILivechatTrigger): Promise<UpdateWriteOpResult> { |
||||
return this.updateOne({ _id }, { $set: data }); |
||||
} |
||||
} |
||||
|
||||
Loading…
Reference in new issue