@chat21/chat21-ionic 3.4.30-rc2 → 3.4.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/CHANGELOG.md +4 -119
  2. package/angular.json +0 -1
  3. package/package.json +1 -1
  4. package/src/app/app.component.html +1 -3
  5. package/src/app/app.component.ts +16 -71
  6. package/src/app/chatlib/conversation-detail/message/image/image.component.html +0 -1
  7. package/src/app/chatlib/conversation-detail/message/image/image.component.ts +0 -19
  8. package/src/app/components/canned-response/canned-response.component.html +23 -26
  9. package/src/app/components/canned-response/canned-response.component.scss +2 -0
  10. package/src/app/components/canned-response/canned-response.component.ts +1 -3
  11. package/src/app/components/conversation-detail/message-text-area/message-text-area.component.html +1 -24
  12. package/src/app/components/conversation-detail/message-text-area/message-text-area.component.scss +0 -30
  13. package/src/app/components/conversation-detail/message-text-area/message-text-area.component.ts +9 -39
  14. package/src/app/components/conversation-info/info-content/info-content.component.ts +2 -2
  15. package/src/app/components/conversation-info/info-group/info-group.component.ts +21 -23
  16. package/src/app/components/conversations-list/header-conversations-list/header-conversations-list.component.html +1 -1
  17. package/src/app/components/conversations-list/header-conversations-list/header-conversations-list.component.ts +1 -5
  18. package/src/app/components/navbar/navbar.component.html +3 -3
  19. package/src/app/components/navbar/navbar.component.ts +38 -29
  20. package/src/app/components/project-item/project-item.component.ts +11 -11
  21. package/src/app/components/sidebar/sidebar.component.html +45 -65
  22. package/src/app/components/sidebar/sidebar.component.ts +117 -110
  23. package/src/app/components/sidebar-user-details/sidebar-user-details.component.html +2 -2
  24. package/src/app/components/sidebar-user-details/sidebar-user-details.component.ts +7 -10
  25. package/src/app/modals/create-ticket/create-ticket.page.ts +2 -4
  26. package/src/app/pages/conversation-detail/conversation-detail.page.html +3 -7
  27. package/src/app/pages/conversation-detail/conversation-detail.page.ts +7 -95
  28. package/src/app/pages/conversations-list/conversations-list.page.html +0 -2
  29. package/src/app/pages/conversations-list/conversations-list.page.ts +2 -40
  30. package/src/app/services/global-settings/global-settings.service.ts +3 -11
  31. package/src/app/services/nav-proxy.service.ts +1 -0
  32. package/src/app/services/tiledesk/tiledesk.service.ts +16 -0
  33. package/src/app/services/triggerEvents/triggerEvents.ts +0 -28
  34. package/src/app/services/websocket/websocket-js.ts +534 -59
  35. package/src/app/services/websocket/websocket.service.ts +10 -9
  36. package/src/app/shared/shared.module.ts +2 -11
  37. package/src/app/utils/globals.ts +0 -2
  38. package/src/app/utils/project-utils.ts +2 -2
  39. package/src/app/utils/utils.ts +1 -18
  40. package/src/assets/i18n/ar.json +1 -11
  41. package/src/assets/i18n/az.json +1 -11
  42. package/src/assets/i18n/de.json +1 -11
  43. package/src/assets/i18n/en.json +1 -11
  44. package/src/assets/i18n/es.json +1 -11
  45. package/src/assets/i18n/fr.json +1 -11
  46. package/src/assets/i18n/it.json +3 -13
  47. package/src/assets/i18n/kk.json +1 -11
  48. package/src/assets/i18n/pt.json +1 -11
  49. package/src/assets/i18n/ru.json +1 -11
  50. package/src/assets/i18n/sr.json +1 -11
  51. package/src/assets/i18n/sv.json +1 -11
  52. package/src/assets/i18n/tr.json +1 -11
  53. package/src/assets/i18n/uk.json +1 -11
  54. package/src/assets/i18n/uz.json +1 -12
  55. package/src/assets/js/chat21client.js +0 -36
  56. package/src/assets/test.html +2 -5
  57. package/src/chat-config-template.json +0 -1
  58. package/src/chat-config.json +0 -1
  59. package/src/chat21-core/providers/abstract/upload.service.ts +1 -5
  60. package/src/chat21-core/providers/firebase/firebase-conversation-handler.ts +1 -1
  61. package/src/chat21-core/providers/firebase/firebase-upload.service.ts +9 -136
  62. package/src/chat21-core/providers/mqtt/mqtt-conversation-handler.ts +1 -1
  63. package/src/chat21-core/providers/native/native-image-repo.ts +1 -1
  64. package/src/chat21-core/providers/native/native-upload-service.ts +45 -143
  65. package/src/chat21-core/providers/tiledesk/tiledesk-auth.service.ts +0 -3
  66. package/src/chat21-core/utils/utils.ts +2 -16
  67. package/src/app/services/project_users/project-users.service.spec.ts +0 -16
  68. package/src/app/services/project_users/project-users.service.ts +0 -63
  69. package/src/app/services/websocket/websocket-js_old.ts +0 -578
  70. package/src/app/services/websocket/websocket.worker.ts +0 -242
  71. package/src/app/utils/permissions.constants.ts +0 -138
  72. package/src/assets/img/no_data_found.png +0 -0
  73. package/src/assets/js/agentDesktop-sdk.js +0 -55
  74. package/src/assets/js/mqtt-keepalive-worker.js +0 -53
  75. package/src/chat21-core/models/projectUsers.ts +0 -19
