chat4app-client-angular 0.0.4 → 0.0.6

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,419 +28,431 @@
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;
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
- /* Token */
207
- Chat4appClientAngularService.prototype.getBearerToken = function () {
208
- var ret = "Bearer " + window.sessionStorage.getItem("chat4AppSessionToken");
209
- return ret;
210
- };
211
- Chat4appClientAngularService.prototype.setTokenChat4app = function (chat4AppSessionToken) {
212
- window.sessionStorage.setItem("chat4AppSessionToken", chat4AppSessionToken);
213
- };
214
- /* Connection */
215
- Chat4appClientAngularService.prototype.onMessageFirebaseReceived = function (data, chatCallback) {
216
- //alert("onMessageReceived connectFirebase");
217
- if (data.type == "msg") {
218
- var chat4appMessage = new Chat4AppMessageReceive();
219
- chat4appMessage.data.chatId = data.chatId;
220
- chat4appMessage.data.chatMessageId = data.chatMessageId;
221
- chat4appMessage.data.externalId = data.externalId;
222
- chat4appMessage.data.fromId = data.fromId;
223
- chat4appMessage.data.toId = data.toId;
224
- chat4appMessage.data.dateHour = data.dateHour;
225
- chat4appMessage.data.type = data.type;
226
- chat4appMessage.notification.body = data.body;
227
- if (data.fileId && data.fileId.length > 0) {
228
- chat4appMessage.data.fileId = data.fileId;
229
- chat4appMessage.data.fileName = data.fileName;
230
- chat4appMessage.data.fileSize = data.fileSize;
231
- chat4appMessage.data.fileType = data.fileType;
232
- }
233
- var datTmp = new Map();
234
- for (var key in data) {
235
- datTmp.set(key, data[key]);
236
- }
237
- chat4appMessage.data.all = datTmp;
238
- chatCallback.onMessage(chat4appMessage);
239
- }
240
- else if ((data.type == "on" || data.type == "off")) {
241
- var chat4appMessage = new Chat4AppMessageReceive();
242
- chat4appMessage.data.chatId = data.chatId;
243
- chat4appMessage.data.chatMessageId = data.chatMessageId;
244
- chat4appMessage.data.externalId = data.externalId;
245
- chat4appMessage.data.fromId = data.fromId;
246
- chat4appMessage.data.toId = data.toId;
247
- chat4appMessage.data.dateHour = data.dateHour;
248
- chat4appMessage.data.type = data.type;
249
- var datTmp = new Map();
250
- for (var key in data) {
251
- datTmp.set(key, data[key]);
252
- }
253
- chat4appMessage.data.all = datTmp;
254
- chatCallback.onOffline(chat4appMessage);
255
- }
256
- };
257
- Chat4appClientAngularService.prototype.connectWebsocket = function (chatCallback, token) {
258
- var _this = this;
259
- this.disconnect();
260
- var securityToken = this.getBearerToken();
261
- this.sock = new SockJS__namespace(this.chatServer + '/stomp/gkz-stomp-endpoint?token=' + securityToken);
262
- this.stompClient = Stomp__namespace.over(this.sock);
263
- this.stompClient.debug = function (msg) {
264
- //console.log(msg);
265
- };
266
- this.stompClient.connect({}, function (frame) {
267
- //console.log(frame);
268
- _this.stompClient.subscribe('/queue/' + token, function (msg) {
269
- //console.log('mensagem', msg);
270
- if (msg.command == "MESSAGE") {
271
- //console.log(msg)
272
- var msgObj = JSON.parse(msg.body);
273
- var datTmp = new Map();
274
- for (var key in msgObj.data) {
275
- datTmp.set(key, msgObj.data[key]);
276
- }
277
- msgObj.data.all = datTmp;
278
- if (msgObj.data.type == "msg") {
279
- chatCallback.onMessage(msgObj);
280
- }
281
- else if ((msgObj.data.type == "on" || msgObj.data.type == "off")) {
282
- chatCallback.onOffline(msgObj);
283
- }
284
- //callback(msg.body);
285
- // ichatcallback.forEach((iChat)=>{
286
- // iChat.onMessage(JSON.parse(msg.body) );
287
- // });
288
- }
289
- });
290
- }, function (message) {
291
- // check message for disconnect
292
- //console.log("Disconnect");
293
- setTimeout(function () {
294
- _this.connectWebsocket(chatCallback, token);
295
- }, 500);
296
- });
297
- };
298
- Chat4appClientAngularService.prototype.disconnect = function () {
299
- // console.log("disconnect")
300
- try {
301
- if (this.stompClient) {
302
- this.stompClient.disconnect();
303
- }
304
- }
305
- catch (e) {
306
- console.log(e);
307
- }
308
- };
309
- Chat4appClientAngularService.prototype.convertChat4AppMessageReceiveToChatMessage4App = function (msg) {
310
- var message = new ChatMessage4App();
311
- message.body = msg.notification.body;
312
- message.chatId = msg.data.chatId;
313
- message.fromId = msg.data.fromId;
314
- message.toId = msg.data.toId;
315
- message.dateHourIncluded = moment__namespace.utc(msg.data.dateHour, "DD-MM-YYYY hh:mm:ss").toDate();
316
- if (msg.data.fileId && msg.data.fileId.length > 0) {
317
- var messageFile = new ChatMessageFile4App();
318
- messageFile.id = msg.data.fileId;
319
- messageFile.name = msg.data.fileName;
320
- messageFile.size = msg.data.fileSize;
321
- messageFile.type = msg.data.fileType;
322
- message.chatMessageFile = messageFile;
323
- }
324
- return message;
325
- };
326
- return Chat4appClientAngularService;
327
- }());
328
- Chat4appClientAngularService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function Chat4appClientAngularService_Factory() { return new Chat4appClientAngularService(i0__namespace.ɵɵinject(i1__namespace.HttpClient)); }, token: Chat4appClientAngularService, providedIn: "root" });
329
- Chat4appClientAngularService.decorators = [
330
- { type: i0.Injectable, args: [{
331
- providedIn: 'root'
332
- },] }
333
- ];
334
- Chat4appClientAngularService.ctorParameters = function () { return [
335
- { type: i1.HttpClient }
336
- ]; };
337
- var Chat4App = /** @class */ (function () {
338
- function Chat4App() {
339
- }
340
- return Chat4App;
341
- }());
342
- var ChatUser4App = /** @class */ (function () {
343
- function ChatUser4App() {
344
- }
345
- return ChatUser4App;
346
- }());
347
- var ChatMessage4App = /** @class */ (function () {
348
- function ChatMessage4App() {
349
- }
350
- return ChatMessage4App;
351
- }());
352
- var ChatMessageFile4App = /** @class */ (function () {
353
- function ChatMessageFile4App() {
354
- }
355
- return ChatMessageFile4App;
356
- }());
357
- var ChatMessageMeta4App = /** @class */ (function () {
358
- function ChatMessageMeta4App() {
359
- }
360
- return ChatMessageMeta4App;
361
- }());
362
- var Chat4AppMessageReceive = /** @class */ (function () {
363
- function Chat4AppMessageReceive() {
364
- this.data = new Chat4AppMessageReceiveData();
365
- this.notification = new Chat4AppMessageReceiveNotification();
366
- }
367
- return Chat4AppMessageReceive;
368
- }());
369
- var Chat4AppMessageReceiveData = /** @class */ (function () {
370
- function Chat4AppMessageReceiveData() {
371
- }
372
- return Chat4AppMessageReceiveData;
373
- }());
374
- var Chat4AppMessageReceiveNotification = /** @class */ (function () {
375
- function Chat4AppMessageReceiveNotification() {
376
- }
377
- return Chat4AppMessageReceiveNotification;
378
- }());
379
- var ChatUserResponse4App = /** @class */ (function () {
380
- function ChatUserResponse4App() {
381
- }
382
- return ChatUserResponse4App;
383
- }());
384
- var ChatFilterRequest4App = /** @class */ (function () {
385
- function ChatFilterRequest4App() {
386
- }
387
- return ChatFilterRequest4App;
388
- }());
389
- var Chat4AppConfig = /** @class */ (function () {
390
- function Chat4AppConfig(endpoint) {
391
- this.endpoint = endpoint;
392
- }
393
- return Chat4AppConfig;
394
- }());
395
- exports.ChatStatus4App = void 0;
396
- (function (ChatStatus4App) {
397
- ChatStatus4App["CREATED"] = "CREATED";
398
- ChatStatus4App["CLOSED"] = "CLOSED";
399
- })(exports.ChatStatus4App || (exports.ChatStatus4App = {}));
400
- exports.ChatUserStatus4App = void 0;
401
- (function (ChatUserStatus4App) {
402
- ChatUserStatus4App["REMOVED"] = "REMOVED";
403
- })(exports.ChatUserStatus4App || (exports.ChatUserStatus4App = {}));
404
- exports.ChatFilterType = void 0;
405
- (function (ChatFilterType) {
406
- ChatFilterType[ChatFilterType["COUNT_NOT_READ"] = 1] = "COUNT_NOT_READ";
407
- 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;
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
+ };
263
+ Chat4appClientAngularService.prototype.connectWebsocket = function (chatCallback, token) {
264
+ var _this = this;
265
+ this.disconnect();
266
+ var securityToken = this.getBearerToken();
267
+ this.sock = new SockJS__namespace(this.chatServer + '/stomp/gkz-stomp-endpoint?token=' + securityToken);
268
+ this.stompClient = Stomp__namespace.over(this.sock);
269
+ this.stompClient.debug = function (msg) {
270
+ //console.log(msg);
271
+ };
272
+ this.stompClient.connect({}, function (frame) {
273
+ //console.log(frame);
274
+ _this.stompClient.subscribe('/queue/' + token, function (msg) {
275
+ //console.log('mensagem', msg);
276
+ if (msg.command == "MESSAGE") {
277
+ //console.log(msg)
278
+ var msgObj = JSON.parse(msg.body);
279
+ var datTmp = new Map();
280
+ for (var key in msgObj.data) {
281
+ datTmp.set(key, msgObj.data[key]);
282
+ }
283
+ msgObj.data.all = datTmp;
284
+ if (msgObj.data.type == "msg") {
285
+ chatCallback.onMessage(msgObj);
286
+ }
287
+ else if ((msgObj.data.type == "on" || msgObj.data.type == "off")) {
288
+ chatCallback.onOffline(msgObj);
289
+ }
290
+ //callback(msg.body);
291
+ // ichatcallback.forEach((iChat)=>{
292
+ // iChat.onMessage(JSON.parse(msg.body) );
293
+ // });
294
+ }
295
+ });
296
+ }, function (message) {
297
+ // check message for disconnect
298
+ //console.log("Disconnect");
299
+ setTimeout(function () {
300
+ _this.connectWebsocket(chatCallback, token);
301
+ }, 500);
302
+ });
303
+ };
304
+ Chat4appClientAngularService.prototype.disconnect = function () {
305
+ // console.log("disconnect")
306
+ try {
307
+ if (this.stompClient) {
308
+ this.stompClient.disconnect();
309
+ }
310
+ }
311
+ catch (e) {
312
+ console.log(e);
313
+ }
314
+ };
315
+ Chat4appClientAngularService.prototype.convertChat4AppMessageReceiveToChatMessage4App = function (msg) {
316
+ var message = new ChatMessage4App();
317
+ message.body = msg.notification.body;
318
+ message.chatId = msg.data.chatId;
319
+ message.fromId = msg.data.fromId;
320
+ message.toId = msg.data.toId;
321
+ message.dateHourIncluded = moment__namespace.utc(msg.data.dateHour, "DD-MM-YYYY hh:mm:ss").toDate();
322
+ message.id = msg.data.chatMessageId;
323
+ if (msg.data.fileId && msg.data.fileId.length > 0) {
324
+ var messageFile = new ChatMessageFile4App();
325
+ messageFile.id = msg.data.fileId;
326
+ messageFile.name = msg.data.fileName;
327
+ messageFile.size = msg.data.fileSize;
328
+ messageFile.type = msg.data.fileType;
329
+ message.chatMessageFile = messageFile;
330
+ }
331
+ return message;
332
+ };
333
+ return Chat4appClientAngularService;
334
+ }());
335
+ Chat4appClientAngularService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function Chat4appClientAngularService_Factory() { return new Chat4appClientAngularService(i0__namespace.ɵɵinject(i1__namespace.HttpClient)); }, token: Chat4appClientAngularService, providedIn: "root" });
336
+ Chat4appClientAngularService.decorators = [
337
+ { type: i0.Injectable, args: [{
338
+ providedIn: 'root'
339
+ },] }
340
+ ];
341
+ Chat4appClientAngularService.ctorParameters = function () { return [
342
+ { type: i1.HttpClient }
343
+ ]; };
344
+ var Chat4App = /** @class */ (function () {
345
+ function Chat4App() {
346
+ }
347
+ return Chat4App;
348
+ }());
349
+ var ChatUser4App = /** @class */ (function () {
350
+ function ChatUser4App() {
351
+ }
352
+ return ChatUser4App;
353
+ }());
354
+ var ChatMessage4App = /** @class */ (function () {
355
+ function ChatMessage4App() {
356
+ }
357
+ return ChatMessage4App;
358
+ }());
359
+ var ChatMessageFile4App = /** @class */ (function () {
360
+ function ChatMessageFile4App() {
361
+ }
362
+ return ChatMessageFile4App;
363
+ }());
364
+ var ChatMessageMeta4App = /** @class */ (function () {
365
+ function ChatMessageMeta4App() {
366
+ }
367
+ return ChatMessageMeta4App;
368
+ }());
369
+ var Chat4AppMessageReceive = /** @class */ (function () {
370
+ function Chat4AppMessageReceive() {
371
+ this.data = new Chat4AppMessageReceiveData();
372
+ this.notification = new Chat4AppMessageReceiveNotification();
373
+ }
374
+ return Chat4AppMessageReceive;
375
+ }());
376
+ var Chat4AppMessageReceiveData = /** @class */ (function () {
377
+ function Chat4AppMessageReceiveData() {
378
+ }
379
+ return Chat4AppMessageReceiveData;
380
+ }());
381
+ var Chat4AppMessageReceiveNotification = /** @class */ (function () {
382
+ function Chat4AppMessageReceiveNotification() {
383
+ }
384
+ return Chat4AppMessageReceiveNotification;
385
+ }());
386
+ var ChatUserResponse4App = /** @class */ (function () {
387
+ function ChatUserResponse4App() {
388
+ }
389
+ return ChatUserResponse4App;
390
+ }());
391
+ var ChatFilterRequest4App = /** @class */ (function () {
392
+ function ChatFilterRequest4App() {
393
+ }
394
+ return ChatFilterRequest4App;
395
+ }());
396
+ var Chat4AppConfig = /** @class */ (function () {
397
+ function Chat4AppConfig(endpoint) {
398
+ this.endpoint = endpoint;
399
+ }
400
+ return Chat4AppConfig;
401
+ }());
402
+ var Chat4AppTranslate = /** @class */ (function () {
403
+ function Chat4AppTranslate() {
404
+ }
405
+ return Chat4AppTranslate;
406
+ }());
407
+ exports.ChatStatus4App = void 0;
408
+ (function (ChatStatus4App) {
409
+ ChatStatus4App["CREATED"] = "CREATED";
410
+ ChatStatus4App["CLOSED"] = "CLOSED";
411
+ })(exports.ChatStatus4App || (exports.ChatStatus4App = {}));
412
+ exports.ChatUserStatus4App = void 0;
413
+ (function (ChatUserStatus4App) {
414
+ ChatUserStatus4App["REMOVED"] = "REMOVED";
415
+ })(exports.ChatUserStatus4App || (exports.ChatUserStatus4App = {}));
416
+ exports.ChatFilterType = void 0;
417
+ (function (ChatFilterType) {
418
+ ChatFilterType[ChatFilterType["COUNT_NOT_READ"] = 1] = "COUNT_NOT_READ";
419
+ ChatFilterType[ChatFilterType["LAST_MESSAGE"] = 2] = "LAST_MESSAGE";
408
420
  })(exports.ChatFilterType || (exports.ChatFilterType = {}));
