chat4app-client-angular 0.0.10 → 0.0.11

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.
@@ -28,450 +28,474 @@
28
28
  var i1__namespace = /*#__PURE__*/_interopNamespace(i1);
29
29
  var moment__namespace = /*#__PURE__*/_interopNamespace(moment);
30
30
 
31
- var Chat4appClientAngularService = /** @class */ (function () {
32
- function Chat4appClientAngularService(http) {
33
- this.http = http;
34
- this.chatServer = "";
35
- this.chatUrl = "";
36
- }
37
- Chat4appClientAngularService.prototype.ngOnInit = function () {
38
- };
39
- Chat4appClientAngularService.prototype.config = function (chat4AppConfig) {
40
- this.chatServer = chat4AppConfig.endpoint;
41
- this.chatUrl = chat4AppConfig.endpoint + "/api/v1/";
42
- };
43
- Chat4appClientAngularService.prototype.init = function (securityChatToken, callback, chatCallback, connectionClientId) {
44
- if (!this.chatServer || this.chatServer.trim().length == 0) {
45
- throw new Error("Endpoint is empty");
46
- }
47
- if (!securityChatToken || securityChatToken.trim().length == 0) {
48
- throw new Error("SecurityChatToken is empty");
49
- }
50
- this.setTokenChat4app(securityChatToken);
51
- if (chatCallback && connectionClientId) {
52
- this.connectWebsocket(chatCallback, connectionClientId);
53
- }
54
- callback(securityChatToken);
55
- };
56
- Chat4appClientAngularService.prototype.getChatUrlDownload = function (messageFileId) {
57
- return this.chatUrl + "chatmessage/getFile?messageFileId=" + messageFileId + "&token=" + this.getBearerToken();
58
- };
59
- Chat4appClientAngularService.prototype.getMessageChat = function (chatId, fromId, toId) {
60
- var url = this.chatUrl + "chatmessage/" + chatId + "/" + fromId + "/" + toId;
61
- return this.http.get(url, {
62
- headers: new i1.HttpHeaders().set('Authorization', this.getBearerToken())
63
- });
64
- };
65
- Chat4appClientAngularService.prototype.getMessageChatByGrop = function (chatId, groupId, fromId) {
66
- var url = this.chatUrl + "chatmessage/byGroup/" + chatId + "/" + groupId + "/" + fromId;
67
- return this.http.get(url, {
68
- headers: new i1.HttpHeaders().set('Authorization', this.getBearerToken())
69
- });
70
- };
71
- Chat4appClientAngularService.prototype.addMessageChat = function (chatMessage4App) {
72
- var url = this.chatUrl + "chatmessage/" + chatMessage4App.chatId;
73
- return this.http.post(url, chatMessage4App, {
74
- headers: new i1.HttpHeaders().set('Authorization', this.getBearerToken())
75
- });
76
- };
77
- Chat4appClientAngularService.prototype.props = function (chatFilterRequest4App) {
78
- var url = this.chatUrl + "chatmessage/props";
79
- return this.http.post(url, chatFilterRequest4App, {
80
- headers: new i1.HttpHeaders().set('Authorization', this.getBearerToken())
81
- });
82
- };
83
- Chat4appClientAngularService.prototype.removeUsersChat = function (chatId, chatUsersId, chatUsersExternalId) {
84
- var params = new Array();
85
- if (chatUsersId && chatUsersId.length > 0) {
86
- chatUsersId.forEach(function (cui) {
87
- params.push("chatUserId=" + cui);
88
- });
89
- }
90
- else if (chatUsersExternalId && chatUsersExternalId.length > 0) {
91
- chatUsersExternalId.forEach(function (cuei) {
92
- params.push("chatUserExternalId=" + cuei);
93
- });
94
- }
95
- var url = this.chatUrl + "chatuser/" + chatId + "?" + params.join("&");
96
- return this.http.delete(url, {
97
- headers: new i1.HttpHeaders().set('Authorization', this.getBearerToken())
98
- });
99
- };
100
- Chat4appClientAngularService.prototype.removeUserChat = function (chatId, chatUserId, chatUserExternalId) {
101
- var param = "";
102
- if (chatUserId) {
103
- param = "chatUserId=" + chatUserId;
104
- }
105
- else {
106
- param = "chatUserExternalId=" + chatUserExternalId;
107
- }
108
- var url = this.chatUrl + "chatuser/" + chatId + "?" + param;
109
- return this.http.delete(url, {
110
- headers: new i1.HttpHeaders().set('Authorization', this.getBearerToken())
111
- });
112
- };
113
- Chat4appClientAngularService.prototype.updateUserChat = function (chatId, charUser4AppUpdate) {
114
- var url = this.chatUrl + "chatuser/" + chatId;
115
- return this.http.put(url, charUser4AppUpdate, {
116
- headers: new i1.HttpHeaders().set('Authorization', this.getBearerToken())
117
- });
118
- };
119
- Chat4appClientAngularService.prototype.createUserChat = function (chatId, chatUser4App) {
120
- var url = this.chatUrl + "chatuser/" + chatId;
121
- return this.http.post(url, chatUser4App, {
122
- headers: new i1.HttpHeaders().set('Authorization', this.getBearerToken())
123
- });
124
- };
125
- Chat4appClientAngularService.prototype.createUsersChat = function (chatId, chatUser4App) {
126
- var url = this.chatUrl + "chatuser/users/" + chatId;
127
- return this.http.post(url, chatUser4App, {
128
- headers: new i1.HttpHeaders().set('Authorization', this.getBearerToken())
129
- });
130
- };
131
- Chat4appClientAngularService.prototype.createChat = function (chat4app) {
132
- var url = this.chatUrl + "chat";
133
- return this.http.post(url, chat4app, {
134
- headers: new i1.HttpHeaders().set('Authorization', this.getBearerToken())
135
- });
136
- };
137
- Chat4appClientAngularService.prototype.createUpdateChat = function (chat4app) {
138
- var url = this.chatUrl + "chat";
139
- return this.http.put(url, chat4app, {
140
- headers: new i1.HttpHeaders().set('Authorization', this.getBearerToken())
141
- });
142
- };
143
- Chat4appClientAngularService.prototype.getLastMessageGroup = function (chatExternalId, groupId) {
144
- var url = this.chatUrl + "chatmessage/lastMessageGroup?chatExternalId=" + chatExternalId + "&groupId=" + groupId;
145
- return this.http.get(url, {
146
- headers: new i1.HttpHeaders().set('Authorization', this.getBearerToken())
147
- });
148
- };
149
- Chat4appClientAngularService.prototype.getLastMessage = function (chatExternalId, chatUserExternalId) {
150
- var url = this.chatUrl + "chatmessage/lastMessage?chatExternalId=" + chatExternalId + "&chatUserExternalId=" + chatUserExternalId;
151
- return this.http.get(url, {
152
- headers: new i1.HttpHeaders().set('Authorization', this.getBearerToken())
153
- });
154
- };
155
- Chat4appClientAngularService.prototype.countNotReadMessages = function (chatUserExternalId, chatExternalId, groupId) {
156
- var url = this.chatUrl + "chatmessage/countNotReadMessages?chatUserExternalId=" + chatUserExternalId;
157
- if (chatExternalId && chatExternalId.length > 0) {
158
- url += "&chatExternalId=" + chatExternalId;
159
- }
160
- if (groupId && groupId.length > 0) {
161
- url += "&groupId=" + groupId;
162
- }
163
- return this.http.get(url, {
164
- headers: new i1.HttpHeaders().set('Authorization', this.getBearerToken())
165
- });
166
- };
167
- Chat4appClientAngularService.prototype.getChatByExternalId = function (externalId) {
168
- var url = this.chatUrl + "chat?externalId=" + externalId;
169
- return this.http.get(url, {
170
- headers: new i1.HttpHeaders().set('Authorization', this.getBearerToken())
171
- });
172
- };
173
- Chat4appClientAngularService.prototype.readMessage = function (chatMessageId, toId) {
174
- var url = this.chatUrl + "chatmessage/read/" + chatMessageId;
175
- if (toId && toId.length > 0) {
176
- url += "/" + toId;
177
- }
178
- return this.http.put(url, null, {
179
- headers: new i1.HttpHeaders().set('Authorization', this.getBearerToken())
180
- });
181
- };
182
- Chat4appClientAngularService.prototype.online = function (chatId, chatUserId) {
183
- var url = this.chatUrl + "chatmessage/online/" + chatId + "/" + chatUserId;
184
- return this.http.get(url, {
185
- headers: new i1.HttpHeaders().set('Authorization', this.getBearerToken())
186
- });
187
- };
188
- Chat4appClientAngularService.prototype.sendFile = function (chatId, fromId, toId, fileToUpload) {
189
- var endpoint = this.chatUrl + "chatmessage/sendFile/" + chatId + "/" + fromId + "/" + toId;
190
- var formData = new FormData();
191
- formData.append('file', fileToUpload);
192
- return this.http
193
- .post(endpoint, formData, {
194
- headers: new i1.HttpHeaders().set('Authorization', this.getBearerToken())
195
- });
196
- };
197
- Chat4appClientAngularService.prototype.sendFileGroup = function (chatId, fromId, groupId, fileToUpload) {
198
- var endpoint = this.chatUrl + "chatmessage/sendFileGroup/" + chatId + "/" + fromId + "/" + groupId;
199
- var formData = new FormData();
200
- formData.append('file', fileToUpload);
201
- return this.http
202
- .post(endpoint, formData, {
203
- headers: new i1.HttpHeaders().set('Authorization', this.getBearerToken())
204
- });
205
- };
206
- Chat4appClientAngularService.prototype.translateMessage = function (chatMessageId, languageTarget) {
207
- var url = this.chatUrl + "chatmessage/translate/" + chatMessageId + "/" + languageTarget;
208
- return this.http.get(url, {
209
- headers: new i1.HttpHeaders().set('Authorization', this.getBearerToken())
210
- });
211
- };
212
- /* Token */
213
- Chat4appClientAngularService.prototype.getBearerToken = function () {
214
- var ret = "Bearer " + window.sessionStorage.getItem("chat4AppSessionToken");
215
- return ret;
216
- };
217
- Chat4appClientAngularService.prototype.setTokenChat4app = function (chat4AppSessionToken) {
218
- window.sessionStorage.setItem("chat4AppSessionToken", chat4AppSessionToken);
219
- };
220
- /* Connection */
221
- Chat4appClientAngularService.prototype.onMessageFirebaseReceived = function (data, chatCallback) {
222
- //alert("onMessageReceived connectFirebase");
223
- if (data.type == "msg") {
224
- var chat4appMessage = new Chat4AppMessageReceive();
225
- chat4appMessage.data.chatId = data.chatId;
226
- chat4appMessage.data.chatMessageId = data.chatMessageId;
227
- chat4appMessage.data.externalId = data.externalId;
228
- chat4appMessage.data.fromId = data.fromId;
229
- chat4appMessage.data.toId = data.toId;
230
- chat4appMessage.data.dateHour = data.dateHour;
231
- chat4appMessage.data.type = data.type;
232
- chat4appMessage.notification.body = data.body;
233
- if (data.fileId && data.fileId.length > 0) {
234
- chat4appMessage.data.fileId = data.fileId;
235
- chat4appMessage.data.fileName = data.fileName;
236
- chat4appMessage.data.fileSize = data.fileSize;
237
- chat4appMessage.data.fileType = data.fileType;
238
- }
239
- var datTmp = new Map();
240
- for (var key in data) {
241
- datTmp.set(key, data[key]);
242
- }
243
- chat4appMessage.data.all = datTmp;
244
- chatCallback.onMessage(chat4appMessage);
245
- }
246
- else if ((data.type == "on" || data.type == "off")) {
247
- var chat4appMessage = new Chat4AppMessageReceive();
248
- chat4appMessage.data.chatId = data.chatId;
249
- chat4appMessage.data.chatMessageId = data.chatMessageId;
250
- chat4appMessage.data.externalId = data.externalId;
251
- chat4appMessage.data.fromId = data.fromId;
252
- chat4appMessage.data.toId = data.toId;
253
- chat4appMessage.data.dateHour = data.dateHour;
254
- chat4appMessage.data.type = data.type;
255
- var datTmp = new Map();
256
- for (var key in data) {
257
- datTmp.set(key, data[key]);
258
- }
259
- chat4appMessage.data.all = datTmp;
260
- chatCallback.onOffline(chat4appMessage);
261
- }
262
- else if (data.type == "read") {
263
- var chat4appMessage = new Chat4AppMessageReceive();
264
- chat4appMessage.data.chatId = data.chatId;
265
- chat4appMessage.data.chatMessageId = data.chatMessageId;
266
- chat4appMessage.data.externalId = data.externalId;
267
- chat4appMessage.data.fromId = data.fromId;
268
- chat4appMessage.data.toId = data.toId;
269
- chat4appMessage.data.dateHour = data.dateHour;
270
- chat4appMessage.data.type = data.type;
271
- var datTmp = new Map();
272
- for (var key in data) {
273
- datTmp.set(key, data[key]);
274
- }
275
- chat4appMessage.data.all = datTmp;
276
- chatCallback.onRead(chat4appMessage);
277
- }
278
- };
279
- Chat4appClientAngularService.prototype.connectWebsocket = function (chatCallback, token) {
280
- var _this = this;
281
- this.disconnect();
282
- var securityToken = this.getBearerToken();
283
- this.sock = new SockJS__namespace(this.chatServer + '/stomp/gkz-stomp-endpoint?token=' + securityToken);
284
- this.stompClient = Stomp__namespace.over(this.sock);
285
- this.stompClient.debug = function (msg) {
286
- //console.log(msg);
287
- };
288
- this.stompClient.connect({}, function (frame) {
289
- //console.log(frame);
290
- _this.stompClient.subscribe('/queue/' + token, function (msg) {
291
- //console.log('mensagem', msg);
292
- if (msg.command == "MESSAGE") {
293
- //console.log(msg)
294
- var msgObj = JSON.parse(msg.body);
295
- var datTmp = new Map();
296
- for (var key in msgObj.data) {
297
- datTmp.set(key, msgObj.data[key]);
298
- }
299
- msgObj.data.all = datTmp;
300
- if (msgObj.data.type == "msg") {
301
- chatCallback.onMessage(msgObj);
302
- }
303
- else if ((msgObj.data.type == "on" || msgObj.data.type == "off")) {
304
- chatCallback.onOffline(msgObj);
305
- }
306
- else if (msgObj.data.type == "read") {
307
- chatCallback.onRead(msgObj);
308
- }
309
- //callback(msg.body);
310
- // ichatcallback.forEach((iChat)=>{
311
- // iChat.onMessage(JSON.parse(msg.body) );
312
- // });
313
- }
314
- });
315
- }, function (message) {
316
- // check message for disconnect
317
- //console.log("Disconnect");
318
- setTimeout(function () {
319
- _this.connectWebsocket(chatCallback, token);
320
- }, 500);
321
- });
322
- };
323
- Chat4appClientAngularService.prototype.disconnect = function () {
324
- // console.log("disconnect")
325
- try {
326
- if (this.stompClient) {
327
- this.stompClient.disconnect();
328
- }
329
- }
330
- catch (e) {
331
- console.log(e);
332
- }
333
- };
334
- Chat4appClientAngularService.prototype.convertChat4AppMessageReceiveToChatMessage4App = function (msg) {
335
- var message = new ChatMessage4App();
336
- message.body = msg.notification.body;
337
- message.chatId = msg.data.chatId;
338
- message.fromId = msg.data.fromId;
339
- message.toId = msg.data.toId;
340
- message.dateHourIncluded = moment__namespace.utc(msg.data.dateHour, "DD-MM-YYYY hh:mm:ss").toDate();
341
- message.id = msg.data.chatMessageId;
342
- if (msg.data.fileId && msg.data.fileId.length > 0) {
343
- var messageFile = new ChatMessageFile4App();
344
- messageFile.id = msg.data.fileId;
345
- messageFile.name = msg.data.fileName;
346
- messageFile.size = msg.data.fileSize;
347
- messageFile.type = msg.data.fileType;
348
- message.chatMessageFile = messageFile;
349
- }
350
- return message;
351
- };
352
- return Chat4appClientAngularService;
353
- }());
354
- Chat4appClientAngularService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function Chat4appClientAngularService_Factory() { return new Chat4appClientAngularService(i0__namespace.ɵɵinject(i1__namespace.HttpClient)); }, token: Chat4appClientAngularService, providedIn: "root" });
355
- Chat4appClientAngularService.decorators = [
356
- { type: i0.Injectable, args: [{
357
- providedIn: 'root'
358
- },] }
359
- ];
360
- Chat4appClientAngularService.ctorParameters = function () { return [
361
- { type: i1.HttpClient }
362
- ]; };
363
- var Chat4App = /** @class */ (function () {
364
- function Chat4App() {
365
- }
366
- return Chat4App;
367
- }());
368
- var ChatUser4App = /** @class */ (function () {
369
- function ChatUser4App() {
370
- }
371
- return ChatUser4App;
372
- }());
373
- var ChatMessage4App = /** @class */ (function () {
374
- function ChatMessage4App() {
375
- }
376
- return ChatMessage4App;
377
- }());
378
- var ChatMessageFile4App = /** @class */ (function () {
379
- function ChatMessageFile4App() {
380
- }
381
- return ChatMessageFile4App;
382
- }());
383
- var ChatMessageMeta4App = /** @class */ (function () {
384
- function ChatMessageMeta4App() {
385
- }
386
- return ChatMessageMeta4App;
387
- }());
388
- var Chat4AppMessageReceive = /** @class */ (function () {
389
- function Chat4AppMessageReceive() {
390
- this.data = new Chat4AppMessageReceiveData();
391
- this.notification = new Chat4AppMessageReceiveNotification();
392
- }
393
- return Chat4AppMessageReceive;
394
- }());
395
- var Chat4AppMessageReceiveData = /** @class */ (function () {
396
- function Chat4AppMessageReceiveData() {
397
- }
398
- return Chat4AppMessageReceiveData;
399
- }());
400
- var Chat4AppMessageReceiveNotification = /** @class */ (function () {
401
- function Chat4AppMessageReceiveNotification() {
402
- }
403
- return Chat4AppMessageReceiveNotification;
404
- }());
405
- var ChatUserResponse4App = /** @class */ (function () {
406
- function ChatUserResponse4App() {
407
- }
408
- return ChatUserResponse4App;
409
- }());
410
- var ChatFilterRequest4App = /** @class */ (function () {
411
- function ChatFilterRequest4App() {
412
- }
413
- return ChatFilterRequest4App;
414
- }());
415
- var Chat4AppConfig = /** @class */ (function () {
416
- function Chat4AppConfig(endpoint) {
417
- this.endpoint = endpoint;
418
- }
419
- return Chat4AppConfig;
420
- }());
421
- var Chat4AppTranslate = /** @class */ (function () {
422
- function Chat4AppTranslate() {
423
- }
424
- return Chat4AppTranslate;
425
- }());
426
- exports.ChatStatus4App = void 0;
427
- (function (ChatStatus4App) {
428
- ChatStatus4App["CREATED"] = "CREATED";
429
- ChatStatus4App["CLOSED"] = "CLOSED";
430
- })(exports.ChatStatus4App || (exports.ChatStatus4App = {}));
431
- exports.ChatUserStatus4App = void 0;
432
- (function (ChatUserStatus4App) {
433
- ChatUserStatus4App["REMOVED"] = "REMOVED";
434
- })(exports.ChatUserStatus4App || (exports.ChatUserStatus4App = {}));
435
- exports.ChatFilterType = void 0;
436
- (function (ChatFilterType) {
437
- ChatFilterType[ChatFilterType["COUNT_NOT_READ"] = 1] = "COUNT_NOT_READ";
438
- ChatFilterType[ChatFilterType["LAST_MESSAGE"] = 2] = "LAST_MESSAGE";
31
+ var Chat4appClientAngularService = /** @class */ (function () {
32
+ function Chat4appClientAngularService(http) {
33
+ this.http = http;
34
+ this.chatServer = "";
35
+ this.chatUrl = "";
36
+ }
37
+ Chat4appClientAngularService.prototype.ngOnInit = function () {
38
+ };
39
+ Chat4appClientAngularService.prototype.config = function (chat4AppConfig) {
40
+ this.chatServer = chat4AppConfig.endpoint;
41
+ this.chatUrl = chat4AppConfig.endpoint + "/api/v1/";
42
+ };
43
+ Chat4appClientAngularService.prototype.init = function (securityChatToken, callback, chatCallback, connectionClientId) {
44
+ if (!this.chatServer || this.chatServer.trim().length == 0) {
45
+ throw new Error("Endpoint is empty");
46
+ }
47
+ if (!securityChatToken || securityChatToken.trim().length == 0) {
48
+ throw new Error("SecurityChatToken is empty");
49
+ }
50
+ this.setTokenChat4app(securityChatToken);
51
+ if (chatCallback && connectionClientId) {
52
+ this.connectWebsocket(chatCallback, connectionClientId);
53
+ }
54
+ callback(securityChatToken);
55
+ };
56
+ Chat4appClientAngularService.prototype.getChatUrlDownload = function (messageFileId) {
57
+ return this.chatUrl + "chatmessage/getFile?messageFileId=" + messageFileId + "&token=" + this.getBearerToken();
58
+ };
59
+ Chat4appClientAngularService.prototype.getMessageChat = function (chatId, fromId, toId) {
60
+ var url = this.chatUrl + "chatmessage/" + chatId + "/" + fromId + "/" + toId;
61
+ return this.http.get(url, {
62
+ headers: new i1.HttpHeaders().set('Authorization', this.getBearerToken())
63
+ });
64
+ };
65
+ Chat4appClientAngularService.prototype.getMessageChatByGrop = function (chatId, groupId, fromId) {
66
+ var url = this.chatUrl + "chatmessage/byGroup/" + chatId + "/" + groupId + "/" + fromId;
67
+ return this.http.get(url, {
68
+ headers: new i1.HttpHeaders().set('Authorization', this.getBearerToken())
69
+ });
70
+ };
71
+ Chat4appClientAngularService.prototype.addMessageChat = function (chatMessage4App) {
72
+ var url = this.chatUrl + "chatmessage/" + chatMessage4App.chatId;
73
+ return this.http.post(url, chatMessage4App, {
74
+ headers: new i1.HttpHeaders().set('Authorization', this.getBearerToken())
75
+ });
76
+ };
77
+ Chat4appClientAngularService.prototype.props = function (chatFilterRequest4App) {
78
+ var url = this.chatUrl + "chatmessage/props";
79
+ return this.http.post(url, chatFilterRequest4App, {
80
+ headers: new i1.HttpHeaders().set('Authorization', this.getBearerToken())
81
+ });
82
+ };
83
+ Chat4appClientAngularService.prototype.removeUsersChat = function (chatId, chatUsersId, chatUsersExternalId) {
84
+ var params = new Array();
85
+ if (chatUsersId && chatUsersId.length > 0) {
86
+ chatUsersId.forEach(function (cui) {
87
+ params.push("chatUserId=" + cui);
88
+ });
89
+ }
90
+ else if (chatUsersExternalId && chatUsersExternalId.length > 0) {
91
+ chatUsersExternalId.forEach(function (cuei) {
92
+ params.push("chatUserExternalId=" + cuei);
93
+ });
94
+ }
95
+ var url = this.chatUrl + "chatuser/" + chatId + "?" + params.join("&");
96
+ return this.http.delete(url, {
97
+ headers: new i1.HttpHeaders().set('Authorization', this.getBearerToken())
98
+ });
99
+ };
100
+ Chat4appClientAngularService.prototype.removeUserChat = function (chatId, chatUserId, chatUserExternalId) {
101
+ var param = "";
102
+ if (chatUserId) {
103
+ param = "chatUserId=" + chatUserId;
104
+ }
105
+ else {
106
+ param = "chatUserExternalId=" + chatUserExternalId;
107
+ }
108
+ var url = this.chatUrl + "chatuser/" + chatId + "?" + param;
109
+ return this.http.delete(url, {
110
+ headers: new i1.HttpHeaders().set('Authorization', this.getBearerToken())
111
+ });
112
+ };
113
+ Chat4appClientAngularService.prototype.updateUserChat = function (chatId, charUser4AppUpdate) {
114
+ var url = this.chatUrl + "chatuser/" + chatId;
115
+ return this.http.put(url, charUser4AppUpdate, {
116
+ headers: new i1.HttpHeaders().set('Authorization', this.getBearerToken())
117
+ });
118
+ };
119
+ Chat4appClientAngularService.prototype.createUserChat = function (chatId, chatUser4App) {
120
+ var url = this.chatUrl + "chatuser/" + chatId;
121
+ return this.http.post(url, chatUser4App, {
122
+ headers: new i1.HttpHeaders().set('Authorization', this.getBearerToken())
123
+ });
124
+ };
125
+ Chat4appClientAngularService.prototype.createUsersChat = function (chatId, chatUser4App) {
126
+ var url = this.chatUrl + "chatuser/users/" + chatId;
127
+ return this.http.post(url, chatUser4App, {
128
+ headers: new i1.HttpHeaders().set('Authorization', this.getBearerToken())
129
+ });
130
+ };
131
+ Chat4appClientAngularService.prototype.createChat = function (chat4app) {
132
+ var url = this.chatUrl + "chat";
133
+ return this.http.post(url, chat4app, {
134
+ headers: new i1.HttpHeaders().set('Authorization', this.getBearerToken())
135
+ });
136
+ };
137
+ Chat4appClientAngularService.prototype.createUpdateChat = function (chat4app) {
138
+ var url = this.chatUrl + "chat";
139
+ return this.http.put(url, chat4app, {
140
+ headers: new i1.HttpHeaders().set('Authorization', this.getBearerToken())
141
+ });
142
+ };
143
+ Chat4appClientAngularService.prototype.getLastMessageGroup = function (chatExternalId, groupId) {
144
+ var url = this.chatUrl + "chatmessage/lastMessageGroup?chatExternalId=" + chatExternalId + "&groupId=" + groupId;
145
+ return this.http.get(url, {
146
+ headers: new i1.HttpHeaders().set('Authorization', this.getBearerToken())
147
+ });
148
+ };
149
+ Chat4appClientAngularService.prototype.getLastMessage = function (chatExternalId, chatUserExternalId) {
150
+ var url = this.chatUrl + "chatmessage/lastMessage?chatExternalId=" + chatExternalId + "&chatUserExternalId=" + chatUserExternalId;
151
+ return this.http.get(url, {
152
+ headers: new i1.HttpHeaders().set('Authorization', this.getBearerToken())
153
+ });
154
+ };
155
+ Chat4appClientAngularService.prototype.countNotReadMessages = function (chatUserExternalId, chatExternalId, groupId) {
156
+ var url = this.chatUrl + "chatmessage/countNotReadMessages?chatUserExternalId=" + chatUserExternalId;
157
+ if (chatExternalId && chatExternalId.length > 0) {
158
+ url += "&chatExternalId=" + chatExternalId;
159
+ }
160
+ if (groupId && groupId.length > 0) {
161
+ url += "&groupId=" + groupId;
162
+ }
163
+ return this.http.get(url, {
164
+ headers: new i1.HttpHeaders().set('Authorization', this.getBearerToken())
165
+ });
166
+ };
167
+ Chat4appClientAngularService.prototype.getChatByExternalId = function (externalId) {
168
+ var url = this.chatUrl + "chat?externalId=" + externalId;
169
+ return this.http.get(url, {
170
+ headers: new i1.HttpHeaders().set('Authorization', this.getBearerToken())
171
+ });
172
+ };
173
+ Chat4appClientAngularService.prototype.readMessage = function (chatMessageId, toId) {
174
+ var url = this.chatUrl + "chatmessage/read/" + chatMessageId;
175
+ if (toId && toId.length > 0) {
176
+ url += "/" + toId;
177
+ }
178
+ return this.http.put(url, null, {
179
+ headers: new i1.HttpHeaders().set('Authorization', this.getBearerToken())
180
+ });
181
+ };
182
+ Chat4appClientAngularService.prototype.online = function (chatId, chatUserId) {
183
+ var url = this.chatUrl + "chatmessage/online/" + chatId + "/" + chatUserId;
184
+ return this.http.get(url, {
185
+ headers: new i1.HttpHeaders().set('Authorization', this.getBearerToken())
186
+ });
187
+ };
188
+ Chat4appClientAngularService.prototype.sendFile = function (chatId, fromId, toId, fileToUpload) {
189
+ var endpoint = this.chatUrl + "chatmessage/sendFile/" + chatId + "/" + fromId + "/" + toId;
190
+ var formData = new FormData();
191
+ formData.append('file', fileToUpload);
192
+ return this.http
193
+ .post(endpoint, formData, {
194
+ headers: new i1.HttpHeaders().set('Authorization', this.getBearerToken())
195
+ });
196
+ };
197
+ Chat4appClientAngularService.prototype.sendFileGroup = function (chatId, fromId, groupId, fileToUpload) {
198
+ var endpoint = this.chatUrl + "chatmessage/sendFileGroup/" + chatId + "/" + fromId + "/" + groupId;
199
+ var formData = new FormData();
200
+ formData.append('file', fileToUpload);
201
+ return this.http
202
+ .post(endpoint, formData, {
203
+ headers: new i1.HttpHeaders().set('Authorization', this.getBearerToken())
204
+ });
205
+ };
206
+ Chat4appClientAngularService.prototype.translateMessage = function (chatMessageId, languageTarget) {
207
+ var url = this.chatUrl + "chatmessage/translate/" + chatMessageId + "/" + languageTarget;
208
+ return this.http.get(url, {
209
+ headers: new i1.HttpHeaders().set('Authorization', this.getBearerToken())
210
+ });
211
+ };
212
+ Chat4appClientAngularService.prototype.startTyping = function (chatId, fromId, toId) {
213
+ var url = this.chatUrl + "chatmessage/startTyping/" + chatId + "/" + fromId + "/" + toId;
214
+ return this.http.put(url, null, {
215
+ headers: new i1.HttpHeaders().set('Authorization', this.getBearerToken())
216
+ });
217
+ };
218
+ Chat4appClientAngularService.prototype.startTypingGroup = function (chatId, fromId, groupId) {
219
+ var url = this.chatUrl + "chatmessage/startTypingGroup/" + chatId + "/" + fromId + "/" + groupId;
220
+ return this.http.put(url, null, {
221
+ headers: new i1.HttpHeaders().set('Authorization', this.getBearerToken())
222
+ });
223
+ };
224
+ Chat4appClientAngularService.prototype.stopTyping = function (chatId, fromId, toId) {
225
+ var url = this.chatUrl + "chatmessage/stopTyping/" + chatId + "/" + fromId + "/" + toId;
226
+ return this.http.put(url, null, {
227
+ headers: new i1.HttpHeaders().set('Authorization', this.getBearerToken())
228
+ });
229
+ };
230
+ Chat4appClientAngularService.prototype.stopTypingGroup = function (chatId, fromId, groupId) {
231
+ var url = this.chatUrl + "chatmessage/stopTypingGroup/" + chatId + "/" + fromId + "/" + groupId;
232
+ return this.http.put(url, null, {
233
+ headers: new i1.HttpHeaders().set('Authorization', this.getBearerToken())
234
+ });
235
+ };
236
+ /* Token */
237
+ Chat4appClientAngularService.prototype.getBearerToken = function () {
238
+ var ret = "Bearer " + window.sessionStorage.getItem("chat4AppSessionToken");
239
+ return ret;
240
+ };
241
+ Chat4appClientAngularService.prototype.setTokenChat4app = function (chat4AppSessionToken) {
242
+ window.sessionStorage.setItem("chat4AppSessionToken", chat4AppSessionToken);
243
+ };
244
+ /* Connection */
245
+ Chat4appClientAngularService.prototype.onMessageFirebaseReceived = function (data, chatCallback) {
246
+ //alert("onMessageReceived connectFirebase");
247
+ if (data.type == "msg") {
248
+ var chat4appMessage = new Chat4AppMessageReceive();
249
+ chat4appMessage.data.chatId = data.chatId;
250
+ chat4appMessage.data.chatMessageId = data.chatMessageId;
251
+ chat4appMessage.data.externalId = data.externalId;
252
+ chat4appMessage.data.fromId = data.fromId;
253
+ chat4appMessage.data.toId = data.toId;
254
+ chat4appMessage.data.dateHour = data.dateHour;
255
+ chat4appMessage.data.type = data.type;
256
+ chat4appMessage.notification.body = data.body;
257
+ if (data.fileId && data.fileId.length > 0) {
258
+ chat4appMessage.data.fileId = data.fileId;
259
+ chat4appMessage.data.fileName = data.fileName;
260
+ chat4appMessage.data.fileSize = data.fileSize;
261
+ chat4appMessage.data.fileType = data.fileType;
262
+ }
263
+ var datTmp = new Map();
264
+ for (var key in data) {
265
+ datTmp.set(key, data[key]);
266
+ }
267
+ chat4appMessage.data.all = datTmp;
268
+ chatCallback.onMessage(chat4appMessage);
269
+ }
270
+ else if ((data.type == "on" || data.type == "off")) {
271
+ var chat4appMessage = new Chat4AppMessageReceive();
272
+ chat4appMessage.data.chatId = data.chatId;
273
+ chat4appMessage.data.chatMessageId = data.chatMessageId;
274
+ chat4appMessage.data.externalId = data.externalId;
275
+ chat4appMessage.data.fromId = data.fromId;
276
+ chat4appMessage.data.toId = data.toId;
277
+ chat4appMessage.data.dateHour = data.dateHour;
278
+ chat4appMessage.data.type = data.type;
279
+ var datTmp = new Map();
280
+ for (var key in data) {
281
+ datTmp.set(key, data[key]);
282
+ }
283
+ chat4appMessage.data.all = datTmp;
284
+ chatCallback.onOffline(chat4appMessage);
285
+ }
286
+ else if (data.type == "read") {
287
+ var chat4appMessage = new Chat4AppMessageReceive();
288
+ chat4appMessage.data.chatId = data.chatId;
289
+ chat4appMessage.data.chatMessageId = data.chatMessageId;
290
+ chat4appMessage.data.externalId = data.externalId;
291
+ chat4appMessage.data.fromId = data.fromId;
292
+ chat4appMessage.data.toId = data.toId;
293
+ chat4appMessage.data.dateHour = data.dateHour;
294
+ chat4appMessage.data.type = data.type;
295
+ var datTmp = new Map();
296
+ for (var key in data) {
297
+ datTmp.set(key, data[key]);
298
+ }
299
+ chat4appMessage.data.all = datTmp;
300
+ chatCallback.onRead(chat4appMessage);
301
+ }
302
+ };
303
+ Chat4appClientAngularService.prototype.connectWebsocket = function (chatCallback, token) {
304
+ var _this = this;
305
+ this.disconnect();
306
+ var securityToken = this.getBearerToken();
307
+ this.sock = new SockJS__namespace(this.chatServer + '/stomp/gkz-stomp-endpoint?token=' + securityToken);
308
+ this.stompClient = Stomp__namespace.over(this.sock);
309
+ this.stompClient.debug = function (msg) {
310
+ //console.log(msg);
311
+ };
312
+ this.stompClient.connect({}, function (frame) {
313
+ //console.log(frame);
314
+ _this.stompClient.subscribe('/queue/' + token, function (msg) {
315
+ //console.log('mensagem', msg);
316
+ if (msg.command == "MESSAGE") {
317
+ //console.log(msg)
318
+ var msgObj = JSON.parse(msg.body);
319
+ var datTmp = new Map();
320
+ for (var key in msgObj.data) {
321
+ datTmp.set(key, msgObj.data[key]);
322
+ }
323
+ msgObj.data.all = datTmp;
324
+ if (msgObj.data.type == "msg") {
325
+ chatCallback.onMessage(msgObj);
326
+ }
327
+ else if ((msgObj.data.type == "on" || msgObj.data.type == "off")) {
328
+ chatCallback.onOffline(msgObj);
329
+ }
330
+ else if (msgObj.data.type == "read") {
331
+ chatCallback.onRead(msgObj);
332
+ }
333
+ //callback(msg.body);
334
+ // ichatcallback.forEach((iChat)=>{
335
+ // iChat.onMessage(JSON.parse(msg.body) );
336
+ // });
337
+ }
338
+ });
339
+ }, function (message) {
340
+ // check message for disconnect
341
+ //console.log("Disconnect");
342
+ setTimeout(function () {
343
+ _this.connectWebsocket(chatCallback, token);
344
+ }, 500);
345
+ });
346
+ };
347
+ Chat4appClientAngularService.prototype.disconnect = function () {
348
+ // console.log("disconnect")
349
+ try {
350
+ if (this.stompClient) {
351
+ this.stompClient.disconnect();
352
+ }
353
+ }
354
+ catch (e) {
355
+ console.log(e);
356
+ }
357
+ };
358
+ Chat4appClientAngularService.prototype.convertChat4AppMessageReceiveToChatMessage4App = function (msg) {
359
+ var message = new ChatMessage4App();
360
+ message.body = msg.notification.body;
361
+ message.chatId = msg.data.chatId;
362
+ message.fromId = msg.data.fromId;
363
+ message.toId = msg.data.toId;
364
+ message.dateHourIncluded = moment__namespace.utc(msg.data.dateHour, "DD-MM-YYYY hh:mm:ss").toDate();
365
+ message.id = msg.data.chatMessageId;
366
+ if (msg.data.fileId && msg.data.fileId.length > 0) {
367
+ var messageFile = new ChatMessageFile4App();
368
+ messageFile.id = msg.data.fileId;
369
+ messageFile.name = msg.data.fileName;
370
+ messageFile.size = msg.data.fileSize;
371
+ messageFile.type = msg.data.fileType;
372
+ message.chatMessageFile = messageFile;
373
+ }
374
+ return message;
375
+ };
376
+ return Chat4appClientAngularService;
377
+ }());
378
+ Chat4appClientAngularService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function Chat4appClientAngularService_Factory() { return new Chat4appClientAngularService(i0__namespace.ɵɵinject(i1__namespace.HttpClient)); }, token: Chat4appClientAngularService, providedIn: "root" });
379
+ Chat4appClientAngularService.decorators = [
380
+ { type: i0.Injectable, args: [{
381
+ providedIn: 'root'
382
+ },] }
383
+ ];
384
+ Chat4appClientAngularService.ctorParameters = function () { return [
385
+ { type: i1.HttpClient }
386
+ ]; };
387
+ var Chat4App = /** @class */ (function () {
388
+ function Chat4App() {
389
+ }
390
+ return Chat4App;
391
+ }());
392
+ var ChatUser4App = /** @class */ (function () {
393
+ function ChatUser4App() {
394
+ }
395
+ return ChatUser4App;
396
+ }());
397
+ var ChatMessage4App = /** @class */ (function () {
398
+ function ChatMessage4App() {
399
+ }
400
+ return ChatMessage4App;
401
+ }());
402
+ var ChatMessageFile4App = /** @class */ (function () {
403
+ function ChatMessageFile4App() {
404
+ }
405
+ return ChatMessageFile4App;
406
+ }());
407
+ var ChatMessageMeta4App = /** @class */ (function () {
408
+ function ChatMessageMeta4App() {
409
+ }
410
+ return ChatMessageMeta4App;
411
+ }());
412
+ var Chat4AppMessageReceive = /** @class */ (function () {
413
+ function Chat4AppMessageReceive() {
414
+ this.data = new Chat4AppMessageReceiveData();
415
+ this.notification = new Chat4AppMessageReceiveNotification();
416
+ }
417
+ return Chat4AppMessageReceive;
418
+ }());
419
+ var Chat4AppMessageReceiveData = /** @class */ (function () {
420
+ function Chat4AppMessageReceiveData() {
421
+ }
422
+ return Chat4AppMessageReceiveData;
423
+ }());
424
+ var Chat4AppMessageReceiveNotification = /** @class */ (function () {
425
+ function Chat4AppMessageReceiveNotification() {
426
+ }
427
+ return Chat4AppMessageReceiveNotification;
428
+ }());
429
+ var ChatUserResponse4App = /** @class */ (function () {
430
+ function ChatUserResponse4App() {
431
+ }
432
+ return ChatUserResponse4App;
433
+ }());
434
+ var ChatFilterRequest4App = /** @class */ (function () {
435
+ function ChatFilterRequest4App() {
436
+ }
437
+ return ChatFilterRequest4App;
438
+ }());
439
+ var Chat4AppConfig = /** @class */ (function () {
440
+ function Chat4AppConfig(endpoint) {
441
+ this.endpoint = endpoint;
442
+ }
443
+ return Chat4AppConfig;
444
+ }());
445
+ var Chat4AppTranslate = /** @class */ (function () {
446
+ function Chat4AppTranslate() {
447
+ }
448
+ return Chat4AppTranslate;
449
+ }());
450
+ exports.ChatStatus4App = void 0;
451
+ (function (ChatStatus4App) {
452
+ ChatStatus4App["CREATED"] = "CREATED";
453
+ ChatStatus4App["CLOSED"] = "CLOSED";
454
+ })(exports.ChatStatus4App || (exports.ChatStatus4App = {}));
455
+ exports.ChatUserStatus4App = void 0;
456
+ (function (ChatUserStatus4App) {
457
+ ChatUserStatus4App["REMOVED"] = "REMOVED";
458
+ })(exports.ChatUserStatus4App || (exports.ChatUserStatus4App = {}));
459
+ exports.ChatFilterType = void 0;
460
+ (function (ChatFilterType) {
461
+ ChatFilterType[ChatFilterType["COUNT_NOT_READ"] = 1] = "COUNT_NOT_READ";
462
+ ChatFilterType[ChatFilterType["LAST_MESSAGE"] = 2] = "LAST_MESSAGE";
439
463
  })(exports.ChatFilterType || (exports.ChatFilterType = {}));