@@ -387,7 +387,7 @@ export class FirebaseConversationHandler extends ConversationHandlerService {
387
387
  } else {
388
388
 
389
389
  if (message.attributes.messagelabel.parameters.firstname) {
390
- // other user has been added to the group (and he has a fullname)
390
+ // other user has been added to the group (and he has a firstname)
391
391
  subject = message.attributes.messagelabel.parameters.firstname;
392
392
  verb = INFO_SUPPORT_USER_ADDED_VERB;
393
393
  complement = INFO_SUPPORT_USER_ADDED_COMPLEMENT;
@@ -42,7 +42,7 @@ export class FirebaseUploadService extends UploadService {
42
42
  });
43
43
  }
44
44
 
45
- public async initialize(projectId?: string) {
45
+ public initialize() {
46
46
  this.logger.log('[FIREBASEUploadSERVICE] initialize');
47
47
  }
48
48
 
@@ -104,107 +104,6 @@ export class FirebaseUploadService extends UploadService {
104
104
 
105
105
  }
106
106
 
107
- public uploadFile(userId: string, upload: UploadModel): Promise<{downloadURL: string, src: any}> {
108
- const that = this;
109
- const uid = this.createGuid();
110
- const urlImagesNodeFirebase = '/public/images/' + userId + '/' + uid + '/' + upload.file.name;
111
- this.logger.debug('[FIREBASEUploadSERVICE] pushUpload ', urlImagesNodeFirebase, upload.file);
112
-
113
- // Create a root reference
114
- const storageRef = firebase.storage().ref();
115
- this.logger.debug('[FIREBASEUploadSERVICE] storageRef', storageRef);
116
-
117
- // Create a reference to 'mountains.jpg'
118
- const mountainsRef = storageRef.child(urlImagesNodeFirebase);
119
- this.logger.debug('[FIREBASEUploadSERVICE] mountainsRef ', mountainsRef);
120
-
121
- // const metadata = {};
122
- const metadata = { name: upload.file.name, contentType: upload.file.type, contentDisposition: 'attachment; filename=' + upload.file.name };
123
-
124
- let uploadTask = mountainsRef.put(upload.file, metadata);
125
-
126
- return new Promise((resolve, reject) => {
127
- uploadTask.on('state_changed', function progress(snapshot) {
128
- // Observe state change events such as progress, pause, and resume
129
- // Get task progress, including the number of bytes uploaded and the total number of bytes to be uploaded
130
- var progress = (snapshot.bytesTransferred / snapshot.totalBytes) * 100;
131
- that.logger.debug('[FIREBASEUploadSERVICE] Upload is ' + progress + '% done');
132
-
133
- // ----------------------------------------------------------------------------------------------------------------------------------------------
134
- // BehaviorSubject publish the upload progress state - the subscriber is in ion-conversastion-detail.component.ts > listenToUploadFileProgress()
135
- // ----------------------------------------------------------------------------------------------------------------------------------------------
136
-
137
- that.BSStateUpload.next({ upload: progress, type: upload.file.type });
138
-
139
- switch (snapshot.state) {
140
- case firebase.storage.TaskState.PAUSED: // or 'paused'
141
- that.logger.debug('[FIREBASEUploadSERVICE] Upload is paused');
142
-
143
- break;
144
- case firebase.storage.TaskState.RUNNING: // or 'running'
145
- that.logger.debug('[FIREBASEUploadSERVICE] Upload is running');
146
-
147
- break;
148
- }
149
- }, function error(error) {
150
- // Handle unsuccessful uploads
151
- reject(error)
152
- }, async function complete() {
153
- // Handle successful uploads on complete
154
- that.logger.debug('[FIREBASEUploadSERVICE] Upload is complete', upload);
155
-
156
- const downloadURL = await uploadTask.snapshot.ref.getDownloadURL();
157
- resolve({downloadURL: downloadURL, src: downloadURL})
158
- // that.BSStateUpload.next({upload: upload});
159
-
160
- });
161
- })
162
- }
163
-
164
- public uploadAsset(userId: string, upload: UploadModel, expiration: number = 60): Promise<{downloadURL: string, src: any}> {
165
- // expiration is ignored on Firebase, but kept for API compatibility with NativeUploadService
166
- const that = this;
167
- const uid = this.createGuid();
168
- const urlAssetsNodeFirebase = '/public/assets/' + userId + '/' + uid + '/' + upload.file.name;
169
- this.logger.debug('[FIREBASEUploadSERVICE] uploadAsset ', urlAssetsNodeFirebase, upload.file, 'expiration:', expiration);
170
-
171
- // Create a root reference
172
- const storageRef = firebase.storage().ref();
173
- this.logger.debug('[FIREBASEUploadSERVICE] storageRef', storageRef);
174
-
175
- const assetRef = storageRef.child(urlAssetsNodeFirebase);
176
- this.logger.debug('[FIREBASEUploadSERVICE] assetRef ', assetRef);
177
-
178
- const metadata = { name: upload.file.name, contentType: upload.file.type, contentDisposition: 'attachment; filename=' + upload.file.name };
179
-
180
- let uploadTask = assetRef.put(upload.file, metadata);
181
-
182
- return new Promise((resolve, reject) => {
183
- uploadTask.on('state_changed', function progress(snapshot) {
184
- var progress = (snapshot.bytesTransferred / snapshot.totalBytes) * 100;
185
- that.logger.debug('[FIREBASEUploadSERVICE] uploadAsset is ' + progress + '% done');
186
-
187
- that.BSStateUpload.next({ upload: progress, type: upload.file.type });
188
-
189
- switch (snapshot.state) {
190
- case firebase.storage.TaskState.PAUSED:
191
- that.logger.debug('[FIREBASEUploadSERVICE] uploadAsset is paused');
192
- break;
193
- case firebase.storage.TaskState.RUNNING:
194
- that.logger.debug('[FIREBASEUploadSERVICE] uploadAsset is running');
195
- break;
196
- }
197
- }, function error(error) {
198
- reject(error)
199
- }, async function complete() {
200
- that.logger.debug('[FIREBASEUploadSERVICE] uploadAsset is complete', upload);
201
-
202
- const downloadURL = await uploadTask.snapshot.ref.getDownloadURL();
203
- resolve({downloadURL: downloadURL, src: downloadURL})
204
- });
205
- })
206
- }
207
-
208
107
  public uploadProfile(userId: string, upload: UploadModel): Promise<any> {
209
108
  const that = this;
210
109
  const urlImagesNodeFirebase = '/profiles/' + userId + '/photo.jpg'
@@ -293,40 +192,6 @@ export class FirebaseUploadService extends UploadService {
293
192
  })
294
193
  }