409
421
 
410
- var Chat4appClientAngularComponent = /** @class */ (function () {
411
- function Chat4appClientAngularComponent() {
412
- }
413
- Chat4appClientAngularComponent.prototype.ngOnInit = function () {
414
- };
415
- return Chat4appClientAngularComponent;
416
- }());
417
- Chat4appClientAngularComponent.decorators = [
418
- { type: i0.Component, args: [{
419
- selector: 'lib-chat4app-client-angular',
420
- template: "\n <p>\n chat4app-client-angular works!\n </p>\n "
421
- },] }
422
- ];
422
+ var Chat4appClientAngularComponent = /** @class */ (function () {
423
+ function Chat4appClientAngularComponent() {
424
+ }
425
+ Chat4appClientAngularComponent.prototype.ngOnInit = function () {
426
+ };
427
+ return Chat4appClientAngularComponent;
428
+ }());
429
+ Chat4appClientAngularComponent.decorators = [
430
+ { type: i0.Component, args: [{
431
+ selector: 'lib-chat4app-client-angular',
432
+ template: "\n <p>\n chat4app-client-angular works!\n </p>\n "
433
+ },] }
434
+ ];
423
435
  Chat4appClientAngularComponent.ctorParameters = function () { return []; };
424
436
 
425
- var Chat4appClientAngularModule = /** @class */ (function () {
426
- function Chat4appClientAngularModule() {
427
- }
428
- return Chat4appClientAngularModule;
429
- }());
430
- Chat4appClientAngularModule.decorators = [
431
- { type: i0.NgModule, args: [{
432
- declarations: [Chat4appClientAngularComponent],
433
- imports: [],
434
- exports: [Chat4appClientAngularComponent]
435
- },] }
437
+ var Chat4appClientAngularModule = /** @class */ (function () {
438
+ function Chat4appClientAngularModule() {
439
+ }
440
+ return Chat4appClientAngularModule;
441
+ }());
442
+ Chat4appClientAngularModule.decorators = [
443
+ { type: i0.NgModule, args: [{
444
+ declarations: [Chat4appClientAngularComponent],
445
+ imports: [],
446
+ exports: [Chat4appClientAngularComponent]
447
+ },] }
436
448
  ];
437
449
 
438
- /*
439
- * Public API Surface of chat4app-client-angular
450
+ /*
451
+ * Public API Surface of chat4app-client-angular
440
452
  */
441
453
 
442
- /**
443
- * Generated bundle index. Do not edit.
454
+ /**
455
+ * Generated bundle index. Do not edit.
444
456
  */
445
457
 
446
458
  exports.Chat4App = Chat4App;
@@ -448,6 +460,7 @@
448
460
  exports.Chat4AppMessageReceive = Chat4AppMessageReceive;
449
461
  exports.Chat4AppMessageReceiveData = Chat4AppMessageReceiveData;
450
462
  exports.Chat4AppMessageReceiveNotification = Chat4AppMessageReceiveNotification;
463
+ exports.Chat4AppTranslate = Chat4AppTranslate;
451
464
  exports.Chat4appClientAngularComponent = Chat4appClientAngularComponent;
452
465
  exports.Chat4appClientAngularModule = Chat4appClientAngularModule;
453
466
  exports.Chat4appClientAngularService = Chat4appClientAngularService;