440
464
 
441
- var Chat4appClientAngularComponent = /** @class */ (function () {
442
- function Chat4appClientAngularComponent() {
443
- }
444
- Chat4appClientAngularComponent.prototype.ngOnInit = function () {
445
- };
446
- return Chat4appClientAngularComponent;
447
- }());
448
- Chat4appClientAngularComponent.decorators = [
449
- { type: i0.Component, args: [{
450
- selector: 'lib-chat4app-client-angular',
451
- template: "\n <p>\n chat4app-client-angular works!\n </p>\n "
452
- },] }
453
- ];
465
+ var Chat4appClientAngularComponent = /** @class */ (function () {
466
+ function Chat4appClientAngularComponent() {
467
+ }
468
+ Chat4appClientAngularComponent.prototype.ngOnInit = function () {
469
+ };
470
+ return Chat4appClientAngularComponent;
471
+ }());
472
+ Chat4appClientAngularComponent.decorators = [
473
+ { type: i0.Component, args: [{
474
+ selector: 'lib-chat4app-client-angular',
475
+ template: "\n <p>\n chat4app-client-angular works!\n </p>\n "
476
+ },] }
477
+ ];
454
478
  Chat4appClientAngularComponent.ctorParameters = function () { return []; };
455
479
 
456
- var Chat4appClientAngularModule = /** @class */ (function () {
457
- function Chat4appClientAngularModule() {
458
- }
459
- return Chat4appClientAngularModule;
460
- }());
461
- Chat4appClientAngularModule.decorators = [
462
- { type: i0.NgModule, args: [{
463
- declarations: [Chat4appClientAngularComponent],
464
- imports: [],
465
- exports: [Chat4appClientAngularComponent]
466
- },] }
480
+ var Chat4appClientAngularModule = /** @class */ (function () {
481
+ function Chat4appClientAngularModule() {
482
+ }
483
+ return Chat4appClientAngularModule;
484
+ }());
485
+ Chat4appClientAngularModule.decorators = [
486
+ { type: i0.NgModule, args: [{
487
+ declarations: [Chat4appClientAngularComponent],
488
+ imports: [],
489
+ exports: [Chat4appClientAngularComponent]
490
+ },] }
467
491
  ];
468
492
 
469
- /*
470
- * Public API Surface of chat4app-client-angular
493
+ /*
494
+ * Public API Surface of chat4app-client-angular
471
495
  */
472
496
 
473
- /**
474
- * Generated bundle index. Do not edit.
497
+ /**
498
+ * Generated bundle index. Do not edit.
475
499
  */
476
500
 
477
501
  exports.Chat4App = Chat4App;