295
194
 
296
- public async deleteFile(userId: string, path: string): Promise<any>{
297
- const that = this;
298
- const file_name_photo = 'photo.jpg';
299
- const file_name_thumb_photo = 'thumb_photo.jpg';
300
-
301
- that.logger.debug('[FIREBASEUploadSERVICE] delete image for USER', userId, path);
302
-
303
- let uid = path.split(userId)[1].split('%2F')[1]; // get the UID of the image
304
- let imageName = path.split(uid + '%2F')[1].split('?')[0];
305
-
306
- // Create a root reference
307
- const storageRef = firebase.storage().ref();
308
- const ref = storageRef.child('public/images/' + userId + '/'+ uid + '/')
309
- let arrayPromise = []
310
- await ref.listAll().then((dir => {
311
- dir.items.forEach(fileRef => arrayPromise.push(this.deleteFile(ref.fullPath, fileRef.name)));
312
- })).catch(error => {
313
- that.logger.error('[FIREBASEUploadSERVICE] delete: listAll error', error)
314
- })
315
-
316
- //AWAIT to return ALL the promise delete()
317
- return new Promise((resolve, reject)=> {
318
- Promise.all(arrayPromise).then(()=>{
319
- resolve(true)
320
- }).catch((error)=>{
321
- reject(error)
322
- })
323
- })
324
- }
325
-
326
- public async deleteAsset(userId: string, path: string): Promise<any>{
327
- return this.deleteProfile(userId, path);
328
- }
329
-
330
195
  public async deleteProfile(userId: string, path: string): Promise<any>{
331
196
  const that = this;
332
197
  const file_name_photo = 'photo.jpg';
@@ -354,5 +219,13 @@ export class FirebaseUploadService extends UploadService {
354
219
  })
