@@ -10,12 +10,14 @@ API.v1.addRoute('livechat/department', { authRequired: true }, {
1010 get ( ) {
1111 const { offset, count } = this . getPaginationItems ( ) ;
1212 const { sort } = this . parseJsonQuery ( ) ;
13- const { text, enabled } = this . queryParams ;
13+
14+ const { text, enabled, onlyMyDepartments } = this . queryParams ;
1415
1516 const departments = Promise . await ( findDepartments ( {
1617 userId : this . userId ,
1718 text,
1819 enabled,
20+ onlyMyDepartments : onlyMyDepartments === 'true' ,
1921 pagination : {
2022 offset,
2123 count,
@@ -59,10 +61,13 @@ API.v1.addRoute('livechat/department/:_id', { authRequired: true }, {
5961 _id : String ,
6062 } ) ;
6163
64+ const { onlyMyDepartments } = this . queryParams ;
65+
6266 const { department, agents } = Promise . await ( findDepartmentById ( {
6367 userId : this . userId ,
6468 departmentId : this . urlParams . _id ,
6569 includeAgents : this . queryParams . includeAgents && this . queryParams . includeAgents === 'true' ,
70+ onlyMyDepartments : onlyMyDepartments === 'true' ,
6671 } ) ) ;
6772
6873 const result = { department } ;
@@ -137,14 +142,15 @@ API.v1.addRoute('livechat/department/:_id', { authRequired: true }, {
137142
138143API . v1 . addRoute ( 'livechat/department.autocomplete' , { authRequired : true } , {
139144 get ( ) {
140- const { selector } = this . queryParams ;
145+ const { selector, onlyMyDepartments } = this . queryParams ;
141146 if ( ! selector ) {
142147 return API . v1 . failure ( 'The \'selector\' param is required' ) ;
143148 }
144149
145150 return API . v1 . success ( Promise . await ( findDepartmentsToAutocomplete ( {
146151 uid : this . userId ,
147152 selector : JSON . parse ( selector ) ,
153+ onlyMyDepartments : onlyMyDepartments === 'true' ,
148154 } ) ) ) ;
149155 } ,
150156} ) ;
0 commit comments