355
220
  }
356
221
 
222
+ // // ------------------------------------
223
+ // // Delete the file photo
224
+ // // ------------------------------------
225
+ private deleteFile(pathToFile, fileName){
226
+ const ref = firebase.storage().ref(pathToFile);
227
+ const childRef = ref.child(fileName);
228
+ return childRef.delete()
229
+ }
357
230
 
358
231
  }
@@ -365,7 +365,7 @@ export class MQTTConversationHandler extends ConversationHandlerService {
365
365
  complement = INFO_SUPPORT_USER_ADDED_COMPLEMENT;
366
366
  } else {
367
367
  if (message.attributes.messagelabel.parameters.firstname) {
368
- // other user has been added to the group (and he has a fullname)
368
+ // other user has been added to the group (and he has a firstname)
369
369
  subject = message.attributes.messagelabel.parameters.firstname;
370
370
  verb = INFO_SUPPORT_USER_ADDED_VERB;
371
371
  complement = INFO_SUPPORT_USER_ADDED_COMPLEMENT;
@@ -16,7 +16,7 @@ export class NativeImageRepoService extends ImageRepoService {
16
16
  * @param uid
17
17
  */
18
18
  getImagePhotoUrl(uid: string): string {
19
- this.baseImageURL = this.getImageBaseUrl() + 'files'
19
+ this.baseImageURL = this.getImageBaseUrl() + 'images'
20
20
  let sender_id = '';
21
21
  if (uid.includes('bot_')) {
22
22
  sender_id = uid.slice(4)
@@ -6,7 +6,6 @@ import { UploadModel } from '../../models/upload';
6
6
  import { AppStorageService } from '../abstract/app-storage.service';
7
7
  import { LoggerService } from '../abstract/logger.service';
8
8
  import { LoggerInstance } from '../logger/loggerInstance';
9
- import { first } from 'rxjs/operators';
10
9
 
11
10
  // @Injectable({ providedIn: 'root' })
12
11
  @Injectable()
@@ -15,8 +14,8 @@ export class NativeUploadService extends UploadService {
15
14
  BSStateUpload: BehaviorSubject<any> = new BehaviorSubject<any>(null)
16
15
 
17
16
  private tiledeskToken: string;
17
+ private URL_TILEDESK_IMAGES: string;
18
18
  private URL_TILEDESK_FILE: string;
19
- private URL_TILEDESK_UPLOAD: string;
20
19
  private logger: LoggerService = LoggerInstance.getInstance()
21
20
 
22
21
  constructor(
@@ -26,17 +25,15 @@ export class NativeUploadService extends UploadService {
26
25
  super();
27
26
  }
28
27
 
29
- initialize(projectId?: string): void {
30
- this.logger.info('[NATIVE UPLOAD] initialize', this.getBaseUrl())
31
- if (projectId) {
32
- this.URL_TILEDESK_FILE = this.getBaseUrl() + projectId + '/files'
33
- }
34
- this.URL_TILEDESK_UPLOAD = this.getBaseUrl();
28
+ initialize(): void {
29
+ this.logger.info('[NATIVE UPLOAD] initialize')
30
+ this.URL_TILEDESK_FILE = this.getBaseUrl() + 'files'
31
+ this.URL_TILEDESK_IMAGES = this.getBaseUrl() + 'images'
35
32
  this.tiledeskToken = this.appStorage.getItem('tiledeskToken')
36
33
  }
37
34
 
38
35
 
39
- upload(userId: string, upload: UploadModel): Promise<{downloadURL: string, src: string}> {
36
+ upload(userId: string, upload: UploadModel): Promise<{ downloadURL: string, src: string}> {
40
37
  this.logger.log('[NATIVE UPLOAD] - upload new image/file ... upload', upload)
41
38
  const headers = new HttpHeaders({
42
39
  Authorization: this.tiledeskToken,
@@ -48,93 +45,37 @@ export class NativeUploadService extends UploadService {
48
45
 
49
46
  const that = this;
50
47
  if ((upload.file.type.startsWith('image') && (!upload.file.type.includes('svg')))) {
48
+ this.logger.log('[NATIVE UPLOAD] - upload new image')
51
49
  //USE IMAGE API
52
- const url = this.URL_TILEDESK_UPLOAD + 'images/users'
50
+ const url = this.URL_TILEDESK_IMAGES + '/users'
53
51
  return new Promise((resolve, reject) => {
54
- that.http.post(url, formData, requestOptions).pipe(first()).subscribe({
55
- next: (data) => {
56
- const downloadURL = this.URL_TILEDESK_UPLOAD + 'images?path=' + encodeURIComponent(data?.['filename']);
57
- resolve({downloadURL : downloadURL, src: downloadURL})
58
- // that.BSStateUpload.next({upload: upload});
59
- },
60
- error: (error) => {
61
- reject(error)
62
- }
52
+ that.http.post(url, formData, requestOptions).subscribe(data => {
53
+ const downloadURL = this.URL_TILEDESK_IMAGES + '?path=' + data['filename'];
54
+ resolve({downloadURL : downloadURL, src: downloadURL})
55
+ // that.BSStateUpload.next({upload: upload});
56
+ }, (error) => {
57
+ reject(error)
63
58
  });
64
59
  });
65
60
  } else {
61
+ this.logger.log('[NATIVE UPLOAD] - upload new file')
66
62
  //USE FILE API
67
- const url = this.URL_TILEDESK_UPLOAD + 'files/users'
63
+ const url = this.URL_TILEDESK_FILE + '/users'
68
64
  return new Promise((resolve, reject) => {
69
- that.http.post(url, formData, requestOptions).pipe(first()).subscribe({
70
- next: (data) => {
71
- const src = this.URL_TILEDESK_UPLOAD + 'files?path=' + encodeURIComponent(data['filename']);
72
- const downloadURL = this.URL_TILEDESK_UPLOAD + 'files/download' + '?path=' + encodeURIComponent(data['filename']);
73
- resolve({downloadURL : downloadURL, src: src})
74
- // that.BSStateUpload.next({upload: upload});
75
- },
76
- error: (error) => {
77
- this.logger.error('[NATIVE UPLOAD] - ERROR upload new file ', error)
78
- reject(error)
79
- }
65
+ that.http.post(url, formData, requestOptions).subscribe(data => {
66
+ const src = this.URL_TILEDESK_FILE + '?path=' + encodeURI(data['filename']);
67
+ const downloadURL = this.URL_TILEDESK_FILE + '/download' + '?path=' + encodeURI(data['filename']);
68
+ resolve({downloadURL : downloadURL, src: src})
69
+ // that.BSStateUpload.next({upload: upload});
70
+ }, (error) => {
71
+ this.logger.error('[NATIVE UPLOAD] - ERROR upload new file ', error)
72
+ reject(error)
80
73
  });
81
74
  });
82
75
  }
83
76
 
84
77
  }
85
78
 
86
- uploadFile(userId: string, upload: UploadModel): Promise<{downloadURL: string, src: string}> {
87
- this.logger.log('[NATIVE UPLOAD] - upload new image/file ... upload', upload)
88
- const headers = new HttpHeaders({
89
- Authorization: this.tiledeskToken,
90
- //'Content-Type': 'multipart/form-data',
91
- });
92
- const requestOptions = { headers: headers };
93
- const formData = new FormData();
94
- formData.append('file', upload.file);
95
-
96
- const that = this;
97
- const url = this.URL_TILEDESK_FILE + '/chat'
98
- return new Promise((resolve, reject) => {
99
- that.http.post(url, formData, requestOptions).pipe(first()).subscribe({
100
- next: (data) => {
101
- const src = this.URL_TILEDESK_UPLOAD + 'files?path=' + encodeURIComponent(data['filename']);
102
- const downloadURL = this.URL_TILEDESK_UPLOAD + 'files/download?path=' + encodeURIComponent(data['filename']);
103
- resolve({downloadURL : downloadURL, src: src})
104
- },
105
- error: (error) => {
106
- reject(error)
107
- }
108
- });
109
- });
110
- }
111
-
112
- uploadAsset(userId: string, upload: UploadModel, expiration: number = 60): Promise<{downloadURL: string, src: string}> {
113
- this.logger.log('[NATIVE UPLOAD] - upload new asset ... upload', upload, 'expiration:', expiration)
114
- const headers = new HttpHeaders({
115
- Authorization: this.tiledeskToken,
116
- });
117
- const requestOptions = { headers: headers };
118
- const formData = new FormData();
119
- formData.append('file', upload.file);
120
-
121
- const that = this;
122
- const queryString = expiration !== undefined ? `?expiration=${encodeURIComponent(String(expiration))}` : ''
123
- const url = this.URL_TILEDESK_FILE + `/assets${queryString}`
124
- return new Promise((resolve, reject) => {
125
- that.http.post(url, formData, requestOptions).pipe(first()).subscribe({
126
- next: (data) => {
127
- const src = this.URL_TILEDESK_UPLOAD + 'files?path=' + data['filename'];
128
- const downloadURL = this.URL_TILEDESK_UPLOAD + 'files/download?path=' + encodeURIComponent(data['filename']);
129
- resolve({downloadURL : downloadURL, src: src})
130
- },
131
- error: (error) => {
132
- reject(error)
133
- }
134
- });
135
- });
136
- }
137
-
138
79
  uploadProfile(userId: string, upload: UploadModel): Promise<any> {
139
80
  this.logger.log('[NATIVE UPLOAD] - upload new photo profile ... upload', upload)
140
81
  const headers = new HttpHeaders({
@@ -147,18 +88,14 @@ export class NativeUploadService extends UploadService {
147
88
 
148
89
  // USE IMAGE API
149
90
  const that = this;
150
- const queryString = userId?.startsWith('bot_') ? `?bot_id=${encodeURIComponent(userId.substring('bot_'.length))}` : ''
151
- const url = this.URL_TILEDESK_FILE + `/users/photo${queryString}`
91
+ const url = this.URL_TILEDESK_IMAGES + `/users/photo?force=true&user_id=${userId}`
152
92
  return new Promise((resolve, reject) => {
153
- that.http.put(url, formData, requestOptions).pipe(first()).subscribe({
154
- next: (data) => {
155
- const downloadURL = this.getBaseUrl() + 'files?path=' + data['thumbnail'];
156
- resolve(downloadURL)
157
- // that.BSStateUpload.next({upload: upload});
158
- },
159
- error: (error) => {
160
- reject(error)
161
- }
93
+ that.http.put(url, formData, requestOptions).subscribe(data => {
94
+ const downloadURL = this.URL_TILEDESK_IMAGES + '?path=' + data['thumbnail'];
95
+ resolve(downloadURL)
96
+ // that.BSStateUpload.next({upload: upload});
97
+ }, (error) => {
98
+ reject(error)
162
99
  });
163
100
  });
164
101
  }
@@ -173,50 +110,18 @@ export class NativeUploadService extends UploadService {
173
110
 
174
111
  //USE IMAGE API
175
112
  const that = this;
176
- const url = this.URL_TILEDESK_UPLOAD + 'images/users' + '?path=' + path.split('path=')[1]
177
- return new Promise((resolve, reject) => {
178
- that.http.delete(url, requestOptions).pipe(first()).subscribe({
179
- next: (data) => {
180
- // const downloadURL = this.URL_TILEDESK_IMAGES + '?path=' + data['filename'];
181
- resolve(true)
182
- // that.BSStateUpload.next({upload: upload});
183
- },
184
- error: (error) => {
185
- reject(error)
186
- }
187
- });
188
- });
189
- }
190
-
191
- deleteFile(userId: string, path: string): Promise<any>{
192
- this.logger.log('[NATIVE UPLOAD] - delete image ... upload', userId)
193
- const headers = new HttpHeaders({
194
- Authorization: this.tiledeskToken,
195
- //'Content-Type': 'multipart/form-data',
196
- });
197
- const requestOptions = { headers: headers };
198
-
199
- //USE IMAGE API
200
- const that = this;
201
- const url = this.URL_TILEDESK_FILE + '?path=' + path.split('path=')[1]
113
+ const url = this.URL_TILEDESK_IMAGES + '/users' + '?path=' + path.split('path=')[1]
202
114
  return new Promise((resolve, reject) => {
203
- that.http.delete(url, requestOptions).pipe(first()).subscribe({
204
- next: (data) => {
205
- // const downloadURL = this.URL_TILEDESK_IMAGES + '?path=' + data['filename'];
206
- resolve(true)
207
- // that.BSStateUpload.next({upload: upload});
208
- },
209
- error: (error) => {
210
- reject(error)
211
- }
115
+ that.http.delete(url, requestOptions).subscribe(data => {
116
+ // const downloadURL = this.URL_TILEDESK_IMAGES + '?path=' + data['filename'];
117
+ resolve(true)
118
+ // that.BSStateUpload.next({upload: upload});
119
+ }, (error) => {
120
+ reject(error)
212
121
  });
213
122
  });
214
123
  }
215
124
 
216
- deleteAsset(userId: string, path: string): Promise<any>{
217
- return this.deleteFile(userId, path);
218
- }
219
-
220
125
  deleteProfile(userId: string, path: string): Promise<any>{
221
126
  this.logger.log('[NATIVE UPLOAD] - delete image ... upload', userId)
222
127
  const headers = new HttpHeaders({
@@ -227,17 +132,14 @@ export class NativeUploadService extends UploadService {
227
132
 
228
133
  //USE IMAGE API
229
134
  const that = this;
230
- const url = this.URL_TILEDESK_FILE + '?path=' + "uploads/users/"+ userId + "/images/photo.jpg"
135
+ const url = this.URL_TILEDESK_IMAGES + '/users' + '?path=' + "uploads/users/"+ userId + "/images/photo.jpg"
231
136
  return new Promise((resolve, reject) => {
232
- that.http.delete(url, requestOptions).pipe(first()).subscribe({
233
- next: (data) => {
234
- // const downloadURL = this.URL_TILEDESK_IMAGES + '?path=' + data['filename'];
235
- resolve(true)
236
- // that.BSStateUpload.next({upload: upload});
237
- },
238
- error: (error) => {
239
- reject(error)
240
- }
137
+ that.http.delete(url, requestOptions).subscribe(data => {
138
+ // const downloadURL = this.URL_TILEDESK_IMAGES + '?path=' + data['filename'];
139
+ resolve(true)
140
+ // that.BSStateUpload.next({upload: upload});
141
+ }, (error) => {
142
+ reject(error)
241
143
  });
242
144
  });
243
145
  }
@@ -121,7 +121,6 @@ export class TiledeskAuthService {
121
121
  this.http.post(this.URL_TILEDESK_SIGNIN_WITH_CUSTOM_TOKEN, null, requestOptions).subscribe((data) => {
122
122
  if (data['success'] && data['token']) {
123
123
  that.tiledeskToken = data['token'];
124
- data['user'].token = tiledeskToken; // mantengo il token custom nell'oggetto user
125
124
  that.createCompleteUser(data['user']);
126
125
  this.checkAndSetInStorageTiledeskToken(that.tiledeskToken)
127
126
  this.BS_IsONLINE.next(true)
@@ -178,8 +177,6 @@ export class TiledeskAuthService {
178
177
  this.currentUser = member;
179
178
  this.logger.log('[TILEDESK-AUTH] - createCompleteUser member ', member);
180
179
  this.appStorage.setItem('currentUser', JSON.stringify(this.currentUser));
181
- const { iat, aud, iss, jti, ...cleanUser } = user; //destructuring and rest user object
182
- localStorage.setItem('user', JSON.stringify(cleanUser));
183
180
 
184
181
  } catch (err) {
185
182
  this.logger.error('[TILEDESK-AUTH]- createCompleteUser ERR ', err)
@@ -765,12 +765,6 @@ export function isOnMobileDevice() {
765
765
  return IS_ON_MOBILE_DEVICE;
766
766
  }
767
767
 
768
-
769
- export function checkIfIsInIframe(){
770
- const isInIframe = window.self !== window.top;
771
- return isInIframe;
772
- }
773
-
774
768
  export function checkWindowWidthIsLessThan991px() {
775
769
  // console.log('UTILS - checkWindowWidthIsLessThan991px:: ', window.innerWidth);
776
770
  if (window.innerWidth < 991) {
@@ -1024,14 +1018,6 @@ export function isAllowedUrlInText(text: string, allowedUrls: string[]) {
1024
1018
  }
1025
1019
 
1026
1020
  function extractUrls(text: string): string[] {
1027
- // Rileva URL con o senza protocollo (http/https)
1028
- const urlRegex = /\b((https?:\/\/)?(www\.)?[a-z0-9.-]+\.[a-z]{2,})(\/[^\s]*)?/gi;
1029
- const matches = text.match(urlRegex) || [];
1030
- // Normalizza: aggiunge https:// se manca, così il parsing con new URL() funziona
1031
- return matches.map((url) => {
1032
- if (!/^https?:\/\//i.test(url)) {
1033
- return 'https://' + url;
1034
- }
1035
- return url;
1036
- });
1021
+ const urlRegex = /https?:\/\/[^\s]+/g;
1022
+ return text.match(urlRegex) || [];
1037
1023
  }
@@ -1,16 +0,0 @@
1
- import { TestBed } from '@angular/core/testing';
2
-
3
- import { ProjectUsersService } from './project-users.service';
4
-
5
- describe('ProjectUsersService', () => {
6
- let service: ProjectUsersService;
7
-
8
- beforeEach(() => {
9
- TestBed.configureTestingModule({});
10
- service = TestBed.inject(ProjectUsersService);
11
- });
12
-
13
- it('should be created', () => {
14
- expect(service).toBeTruthy();
15
- });
16
- });
@@ -1,63 +0,0 @@
1
- import { HttpClient, HttpHeaders } from '@angular/common/http';
2
- import { Injectable } from '@angular/core';
3
- import { Observable } from 'rxjs';
4
- import { map } from 'rxjs/operators';
5
- import { ProjectUser } from 'src/chat21-core/models/projectUsers';
6
- import { AppStorageService } from 'src/chat21-core/providers/abstract/app-storage.service';
7
- import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service';
8
- import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance';
9
-
10
- @Injectable({
11
- providedIn: 'root'
12
- })
13
- export class ProjectUsersService {
14
-
15
- private SERVER_BASE_URL: string;
16
- private tiledeskToken: string;
17
-
18
- private logger: LoggerService = LoggerInstance.getInstance();
19
- constructor(
20
- public http: HttpClient,
21
- public appStorageService: AppStorageService
22
- ) {}
23
-
24
- initialize(serverBaseUrl: string) {
25
- this.logger.log('[TILEDESK-PROJECT_USERS-SERV] - initialize serverBaseUrl', serverBaseUrl);
26
- this.SERVER_BASE_URL = serverBaseUrl;
27
- this.tiledeskToken = this.appStorageService.getItem('tiledeskToken')
28
- }
29
-
30
- public getProjectUsersByProjectId(project_id: string): Observable<ProjectUser[]> {
31
- const url = this.SERVER_BASE_URL + project_id + '/project_users/';
32
- this.logger.log('[TILEDESK-SERVICE] - GET PROJECT-USER URL', url);
33
-
34
- const httpOptions = {
35
- headers: new HttpHeaders({
36
- 'Content-Type': 'application/json',
37
- Authorization: this.tiledeskToken
38
- })
39
- };
40
- return this.http.get(url, httpOptions).pipe(map((res: any) => {
41
- this.logger.log('[TILEDESK-SERVICE] - GET PROJECT-USER RES ', res);
42
- return res
43
- }))
44
- }
45
-
46
- public getProjectUserByProjectId(project_id: string): Promise<ProjectUser> {
47
- const url = this.SERVER_BASE_URL + project_id + '/project_users/me';
48
- this.logger.log('[TILEDESK-SERVICE]- GET PROJECT-USER BY USER-ID - URL', url);
49
-
50
- const httpOptions = {
51
- headers: new HttpHeaders({
52
- 'Content-Type': 'application/json',
53
- Authorization: this.tiledeskToken
54
- })
55
- };
56
-
57
- return this.http.get(url, httpOptions).pipe(map((res: any) => {
58
- this.logger.log('[TILEDESK-SERVICE] - GET PROJECT-USER RES ', res);
59
- return res[0]
60
- })).toPromise();
61
- }
62
-
63
- }