repo_name
string
dataset
string
owner
string
lang
string
func_name
string
code
string
docstring
string
url
string
sha
string
design-studio
github_2023
Tiledesk
typescript
DepartmentService.updateDeptStatus
public updateDeptStatus(dept_id: string, status: number) { const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json', 'Authorization': this.tiledeskToken }) }; const url = this.URL_TILEDESK_DEPARTMENTS + dept_id; this.logger.log('UPDATE DEPT STATUS - URL ', url); const body = { 'status': status }; this.logger.log('[DEPTS-SERV] UPDATE DEPT STATUS - BODY ', body); return this.httpClient .patch(url, JSON.stringify(body), httpOptions) }
/** * UPDATE DEPARTMENT STATUS * @param dept_id * @param status */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/department.service.ts#L305-L322
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
DepartmentService.updateDefaultDeptOnlineMsg
public updateDefaultDeptOnlineMsg(id: string, onlineMsg: string) { const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json', 'Authorization': this.tiledeskToken }) }; const url = this.URL_TILEDESK_DEPARTMENTS + id; this.logger.log('[DEPTS-SERV] UPDATE DEFAULT DEPARTMENT ONLINE MSG URL ', url); const body = { 'online_msg': onlineMsg }; this.logger.log('[DEPTS-SERV] - UPDATE DEFAULT DEPARTMENT ONLINE MSG - BODY ', body); return this.httpClient .put(url, JSON.stringify(body), httpOptions) // .map((res) => res.json()); }
// --------------------------------------------------------------
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/department.service.ts#L327-L346
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
DepartmentService.updateDefaultDeptOfflineMsg
public updateDefaultDeptOfflineMsg(id: string, offlineMsg: string) { const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json', 'Authorization': this.tiledeskToken }) }; const url = this.URL_TILEDESK_DEPARTMENTS + id; this.logger.log('[DEPTS-SERV] - UPDATE DEFAULT DEPARTMENT OFFLINE MSG - URL ', url); const body = { 'offline_msg': offlineMsg }; this.logger.log('[DEPTS-SERV] - UPDATE DEFAULT DEPARTMENT OFFLINE MSG - BODY ', body); return this.httpClient .put(url, JSON.stringify(body), httpOptions) }
// --------------------------------------------------------------
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/department.service.ts#L351-L368
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
DepartmentService.testChat21AssignesFunction
public testChat21AssignesFunction(id: string): Observable<Department[]> { const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json', 'Authorization': this.tiledeskToken }) }; let url = this.URL_TILEDESK_DEPARTMENTS; // + '?nobot=' + true url += id + '/operators'; this.logger.log('-- -- -- URL FOR TEST CHAT21 FUNC ', url); const headers = new Headers(); headers.append('Content-Type', 'application/json'); headers.append('Authorization', this.tiledeskToken); // this.logger.log('TOKEN TO COPY ', this.TOKEN) return this.httpClient .get<Department[]>(url, httpOptions) }
// ------------------------------------
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/department.service.ts#L377-L398
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
FaqKbService.getFaqKbByProjectId
public getFaqKbByProjectId(): Observable<Chatbot[]> { const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json', 'Authorization': this.tiledeskToken }) }; const url = this.FAQKB_URL; this.logger.log('[FAQ-KB.SERV] - GET FAQ-KB BY PROJECT ID - URL', url); return this._httpClient.get<Chatbot[]>(url, httpOptions).pipe(map((response) => { const data = response; // Does something on data.data this.logger.log('[FAQ-KB.SERV] GET FAQ-KB BY PROJECT ID - data', data); data.forEach(d => { if (d.description) { let stripHere = 20; d['truncated_desc'] = d.description.substring(0, stripHere) + '...'; } }); // return the modified data: return data; }) ); }
/** * READ (GET ALL FAQKB WITH THE CURRENT PROJECT ID) * NOTE: chat21-api-node.js READ THE CURRENT PROJECT ID FROM THE URL SO IT SO NO LONGER NECESSARY TO PASS THE PROJECT * ID AS PARAMETER */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/faq-kb.service.ts#L47-L73
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
FaqKbService.getAllBotByProjectId
public getAllBotByProjectId(): Observable<FaqKb[]> { const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json', 'Authorization': this.tiledeskToken }) }; const url = this.FAQKB_URL + '?all=true'; this.logger.log('[FAQ-KB.SERV] - GET *ALL* FAQ-KB BY PROJECT ID - URL', url); return this._httpClient.get<FaqKb[]>(url, httpOptions).pipe( map( (response) => { const data = response; // Does something on data.data this.logger.log('[FAQ-KB.SERV] GET *ALL* FAQ-KB BY PROJECT ID - data', data); data.forEach(d => { this.logger.log('[FAQ-KB.SERV] - GET *ALL* FAQ-KB BY PROJECT ID URL data d', d); if (d.description) { let stripHere = 20; d['truncated_desc'] = d.description.substring(0, stripHere) + '...'; } }); // return the modified data: return data; }) ); }
// ------------------------------------------------------------
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/faq-kb.service.ts#L78-L108
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
FaqKbService.updateFaqKb
public updateFaqKb(chatbot: Chatbot) { const httpOptions = { headers: new HttpHeaders({ 'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization': this.tiledeskToken }) }; let url = this.FAQKB_URL + chatbot._id; this.logger.log('update BOT - URL ', url); // if (chatbot.type === 'internal' || chatbot.type === 'tilebot') { // chatbot['webhook_enabled'] = webkookisenalbled; // chatbot['webhook_url'] = webhookurl // chatbot['language'] = resbotlanguage // } this.logger.log('[FAQ-KB.SERV] updateFaqKb - BODY ', chatbot); return this._httpClient.put(url, JSON.stringify(chatbot), httpOptions) }
/** * UPDATE (PUT) * @param id * @param fullName */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/faq-kb.service.ts#L128-L147
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
FaqKbService.updateFaqKbAgentsAvailable
public updateFaqKbAgentsAvailable(id: string, agents_available: boolean) { const httpOptions = { headers: new HttpHeaders({ 'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization': this.tiledeskToken }) }; let url = this.FAQKB_URL + id; this.logger.log('update BOT - URL ', url); let body = { 'agents_available': agents_available, }; this.logger.log('[FAQ-KB.SERV] updateFaqKb - BODY ', body); return this._httpClient.put(url, JSON.stringify(body), httpOptions) }
/** * UPDATE (PUT) * @param id * @param fullName */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/faq-kb.service.ts#L154-L170
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
FaqKbService.updateFaqKbLanguage
updateFaqKbLanguage (id: string, chatbotlanguage: string) { const httpOptions = { headers: new HttpHeaders({ 'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization': this.tiledeskToken }) }; let url = this.FAQKB_URL + id + '/language/' + chatbotlanguage; this.logger.log('update BOT LANG - URL ', url); const body = { 'language': chatbotlanguage }; this.logger.log('[FAQ-KB.SERV] update BOT LANG - BODY ', body); return this._httpClient.put(url, JSON.stringify(body), httpOptions) }
// PROJECT_ID/faq_kb/FAQ_KB_ID/language/LANGUAGE
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/faq-kb.service.ts#L175-L193
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
FaqKbService.publish
public publish(chatbot: Chatbot) { const httpOptions = { headers: new HttpHeaders({ 'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization': this.tiledeskToken }) } let url = this.FAQKB_URL + chatbot._id + "/publish"; this.logger.log('publish BOT - URL ', url); return this._httpClient.put(url, null, httpOptions) }
// http://localhost:3000/63ea8812b48b3e22c9372f05/faq_kb/63ea8820b48b3e22c9372f83/publish
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/faq-kb.service.ts#L227-L241
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
FaqService.exsportFaqsToCsv
public exsportFaqsToCsv(id_faq_kb: string) { const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json', 'Authorization': this.tiledeskToken, }), responseType: 'text' as 'json' }; const url = this.EXPORT_FAQ_TO_CSV_URL + '?id_faq_kb=' + id_faq_kb; this.logger.log('[FAQ-SERV] - EXPORT FAQS AS CSV - URL', url); return this._httpClient.get(url, httpOptions) }
/** * EXPORT FAQS AS CSV * @param id_faq_kb * @returns */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/faq.service.ts#L53-L66
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
FaqService.importChatbotFromJSONFromScratch
public importChatbotFromJSONFromScratch(jsonfile) { const options = { headers: new HttpHeaders({ 'Accept': 'application/json', 'Authorization': this.tiledeskToken }) }; const url = this.SERVER_BASE_PATH + this.project_id + "/faq_kb/importjson/null/?create=true" this.logger.log('[FAQ-SERV] UPLOAD FAQS CSV - URL ', url); return this._httpClient.post(url, jsonfile, options) }
// ( POST ../PROJECT_ID/bots/importjson/null/?create=true)
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/faq.service.ts#L98-L111
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
FaqService.addIntent
public addIntent(intent: any) { const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json', 'Authorization': this.tiledeskToken }) }; const url = this.FAQ_URL; this.logger.log('[FAQ-SERV] ADD FAQ - PUT URL ', url); this.logger.log('[FAQ-SERV] ADD FAQ - POST BODY ', intent); return this._httpClient.post(url, JSON.stringify(intent), httpOptions) }
/** * CREATE FAQ (POST) * @param intent * @returns */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/faq.service.ts#L139-L150
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
FaqService.updateIntent
public updateIntent(intent: any) { const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json', 'Authorization': this.tiledeskToken }) }; this.logger.log('[FAQ-SERV] UPDATE FAQ - ID ', intent._id); let url = this.FAQ_URL + intent._id; if(intent.intent_id) url = this.FAQ_URL + 'intentId' + intent.intent_id; this.logger.log('[FAQ-SERV] UPDATE FAQ - PUT URL ', url); this.logger.log('----------->>>', intent); this.logger.log('[FAQ-SERV] UPDATE FAQ - PUT REQUEST BODY ', intent); return this._httpClient.put(url, JSON.stringify(intent), httpOptions); }
/** * UPDATE FAQ (PUT) * @param intent * @returns */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/faq.service.ts#L157-L173
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
FaqService.createTrainBotAnswer
public createTrainBotAnswer(question: string, answer: string, id_faq_kb: string) { const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json', 'Authorization': this.tiledeskToken }) }; const url = this.FAQ_URL; this.logger.log('[FAQ-SERV] CREATE TRAIN BOT FAQ - URL ', url); const body = { 'question': question, 'answer': answer, 'id_faq_kb': id_faq_kb }; this.logger.log('[FAQ-SERV] CREATE TRAIN BOT FAQ - BODY ', body); return this._httpClient.post(url, JSON.stringify(body), httpOptions) }
/** * CREATE TRAIN BOT ANSWER (POST) * @param question * @param answer * @param id_faq_kb * @returns */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/faq.service.ts#L183-L198
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
FaqService.deleteFaq
public deleteFaq(id: string, intent_id?: string, id_faq_kb?: string) { const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json', 'Authorization': this.tiledeskToken }) }; let url = this.FAQ_URL + id; if(intent_id) url = this.FAQ_URL + 'intentId' + intent_id + '?id_faq_kb=' + id_faq_kb; // if(intent_id) url = this.FAQ_URL + 'intentId' + intent_id; this.logger.log('[FAQ-SERV] DELETE FAQ URL ', url); return this._httpClient.delete(url, httpOptions) }
/** * DELETE FAQ (DELETE) * @param id * @returns */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/faq.service.ts#L205-L217
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
FaqService.updateTrainBotFaq
public updateTrainBotFaq(id: string, question: string, answer: string) { this.logger.log('[FAQ-SERV] - UPDATE TRAIN BOT FAQ - ID ', id); const httpOptions = { headers: new HttpHeaders({ 'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization': this.tiledeskToken }) }; let url = this.FAQ_URL + id; this.logger.log('[FAQ-SERV] - UPDATE TRAIN BOT FAQ - PUT URL ', url); const body = { 'question': question, 'answer': answer }; this.logger.log('[FAQ-SERV] - UPDATE TRAIN BOT FAQ - BODY ', body); return this._httpClient.put(url, JSON.stringify(body), httpOptions) }
/** * UPDATE TRAIN BOT FAQ * @param id * @param question * @param answer * @returns */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/faq.service.ts#L226-L244
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
FaqService.searchFaqByFaqKbId
public searchFaqByFaqKbId(botId: string, question: string) { const httpOptions = { headers: new HttpHeaders({ 'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization': this.tiledeskToken }) }; const url = this.SERVER_BASE_PATH + this.project_id + '/faq_kb/' + 'askbot'; const body = { 'id_faq_kb': botId, 'question': question }; return this._httpClient.post(url, JSON.stringify(body), httpOptions) }
/** * SEARCH FAQ BY BOT ID * @param botId * @param question * @returns */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/faq.service.ts#L253-L267
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
NotifyService._displayContactUsModal
_displayContactUsModal(displayModal: boolean, areAvailableOperatorsSeats: string) { this.logger.log('[NOTIFY-SERVICE] - _displayContactUsModal areAvailableOperatorsSeats ', areAvailableOperatorsSeats); if (areAvailableOperatorsSeats === 'operators_seats_unavailable') { this.showSubtitleAllOperatorsSeatsUsed = true; } else { this.showSubtitleAllOperatorsSeatsUsed = false; } if (displayModal === true) { this.displayContactUsModal = 'block'; } }
// "CONTACT US - LET'S CHAT" MODAL
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/notify.service.ts#L130-L141
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
NotifyService.openDataExportNotAvailable
openDataExportNotAvailable() { this.displayDataExportNotAvailable = 'block'; }
// -----------------------------------------------
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/notify.service.ts#L154-L156
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
NotifyService.presentModalInstallTiledeskModal
presentModalInstallTiledeskModal() { this.displayInstallTiledeskModal = 'block'; }
// -----------------------------------------------
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/notify.service.ts#L165-L167
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
NotifyService.presentModalSuccessCheckModal
presentModalSuccessCheckModal(titletext: string, bodytext: string) { this.successCheckModalTitleText = titletext; this.successCheckModalBodyText = bodytext; this.displaySuccessCheckModal = 'block'; }
// -----------------------------------------------
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/notify.service.ts#L176-L180
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
NotifyService.displayCancelSubscriptionModal
displayCancelSubscriptionModal(displayModal: boolean) { if (displayModal === true) { this.viewCancelSubscriptionModal = 'block'; } }
// -----------------------------------------------
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/notify.service.ts#L190-L194
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
NotifyService.cancelSubscriptionCompleted
cancelSubscriptionCompleted(hasDone: boolean) { this.viewCancelSubscriptionModal = 'none'; this.cancelSubscriptionCompleted$.next(hasDone); }
// CALLED FROM NotificationMessageComponent
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/notify.service.ts#L201-L204
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
NotifyService.publishHasClickedChat
publishHasClickedChat(hasClickedChat: boolean) { this.logger.log('[NOTIFY-SERVICE] - hasClickedChat ', hasClickedChat); this.bs_hasClickedChat.next(true); }
// is CALLED FROM SIDEBAR, IN THE CHECLIST MODAL (NOTIFICATION-MESSAGE) AND HOME WHEN THE USER CLICK ON THE CHAT BTN
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/notify.service.ts#L255-L258
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
NotifyService.showNotification
showNotification(message, notificationColor, icon) { const type = ['', 'info', 'success', 'warning', 'danger']; // const color = Math.floor((Math.random() * 4) + 1); const color = notificationColor this.notify = $.notify({ // icon: 'glyphicon glyphicon-warning-sign', // message: message }, { type: type[color], // timer: 55000, // delay: 0, placement: { from: 'top', align: 'right' }, template: '<div data-notify="container" class="col-xs-11 col-sm-3 alert alert-{0}" style="text-align: left;" role="alert">' + '<button type="button" aria-hidden="true" class="close" data-notify="dismiss">×</button>' + // '<span data-notify="title" style="max-width: 100%; font-size:1.1em; ">TileDesk</span> ' + // tslint:disable-next-line:max-line-length '<span data-notify="icon" style="display: inline;"><i style="vertical-align: middle; padding-right: 5px;" class="material-icons">' + icon + '</i> </span> ' + '<span data-notify="message" style="display: inline; vertical-align: middle ">' + message + '</span>' + '</div>' }); }
// showNotification(from, align) {
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/notify.service.ts#L263-L288
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
NotifyService.showForegroungPushNotification
showForegroungPushNotification(sender: string, msg: string, link: string, requester_avatar_initial: string, requester_avatar_bckgrnd: string) { // console.log('[NOTIFY-SERVICE] showForegroungPushNotification link', link) // console.log('[NOTIFY-SERVICE] showForegroungPushNotification requester_avatar_initial', requester_avatar_initial) // console.log('[NOTIFY-SERVICE] showForegroungPushNotification requester_avatar_bckgrnd', requester_avatar_bckgrnd) $.notifyDefaults({ url_target: "_self" }); this.foregroungNotification = $.notify({ title: sender, message: msg, url: link, }, { type: 'minimalist', delay: 6000, placement: { from: 'top', align: 'center' }, // '<span data-notify="icon"></span>' + // '<img data-notify="icon" class="img-circle pull-left">' + // [ngStyle]="{'background': 'linear-gradient(rgb(255,255,255) -125%,' + request?.requester_fullname_fillColour + ')'}" // '<span class="foreground-notification-img-circle pull-left [ngStyle]="{"background": '+ requester_avatar_bckgrnd +' } ">' + // requester_avatar_initial // +'</span>' + template: '<div id="foreground-not" data-notify="container" class="col-xs-3 col-sm-3 alert alert-{0}" role="alert" style="box-shadow:0 5px 15px -5px rgb(0 0 0 / 40%)" ' + '<span data-notify="icon"></span>' + '<span data-notify="header">New message</span>' + '<span data-notify="title">{1}</span>' + '<span data-notify="message">{2}</span>' + `<a href="{3}" data-notify="url"></a>` + '</div>' }); }
// icon_type: 'image',
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/notify.service.ts#L321-L355
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
NotifyService.showRequestIsArchivedNotification
showRequestIsArchivedNotification(msg_part1) { // tslint:disable-next-line:max-line-length // this.notifyArchivingRequest.update({ 'type': 'success', 'message': '<i class="material-icons" style="vertical-align: middle;"> done </i> <span style="vertical-align: middle; display: inline-block; padding-right:5px">' + msg_part1 + request_id + msg_part2 + '</span> <span style="padding-left:28px">' + '</span>' }) this.notifyArchivingRequest.update({ 'type': 'success', 'message': `<span data-notify="icon" style="display: inline;"><i style="vertical-align: middle; padding: 3px;background-color: #449d48; border-radius: 50%; font-size:16px " class="material-icons">` + 'done' + '</i> </span> ' + '<span data-notify="message" style="display: inline; vertical-align: middle; padding-left:8px">' + msg_part1 + '</span>' }) }
// showRequestIsArchivedNotification(msg_part1, request_id, msg_part2) {
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/notify.service.ts#L559-L567
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
OpenaiService.previewPrompt
previewPrompt(data) { const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json', 'Authorization': this.tiledeskToken }) } const url = this.URL_TILEDESK_OPENAI + "/openai/"; this.logger.debug('[OPENAI.SERVICE] - preview prompt URL: ', url); return this.httpClient.post(url, data, httpOptions); }
////////////////////////////////////////////////////////
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/openai.service.ts#L48-L60
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
OpenaiService.previewAskPrompt
previewAskPrompt(data) { const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json', 'Authorization': this.tiledeskToken }) } const url = this.URL_TILEDESK_OPENAI + "/kb/qa"; this.logger.debug('[OPENAI.SERVICE] - preview prompt URL: ', url); return this.httpClient.post(url, data, httpOptions); }
////////////////////////////////////////////////////////
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/openai.service.ts#L70-L82
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
OpenaiService.askGpt
askGpt(data) { const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json', 'Authorization': this.tiledeskToken // remove it for pugliai endpoint }) } // const url = this.GPT_API_URL + "/qa"; const url = this.URL_TILEDESK_OPENAI + "/kbsettings/qa"; this.logger.debug('[OPENAI.SERVICE] - ask gpt URL: ', url); return this.httpClient.post(url, data, httpOptions); }
////////////////////////////////////////////////////////
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/openai.service.ts#L104-L117
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ProjectService.createNewProjectUserToGetNewLeadID
public createNewProjectUserToGetNewLeadID(project_id: string) { const url = this.SERVER_BASE_URL + project_id + '/project_users/' this.logger.log('[TILEDESK-SERVICE] - CREATE NEW PROJECT USER TO GET NEW LEAD ID url ', url); const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json', Authorization: this.tiledeskToken }) }; const body = {}; return this.http.post(url, body, httpOptions).pipe(map((res: any) => { this.logger.log('[TILEDESK-SERVICE] - CREATE NEW PROJECT USER TO GET NEW LEAD ID url ', res); return res })) }
// ---------------------------------------------
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/projects.service.ts#L148-L162
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ProjectService.createNewLead
public createNewLead(leadid: string, fullname: string, leademail: string, project_id: string) { const url = this.SERVER_BASE_URL + project_id + '/leads/' this.logger.log('[TILEDESK-SERVICE] - CREATE NEW LEAD url ', url); const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json', Authorization: this.tiledeskToken }) }; const body = { 'lead_id': leadid, 'fullname': fullname, 'email': leademail }; this.logger.log('[TILEDESK-SERVICE] - CREATE NEW LEAD ', body); return this.http.post(url, body, httpOptions).pipe(map((res: any) => { this.logger.log('[TILEDESK-SERVICE] - CREATE NEW LEAD RES ', res); return res })) }
// ---------------------------------------------
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/projects.service.ts#L167-L185
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ProjectService.getAllBotByProjectId
public getAllBotByProjectId(project_id: string) { const url = this.SERVER_BASE_URL + project_id + '/faq_kb?all=true' this.logger.log('[TILEDESK-SERVICE] - GET ALL BOTS BY PROJECT ID - URL', url); const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json', Authorization: this.tiledeskToken }) }; return this.http.get(url, httpOptions).pipe(map((res: any) => { this.logger.log('[TILEDESK-SERVICE] - GET ALL BOTS BY PROJECT ID - RES ', res); return res })) }
// -------------------------------------------------------------------------------------
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/projects.service.ts#L190-L206
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ProjectService.getDeptsByProjectId
public getDeptsByProjectId(project_id: string) { const url = this.SERVER_BASE_URL + project_id + '/departments/allstatus'; this.logger.log('[TILEDESK-SERVICE] - GET DEPTS (ALL STATUS) - URL', url); const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json', Authorization: this.tiledeskToken }) }; return this.http.get(url, httpOptions).pipe(map((res: any) => { this.logger.log('[TILEDESK-SERVICE] - GET DEPTS (ALL STATUS) - RES ', res); return res })) }
// -------------------------------------------------------------------------------------
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/projects.service.ts#L211-L227
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
UsersService.getCurrentUserCommunityProfile
public getCurrentUserCommunityProfile(userid): Observable<UserModel[]> { const url = this.SERVER_BASE_URL + 'users_util/' + userid; this.logger.log('[USER-SERV] - GET CURRENT USER CMNTY PROFILE - URL', url); const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json', }) }; return this._httpClient.get<UserModel[]>(url, httpOptions) }
// }
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/users.service.ts#L255-L267
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
UsersService.updateUserWithCommunityProfile
public updateUserWithCommunityProfile(userWebsite: string, userPublicEmail: string, userDescription: string) { const url = this.SERVER_BASE_URL + 'users/'; this.logger.log('[USER-SERV] - UPDATE USER WITH COMMUNITY PROFILE (PUT) URL ', url); const httpOptions = { headers: new HttpHeaders({ 'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization': this.TOKEN }) }; const body = { 'public_website': userWebsite, 'public_email': userPublicEmail, 'description': userDescription }; this.logger.log('[USER-SERV] - UPDATE USER WITH COMMUNITY PROFILE - BODY ', body); return this._httpClient.put(url, JSON.stringify(body), httpOptions) }
// }
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/users.service.ts#L1094-L1115
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
WebSocketJs.ref
ref(topic, calledby, onCreate, onUpdate, onData) { // this.logger.log('[WEBSOCKET-JS] ****** CALLING REF ****** '); this.logger.log('[WEBSOCKET-JS] - REF - calledby ', calledby); this.logger.log('[WEBSOCKET-JS] - REF - TOPIC ', topic); this.logger.log('[WEBSOCKET-JS] - REF - CALLBACKS', this.callbacks); if (!this.callbacks) { this.logger.log('[WEBSOCKET-JS] - REF OOOOPS! NOT CALLBACKS ***', this.callbacks); return } this.callbacks.set(topic, { onCreate: onCreate, onUpdate: onUpdate, onData: onData }); this.logger.log('[WEBSOCKET-JS] - CALLBACK-SET - callbacks', this.callbacks); if (this.ws && this.ws.readyState == 1) { this.logger.log('[WEBSOCKET-JS] - REF - READY STATE ', this.ws.readyState); this.logger.log('[WEBSOCKET-JS] - REF - READY STATE = 1 > SUBSCRIBE TO TOPICS '); this.subscribe(topic); } else { // this.ws = new WebSocket("wss://tiledesk-server-pre.herokuapp.com/?token=JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI1ZGRkMzBiZmYwMTk1ZjAwMTdmNzJjNmQiLCJlbWFpbCI6InByZWdpbm9AZjIxdGVzdC5pdCIsImZpcnN0bmFtZSI6Ikdpbm8iLCJsYXN0bmFtZSI6IlByZSIsImVtYWlsdmVyaWZpZWQiOnRydWUsImlhdCI6MTYwODgwNjY0MCwiYXVkIjoiaHR0cHM6Ly90aWxlZGVzay5jb20iLCJpc3MiOiJodHRwczovL3RpbGVkZXNrLmNvbSIsInN1YiI6InVzZXIiLCJqdGkiOiI1YmVmMDcxYy00ODBlLTQzYzQtOTRhYS05ZjQxYzMyNDcxMGQifQ.wv6uBn2P6H9wGb5WCYQkpPEScMU9PB1pBUzFouhJk20"); this.logger.log('[WEBSOCKET-JS] - REF - READY STATE ≠ 1 > OPEN WS AND THEN SUBSCRIBE TO TOPICS'); // this.logger.log('% »»» WebSocketJs WF *** REF *** WS 2 ', this.ws); var that = this; if (this.ws) { this.ws.addEventListener("open", function (event) { that.logger.log('[WEBSOCKET-JS] - REF - OPEN EVENT *** ', event); that.subscribe(topic); }); } if (this.topics.indexOf(topic) === -1) { this.topics.push(topic); } } }
// WsRequestsMsgsComponent onInit() is got the request id from url params
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/websocket/websocket-js.ts#L72-L112
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
WebSocketJs.subscribe
subscribe(topic) { if (this.topics.indexOf(topic) === -1) { this.topics.push(topic); } this.logger.log('[WEBSOCKET-JS] - SUBSCRIBE TO TOPIC ', topic); var message = { action: 'subscribe', payload: { //topic: '/' + project_id + '/requests', topic: topic, message: undefined, method: undefined }, }; var str = JSON.stringify(message); this.logger.log("[WEBSOCKET-JS] - SUBSCRIBE TO TOPIC - STRING TO SEND " + str, " FOR SUBSCRIBE TO TOPIC: ", topic); this.send(str, `SUBSCRIBE to ${topic}`); }
// -----------------------------------------------------------------------------------------------------
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/websocket/websocket-js.ts#L117-L137
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
WebSocketJs.unsubscribe
unsubscribe(topic) { this.logger.log("[WEBSOCKET-JS] - UN-SUBSCRIBE - FROM TOPIC: ", topic); // this.logger.log("% »»» WebSocketJs WF *** UNSUBSCRIBE *** - this.topics ", this.topics); // this.logger.log("% »»» WebSocketJs WF *** UNSUBSCRIBE *** - topic ", topic); // this.logger.log("% »»» WebSocketJs WF *** UNSUBSCRIBE *** - callbacks ", this.callbacks); var index = this.topics.indexOf(topic); if (index > -1) { this.topics.splice(index, 1); } this.logger.log("[WEBSOCKET-JS] - UN-SUBSCRIBE - TOPICS AFTER SPLICE THE TOPIC ", this.topics); this.logger.log("[WEBSOCKET-JS] - UN-SUBSCRIBE - DELETE TOPIC FROM CALLBACKS - CALLBACKS SIZE ", this.callbacks.size); // if (this.callbacks.length > 0) { if (this.callbacks.size > 0) { this.callbacks.delete(topic); this.logger.log("[WEBSOCKET-JS] - UN-SUBSCRIBE - CALLBACKS AFTER DELETE TOPIC ", this.callbacks); } var message = { action: 'unsubscribe', payload: { //topic: '/' + project_id + '/requests', topic: topic, message: undefined, method: undefined }, }; var str = JSON.stringify(message); this.logger.log("[WEBSOCKET-JS] - UN-SUBSCRIBE str " + str); if (this.ws && this.ws.readyState == 1) { this.logger.log("[WEBSOCKET-JS] - UN-SUBSCRIBE TO TOPIC - STRING TO SEND " + str, " FOR UNSUBSCRIBE TO TOPIC: ", topic); this.send(str, `UNSUSCRIBE from ${topic}`); } else if (this.ws) { this.logger.log("[WEBSOCKET-JS] - UN-SUBSCRIBE TRY 'SEND' BUT READY STASTE IS : ", this.ws.readyState); } }
// -----------------------------------------------------------------------------------------------------
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/websocket/websocket-js.ts#L146-L187
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
WebSocketJs.send
send(initialMessage, calling_method) { // this.logger.log("[WEBSOCKET-JS] - SEND - INIZIAL-MSG ", initialMessage, " CALLED BY ", calling_method); this.ws.send(initialMessage); }
// -----------------------------------------------------------------------------------------------------
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/websocket/websocket-js.ts#L192-L196
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
WebSocketJs.close
close() { this.topics = []; this.callbacks = []; this.logger.log("[WEBSOCKET-JS] - CALLED CLOSE - TOPICS ", this.topics, ' - CALLLBACKS ', this.callbacks); if (this.ws) { this.ws.onclose = function () { }; // disable onclose handler first this.ws.close(); } this.heartReset(); }
// -----------------------------------------------------------------------------------------------------
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/websocket/websocket-js.ts#L202-L212
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
WebSocketJs.resubscribe
resubscribe() { this.logger.log("[WEBSOCKET-JS] - RESUBSCRIBE - TO TOPICS ", this.topics); this.logger.log("[WEBSOCKET-JS] - RESUBSCRIBE - CALLBACKS ", this.callbacks); if (this.topics.length > 0) { this.topics.forEach(topic => { this.logger.log("[WEBSOCKET-JS] - RESUBSCRIBE - SUBDCRIBE TO TOPICS ", topic); this.subscribe(topic); // nn fa sudbcribe }); } }
// -----------------------------------------------------------------------------------------------------
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/websocket/websocket-js.ts#L217-L227
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
WebSocketJs.heartCheck
heartCheck() { this.heartReset(); this.heartStart(); }
// -----------------------------------------------------------------------------------------------------
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/websocket/websocket-js.ts#L232-L235
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
WebSocketJs.heartStart
heartStart() { // this.getRemainingTime(); this.pingTimeoutId = setTimeout(() => { // Qui viene inviato un battito cardiaco Dopo averlo ricevuto, viene restituito un messaggio di battito cardiaco. // onmessage Ottieni il battito cardiaco restituito per indicare che la connessione è normale if (this.ws && this.ws.readyState == 1) { // this.logger.log("[WEBSOCKET-JS] - HEART-START - SEND PING-MSG"); this.send(JSON.stringify(this.pingMsg), 'HEART-START') } else if (this.ws) { this.logger.log("[WEBSOCKET-JS] - HEART-START - TRY TO SEND PING-MSG BUT READY STATE IS ", this.ws.readyState); } // Se non viene ripristinato dopo un determinato periodo di tempo, il backend viene attivamente disconnesso this.pongTimeoutId = setTimeout(() => { this.logger.log("[WEBSOCKET-JS] - HEART-START - PONG-TIMEOUT-ID - CLOSE WS "); // se onclose Si esibirà reconnect,Eseguiamo ws.close() Bene, se lo esegui direttamente reconnect Si innescherà onclose Causa riconnessione due volte this.ws.close(); }, this.pongTimeout); }, this.pingTimeout); }
// -----------------------------------------------------------------------------------------------------
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/websocket/websocket-js.ts#L279-L305
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
WebSocketJs.heartReset
heartReset() { // this.logger.log("[WEBSOCKET-JS] - HEART-RESET"); clearTimeout(this.pingTimeoutId); clearTimeout(this.pongTimeoutId); }
// -----------------------------------------------------------------------------------------------------
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/websocket/websocket-js.ts#L310-L314
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
WebSocketJs.init
init(url, onCreate, onUpdate, onData, onOpen = undefined, onOpenCallback = undefined, _topics = [], _callbacks = new Map()) { this.url = url; this.onCreate = onCreate; this.onUpdate = onUpdate; this.onData = onData; this.onOpen = onOpen; this.topics = _topics//[];//new Map(); this.callbacks = _callbacks// new Map(); // this.userHasClosed = false; // this.logger.log('% »»» WebSocketJs WF - closeWebsocket this.userHasClosed ' , this.userHasClosed); // this.sendingMessages = [];//new Map(); // this.data = []; // this.init(this.sendMesagesInSendingArray); this.logger.log("[WEBSOCKET-JS] - CALLING INIT - topics ", this.topics); this.logger.log("[WEBSOCKET-JS] - CALLING INIT - url ", this.url); this.logger.log("[WEBSOCKET-JS] - CALLING INIT - callbacks ", this.callbacks); var that = this; return new Promise(function (resolve, reject) { // var options = { // // headers: { // // "Authorization" : "JWT " + token // // } // }; // this.logger.log('options', options); // var ws = new WebSocket('ws://localhost:3000'); // var ws = new WebSocket('ws://localhost:3000/public/requests'); // var ws = new WebSocket('ws://localhost:3000/5bae41325f03b900401e39e8/messages'); // ----------------------------------------------------------------------------------------------------- // @ new WebSocket // ----------------------------------------------------------------------------------------------------- that.ws = new WebSocket(that.url); // ----------------------------------------------------------------------------------------------------- // @ onopen // ----------------------------------------------------------------------------------------------------- that.ws.onopen = function (e) { that.logger.log('[WEBSOCKET-JS] - websocket is connected ...', e); // ----------------- // @ heartCheck // ----------------- that.heartCheck(); if (onOpenCallback) { onOpenCallback(); } if (that.onOpen) { that.onOpen(); } } // ----------------------------------------------------------------------------------------------------- // @ onclose // ----------------------------------------------------------------------------------------------------- that.ws.onclose = function (e) { that.logger.log('[WEBSOCKET-JS] websocket IS CLOSED ... Try to reconnect in 3 seconds ', e); // this.logger.log('% »»» WebSocketJs - websocket onclose this.userHasClosed ', that.userHasClosed); // https://stackoverflow.com/questions/3780511/reconnection-of-client-when-server-reboots-in-websocket // Try to reconnect in 3 seconds // -------------------- // @ init > resubscribe // -------------------- setTimeout(function () { that.init(url, onCreate, onUpdate, onData, onOpen, function () { that.logger.log('[WEBSOCKET-JS] websocket IS CLOSED ... CALLING RESUSCRIBE '); that.resubscribe(); }, that.topics, that.callbacks); }, 3000); } // ----------------------------------------------------------------------------------------------------- // @ onerror // ----------------------------------------------------------------------------------------------------- that.ws.onerror = function (err) { that.logger.error('[WEBSOCKET-JS] websocket IS CLOSED - websocket error ...', err) } // ----------------------------------------------------------------------------------------------------- // @ onmessage // ----------------------------------------------------------------------------------------------------- that.ws.onmessage = function (message) { // that.logger.log('[WEBSOCKET-JS] websocket onmessage ', message); // that.logger.log('[WEBSOCKET-JS] websocket onmessage data', message.data); // let test = '{ "action": "publish","payload": {"topic": "/5df26badde7e1c001743b63c/requests", "method": "CREATE", "message": [ { "_id": "5f29372d690e6f0034edf100", "status": 200, "preflight": false, "hasBot": true, "participants": ["bot_5df272e8de7e1c001743b645"], "participantsAgents": [], "participantsBots": ["5df272e8de7e1c001743b645"], "request_id": "support-group-MDszsSJlwqQn1_WCh6u", "requester": "5f29371b690e6f0034edf0f5", "lead": "5f29372d690e6f0034edf0ff", "first_text": "ocourse the email is valid ","department": "5df26badde7e1c001743b63e", "agents": [{"user_available": true,"online_status": "online", "number_assigned_requests": 35, "_id": "5e0f2119705a35001725714d","id_project": "5df26badde7e1c001743b63c", "id_user": "5aaa99024c3b110014b478f0", "role": "admin", "createdBy": "5df26ba1de7e1c001743b637","createdAt": "2020-01-03T11:10:17.123Z", "updatedAt": "2020-01-03T11:10:17.123Z", "__v": 0 }, { "user_available": false, "online_status": "offline", "number_assigned_requests": 0, "_id": "5e1a13824437eb0017f712b4", "id_project": "5df26badde7e1c001743b63c","id_user": "5ac7521787f6b50014e0b592", "role": "admin", "createdBy": "5df26ba1de7e1c001743b637", "createdAt": "2020-01-11T18:27:14.657Z","updatedAt": "2020-01-11T18:27:14.657Z", "__v": 0}, { "user_available": false,"online_status": "offline", "number_assigned_requests": 0, "_id": "5df26bdfde7e1c001743b640", "id_project": "5df26badde7e1c001743b63c", "id_user": "5de9200d6722370017731969","role": "admin","createdBy": "5df26ba1de7e1c001743b637", "createdAt": "2019-12-12T16:33:35.244Z", "updatedAt": "2019-12-12T16:33:35.244Z","__v": 0 }, {"user_available": true, "online_status": "online","number_assigned_requests": -11, "_id": "5eb1a3647ac005003480f54d", "id_project": "5df26badde7e1c001743b63c","id_user": "5e09d16d4d36110017506d7f","role": "owner", "createdBy": "5aaa99024c3b110014b478f0","createdAt": "2020-05-05T17:33:24.328Z", "updatedAt": "2020-05-05T17:33:24.328Z","__v": 0}], "sourcePage": "https://www.tiledesk.com/pricing-self-managed/", "language": "en","userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36","attributes": { "departmentId": "5df26badde7e1c001743b63e","departmentName": "Default Department","ipAddress": "115.96.30.154","client": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36","sourcePage": "https://www.tiledesk.com/pricing-self-managed/", "projectId": "5df26badde7e1c001743b63c", "requester_id": "ce31d3fd-a358-49c7-9b9f-5aead8330063", "subtype": "info","decoded_jwt": {"_id": "ce31d3fd-a358-49c7-9b9f-5aead8330063","firstname": "Guest", "id": "ce31d3fd-a358-49c7-9b9f-5aead8330063", "fullName": "Guest ","iat": 1596536604,"aud": "https://tiledesk.com","iss": "https://tiledesk.com","sub": "guest","jti": "702a4a7e-e56a-43cf-aadd-376f7c12f633"}},"id_project": "5df26badde7e1c001743b63c","createdBy": "ce31d3fd-a358-49c7-9b9f-5aead8330063","tags": [], "notes": [],"channel": {"name": "chat21"},"createdAt": "2020-08-04T10:23:41.641Z","updatedAt": "2021-03-25T18:01:13.371Z","__v": 3,"assigned_at": "2020-08-04T10:25:26.059Z","channelOutbound": {"name": "chat21"},"snapshot": {"agents": [{"id_user": "5aaa99024c3b110014b478f0"}, {"id_user": "5ac7521787f6b50014e0b592"}, {"id_user": "5de9200d6722370017731969"}, { "id_user": "5e09d16d4d36110017506d7f"}]},"id": "5f29372d690e6f0034edf100","requester_id": "5f29372d690e6f0034edf0ff"}]}}' // let test_due = '{ "action": "publish","payload": {"topic": "/5df26badde7e1c001743b63c/requests", "method": "CREATE", "message": [ { "_id": "5f29372d690e6f0034edf100", "status": 200, "preflight": false, "hasBot": true, "participants": ["bot_5df272e8de7e1c001743b645"], "participantsAgents": [], "participantsBots": ["5df272e8de7e1c001743b645"], "request_id": "support-group-MDszsSJlwqQn1_WCh6u", "requester": "5f29371b690e6f0034edf0f5", "lead": "5f29372d690e6f0034edf0ff", "first_text": "ocourse the email is valid ","department": "5df26badde7e1c001743b63e", "agents": [{"user_available": true,"online_status": "online", "number_assigned_requests": 35, "_id": "5e0f2119705a35001725714d","id_project": "5df26badde7e1c001743b63c", "id_user": "5aaa99024c3b110014b478f0", "role": "admin", "createdBy": "5df26ba1de7e1c001743b637","createdAt": "2020-01-03T11:10:17.123Z", "updatedAt": "2020-01-03T11:10:17.123Z", "__v": 0 }, { "user_available": false, "online_status": "offline", "number_assigned_requests": 0, "_id": "5e1a13824437eb0017f712b4", "id_project": "5df26badde7e1c001743b63c","id_user": "5ac7521787f6b50014e0b592", "role": "admin", "createdBy": "5df26ba1de7e1c001743b637", "createdAt": "2020-01-11T18:27:14.657Z","updatedAt": "2020-01-11T18:27:14.657Z", "__v": 0}, { "user_available": false,"online_status": "offline", "number_assigned_requests": 0, "_id": "5df26bdfde7e1c001743b640", "id_project": "5df26badde7e1c001743b63c", "id_user": "5de9200d6722370017731969","role": "admin","createdBy": "5df26ba1de7e1c001743b637", "createdAt": "2019-12-12T16:33:35.244Z", "updatedAt": "2019-12-12T16:33:35.244Z","__v": 0 }, {"user_available": true, "online_status": "online","number_assigned_requests": -11, "_id": "5eb1a3647ac005003480f54d", "id_project": "5df26badde7e1c001743b63c","id_user": "5e09d16d4d36110017506d7f","role": "owner", "createdBy": "5aaa99024c3b110014b478f0","createdAt": "2020-05-05T17:33:24.328Z", "updatedAt": "2020-05-05T17:33:24.328Z","__v": 0}], "sourcePage": "https://www.tiledesk.com/pricing-self-managed/", "language": "en","userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36","attributes": { "departmentId": "5df26badde7e1c001743b63e","departmentName": "Default Department","ipAddress": "115.96.30.154","client": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36","sourcePage": "https://www.tiledesk.com/pricing-self-managed/", "projectId": "5df26badde7e1c001743b63c", "requester_id": "ce31d3fd-a358-49c7-9b9f-5aead8330063", "subtype": "info","decoded_jwt": {"_id": "ce31d3fd-a358-49c7-9b9f-5aead8330063","firstname": "Guest", "id": "ce31d3fd-a358-49c7-9b9f-5aead8330063", "fullName": "Guest ","iat": 1596536604,"aud": "https://tiledesk.com","iss": "https://tiledesk.com","sub": "guest","jti": "702a4a7e-e56a-43cf-aadd-376f7c12f633"}},"id_project": "5df26badde7e1c001743b63c","createdBy": "ce31d3fd-a358-49c7-9b9f-5aead8330063","tags": [], "notes": [],"channel": {"name": "chat21"},"createdAt": "2020-08-04T10:23:41.641Z","updatedAt": "2021-03-25T18:01:13.371Z","__v": 3,"assigned_at": "2020-08-04T10:25:26.059Z","channelOutbound": {"name": "chat21"},"_snapshot": {"agents": [{"id_user": "5aaa99024c3b110014b478f0"}, {"id_user": "5ac7521787f6b50014e0b592"}, {"id_user": "5de9200d6722370017731969"}, { "id_user": "5e09d16d4d36110017506d7f"}]},"id": "5f29372d690e6f0034edf100","requester_id": "5f29372d690e6f0034edf0ff"}]}}' try { var json = JSON.parse(message.data); // var json = JSON.parse(test_due); // this.logger.log('% »»» WebSocketJs - websocket onmessage JSON.parse(message.data) json payload', json.payload); // this.logger.log('% »»» WebSocketJs - websocket onmessage JSON.parse(message.data) json payload topic', json.payload.topic); // this.logger.log('% »»» WebSocketJs - websocket onmessage JSON.parse(message.data) json ', json); } catch (e) { that.logger.error('[WEBSOCKET-JS] - This doesn\'t look like a valid JSON: ', message.data); return; } // ------------------- // @ heartCheck // ------------------- that.heartCheck(); // -------------------------------------------------------------------------------------------------------------------- // @ check the action and the message's text - if action is 'heartbeat' and text is ping send the PONG message and return // -------------------------------------------------------------------------------------------------------------------- if (json.action == "heartbeat") { if (json.payload.message.text == "ping") { // ------------------- // @ send PONG // ------------------- // that.logger.log('[WEBSOCKET-JS] - RECEIVED PING -> SEND PONG MSG'); that.send(JSON.stringify(that.pongMsg), 'ON-MESSAGE') } else { // nk // this.logger.log('[WEBSOCKET-JS] - NOT RECEIVED PING '); } return; } var object = { event: json.payload, data: json }; if (that.onData) { that.onData(json.payload.message, object); } var callbackObj = that.callbacks.get(object.event.topic); if (callbackObj && callbackObj.onData) { callbackObj.onData(json.payload.message, object); } if (json && json.payload && json.payload.message && that.isArray(json.payload.message)) { json.payload.message.forEach(element => { //let insUp = that.insertOrUpdate(element); let insUp = json.payload.method; var object = { event: json.payload, data: element }; var callbackObj = that.callbacks.get(object.event.topic); if (insUp == "CREATE") { if (that.onCreate) { that.onCreate(element, object); } if (callbackObj) { callbackObj.onCreate(element, object); } } if (insUp == "UPDATE") { if (that.onUpdate) { that.onUpdate(element, object); } if (callbackObj && callbackObj.onUpdate) { callbackObj.onUpdate(element, object); } } resolve({ element: element, object: object }); }); } else { //let insUp = that.insertOrUpdate(json.payload.message); let insUp = json.payload.method; var object = { event: json.payload, data: json }; var callbackObj = that.callbacks.get(object.event.topic); if (insUp == "CREATE") { if (that.onCreate) { that.onCreate(json.payload.message, object); } if (callbackObj && callbackObj.onCreate) { callbackObj.onCreate(json.payload.message, object); } } if (insUp == "UPDATE") { if (that.onUpdate) { that.onUpdate(json.payload.message, object); } if (callbackObj && callbackObj.onUpdate) { callbackObj.onUpdate(json.payload.message, object); } } resolve({ element: json.payload.message, object: object }); // resolve: // $('#messages').after(json.text + '<br>'); } } }); // .PROMISE }
// -----------------------------------------------------------------------------------------------------
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/websocket/websocket-js.ts#L319-L539
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
WebSocketJs.isArray
isArray(what) { return Object.prototype.toString.call(what) === '[object Array]'; }
// }
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/websocket/websocket-js.ts#L559-L561
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
WsChatbotService.subsToAITrain_ByBot_id
subsToAITrain_ByBot_id(project_id, bot_id) { var self = this; this.logger.log("[WS-CHATBOT-SERV] - SUBSCRIBE TO AI TRAIN BY BOT ID bot_id", bot_id); const path = '/' + project_id + '/bots/' + bot_id this.logger.log("[WS-CHATBOT-SERV] - SUBSCRIBE TO AI TRAIN BY BOT ID path", path); this.webSocketJs.ref(path, 'subsToAITrain_ByBot_id', function (data, notification) { self.logger.log("[WS-CHATBOT-SERV] -SUBSCRIBE TO AI TRAIN BY BOT ID - CREATE data", data); // console.log("[WS-CHATBOT-SERV] -SUBSCRIBE TO AI TRAIN BY BOT ID - CREATE data", data) // -------------------------------------------------------------------------- // Check if upcoming messages already exist in the messasges list (1° METHOD) // -------------------------------------------------------------------------- // this.logger.log("[WS-MSGS-SERV]- ADD WS Msgs - CHEK IF ADD MSD data ", data); // const msgFound = self.wsMsgsList.filter((obj: any) => { // this.logger.log("[WS-MSGS-SERV]- ADD WS Msgs - CHEK IF ADD MSD obj._id ", obj._id , ' data._id ', data._id); // return obj._id === data._id; // }); // this.logger.log("[WS-MSGS-SERV] - ADD WS Msgs - CHEK IF ADD MSG INCOMING data ", data); // this.logger.log("[WS-MSGS-SERV] - ADD WS Msgs - CHEK IF ADD MSG INCOMING data wsMsgsList ", self.wsMsgsList); // -------------------------------------------------------------------------- // Check if upcoming messages already exist in the messasges list (2nd METHOD) // -------------------------------------------------------------------------- // const index = self.wsMsgsList.findIndex((msg) => msg._id === data._id); // // if (msgFound.length === 0) { // if (index === -1) { // self.addWsMsg(data) // } else { // // self.logger.log("[WS-MSGS-SERV] - SUBSCRIBE TO MSGS BY REQUESTS ID - MSG ALREADY EXIST - NOT ADD"); // } }, function (data, notification) { // console.log("[WS-MSGS-SERV] - SUBSCRIBE TO MSGS BY REQUESTS ID - UPDATE data", data); // self.updateWsMsg(data) }, function (data, notification) { if (data) { // console.log("[WS-MSGS-SERV] - SUBSCRIBE TO MSGS BY REQUESTS ID - ON-DATA - data", data); self.wsChatbotTraining$.next(data); } } ); }
/** * * Subscribe to websocket chatbot by bot id * called if chatbot.intentsEngine is equal to 'ai' * * @param bot_id */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/websocket/ws-chatbot.service.ts#L46-L96
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
WsChatbotService.unsubsToAITrain_ByBot_id
unsubsToAITrain_ByBot_id(bot_id) { this.logger.log("[WS-MSGS-SERV] - UNSUBSCRIBE TO MSGS BY REQUEST ID - request_id ", bot_id); this.webSocketJs.unsubscribe('/' + this.project_id + '/bots/' + bot_id ); }
/** * Unsubscribe to websocket messages by request id service * called when in WsRequestsMsgsComponent onInit() is got the request id from url params * * @param request_id */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/websocket/ws-chatbot.service.ts#L104-L108
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
NotificationMessageComponent.openModalExpiredSubscOrGoToPricing
openModalExpiredSubscOrGoToPricing() { if (this.USER_ROLE === 'owner') { if (this.prjct_profile_type === 'free' && this.trial_expired === true) { this.notify.closeDataExportNotAvailable(); this.router.navigate(['project/' + this.project._id + '/pricing']); // this.notify.presentContactUsModalToUpgradePlan(true); } else if (this.prjct_profile_type === 'payment' && this.subscription_is_active === false) { this.notify.closeDataExportNotAvailable(); if (this.profile_name !== PLAN_NAME.C) { this.notify.displaySubscripionHasExpiredModal(true, this.prjct_profile_name, this.subscription_end_date); } else if (this.profile_name === PLAN_NAME.C) { this.notify.displayEnterprisePlanHasExpiredModal(true, this.prjct_profile_name, this.subscription_end_date); } } } else { this.notify.closeDataExportNotAvailable() this.notify.presentModalOnlyOwnerCanManageTheAccountPlan(this.onlyOwnerCanManageTheAccountPlanMsg, this.learnMoreAboutDefaultRoles); } }
// }
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/ui/notification-message/notification-message.component.ts#L197-L219
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
NotificationMessageComponent.copyToClipboard
copyToClipboard() { document.querySelector('textarea').select(); document.execCommand('copy'); this.has_copied = true; setTimeout(() => { this.has_copied = false; }, 2000); }
// ----------------------------------------
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/ui/notification-message/notification-message.component.ts#L254-L262
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
NotificationMessageComponent.openChat
openChat() { // localStorage.setItem('chatOpened', 'true'); const url = this.CHAT_BASE_URL; window.open(url, '_blank'); this.notify.publishHasClickedChat(true); }
// ----------------------------------------
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/ui/notification-message/notification-message.component.ts#L267-L272
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
NotificationMessageComponent.goToWidgetPage
goToWidgetPage() { this.router.navigate(['project/' + this.project._id + '/widget']); this.notify.closeModalInstallTiledeskModal() }
// ----------------------------------------
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/ui/notification-message/notification-message.component.ts#L277-L280
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ProjectPlanUtils.hideActionCategory
private hideActionCategory(actionType: TYPE_ACTION_CATEGORY){ this.logger.log('[PROJECT_PROFILE] hideActionType', actionType); //MANAGE ACTION CATEGORIES let index = ACTION_CATEGORY.findIndex(el => el.type === getKeyByValue(actionType, TYPE_ACTION_CATEGORY)); if(index > -1){ ACTION_CATEGORY.splice(index,1) } //MANAGE ACTION LIST Object.values(ACTIONS_LIST).filter(el => el.category == actionType).map( el => el.status = 'inactive') //MANAGE VOICE ATTRIBUTES LIST if(actionType === TYPE_ACTION_CATEGORY.VOICE){ let index = variableList.findIndex(el => el.key === 'voiceFlow') if(index > -1){ variableList.splice(index,1) } } }
/** hide action by * 1. CATEGORY TYPE * 2. ACTION LIST * 3. ATTRIBUTE LIST ASSOCIATED WITH */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/utils/project-utils.ts#L213-L233
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ProjectPlanUtils.hideAction
private hideAction(action: TYPE_ACTION | TYPE_ACTION_VXML){ let actionType: TYPE_ACTION_CATEGORY = Object.values(ACTIONS_LIST).find(el => el.type == action).category Object.values(ACTIONS_LIST).filter(el => el.type == action).map( el => el.status = 'inactive') //MANAGE ACTION CATEGORIES let actions = Object.values(ACTIONS_LIST).filter(el => (el.category == actionType && el.status === 'active')) if(actions.length === 0){ let index = ACTION_CATEGORY.findIndex(el => el.type === getKeyByValue(actionType, TYPE_ACTION_CATEGORY)); if(index > -1){ ACTION_CATEGORY.splice(index,1) } } }
/** hide action by * 1. ACTION LIST * 2. if no ACTION of same type exist, remove CTEGORY */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/utils/project-utils.ts#L239-L252
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ProjectPlanUtils.checkActionCanShow
private checkActionCanShow(action: TYPE_ACTION | TYPE_ACTION_VXML){ let status = this.checkIfIsEnabledInProject(action) if(!status){ this.hideAction(action) } }
/** CHECK IF ACTION IS IN 'customization' * IF NOT: * --- remove action type from list */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/utils/project-utils.ts#L258-L263
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ProjectPlanUtils.checkActionCanShowInFT
private checkActionCanShowInFT(feature: string, action: TYPE_ACTION | TYPE_ACTION_VXML){ this.logger.log('[PROJECT_PROFILE] checkIfCategoryCanLoad -->', feature, action); let status = true; // --1: check into env let public_Key = this.appConfigService.getConfig().t2y12PruGU9wUtEGzBJfolMIgK; let keys = public_Key.split("-"); this.logger.log('[PROJECT_PROFILE] checkIfCategoryCanLoad keys -->', keys); if (public_Key.includes(feature) === true) { keys.forEach(key => { // this.logger.log('NavbarComponent public_Key key', key) if (key.includes(feature)) { // this.logger.log('PUBLIC-KEY (TRY_ON_WA) - key', key); let tow = key.split(":"); // this.logger.log('PUBLIC-KEY (TRY_ON_WA) - mt key&value', mt); if (tow[1] === "F") { this.hideAction(action) return; } } }); }else { this.logger.log('[PROJECT_PROFILE] keys KNB not exist', keys); this.hideAction(action) return; } }
/** CHECK IF ACTION IS IN 'feature-token' * IF NOT: * --- remove action type from list */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/utils/project-utils.ts#L269-L295
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ChatManager.initialize
initialize() { const appconfig = this.appConfigService.getConfig(); this.tenant = appconfig.firebaseConfig.tenant; this.logger.log('[CHAT MANAGER] - initialize -> firebaseConfig tenant ', this.tenant); this.handlers = []; this.openInfoConversation = true; this.currentUser = null; this.logger.log('[CHAT MANAGER]- initialize -> this.handlers', this.handlers); }
/** * inizializza chatmanager */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/chat21-core/providers/chat-manager.ts#L46-L54
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ChatManager.setTiledeskToken
public setTiledeskToken(tiledeskToken: string) { this.logger.log('initialize FROM [APP-COMP] - [CHAT MANAGER] - initialize -> firebaseConfig tenant ', this.tenant); this.tiledeskToken = tiledeskToken; }
/** * setTiledeskToken */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/chat21-core/providers/chat-manager.ts#L59-L62
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ChatManager.getTiledeskToken
public getTiledeskToken(): string { return this.tiledeskToken; }
/** * return tiledeskToken */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/chat21-core/providers/chat-manager.ts#L67-L69
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ChatManager.setCurrentUser
public setCurrentUser(currentUser: UserModel) { this.logger.log('initialize FROM [APP-COMP] - [CHAT MANAGER] setCurrentUser currentUser ', currentUser) this.currentUser = currentUser; }
/** * setCurrentUser */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/chat21-core/providers/chat-manager.ts#L74-L77
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ChatManager.getCurrentUser
public getCurrentUser(): UserModel { return this.currentUser; }
/** * return current user detail */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/chat21-core/providers/chat-manager.ts#L82-L84
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ChatManager.getOpenInfoConversation
getOpenInfoConversation(): boolean { return this.openInfoConversation; }
/** * */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/chat21-core/providers/chat-manager.ts#L92-L94
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ChatManager.dispose
dispose() { this.logger.debug('[CHAT MANAGER] 1 - setOffAllReferences'); if (this.handlers) { this.setOffAllReferences(); } this.logger.debug('[CHAT MANAGER] 2 - disposeConversationsHandler'); if (this.conversationsHandlerService) { this.disposeConversationsHandler(); } this.logger.debug('[CHAT MANAGER] 3 - disposeArchivedConversationsHandler'); if (this.archivedConversationsService) { this.disposeArchivedConversationsHandler(); } this.logger.debug('[CHAT MANAGER] 4 - disposeContactsSynchronizer'); // if (this.contactsSynchronizer) { this.disposeContactsSynchronizer(); } this.logger.debug('[CHAT MANAGER] OKK '); this.conversationsHandlerService = null; this.archivedConversationsService = null; // this.contactsSynchronizer = null; }
/** * dispose all references * dispose refereces messaggi di ogni conversazione * dispose reference conversazioni * dispose reference sincronizzazione contatti */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/chat21-core/providers/chat-manager.ts#L101-L114
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ChatManager.goOffLine
goOffLine() { this.currentUser = null; // cancello token e user dal localstorage!!!!! this.logger.debug('[CHAT MANAGER] 1 - CANCELLO TUTTE LE REFERENCES'); this.dispose(); }
/** * invocato da user.ts al LOGOUT: * 1 - cancello tutte le references * 2 - pubblico stato loggedUser come logout */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/chat21-core/providers/chat-manager.ts#L159-L164
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ChatManager.addConversationHandler
addConversationHandler(handler: ConversationHandlerService) { this.logger.debug('[CHAT MANAGER] -----> addConversationHandler', this.handlers, handler); this.handlers.push(handler); }
/** * aggiungo la conversazione all'array delle conversazioni * chiamato dall'inizialize di dettaglio-conversazione.ts * @param handler */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/chat21-core/providers/chat-manager.ts#L172-L175
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ChatManager.removeConversationHandler
removeConversationHandler(conversationId) { this.logger.debug('[CHAT MANAGER] -----> removeConversationHandler: ', conversationId); const index = this.handlers.findIndex(i => i.conversationWith === conversationId); this.handlers.splice(index, 1); }
/** * rimuovo dall'array degli handlers delle conversazioni una conversazione * al momento non è utilizzato!!! * @param conversationId */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/chat21-core/providers/chat-manager.ts#L182-L186
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ChatManager.getConversationHandlerByConversationId
getConversationHandlerByConversationId(conversationId): any { let handler = null; this.handlers.forEach(conv => { // this.logger.('[CHAT MANAGER]forEach ***', conversationId, this.handlers, conv); if (conv.conversationWith === conversationId) { handler = conv; return; } }); return handler; // const resultArray = this.handlers.filter((handler) => { // this.logger.('[CHAT MANAGER]FILTRO::: ***', conversationId, handler.conversationWith); // return handler.conversationWith === conversationId; // }); // if (resultArray.length === 0) { // return null; // } // return resultArray[0]; }
/** * cerco e ritorno una conversazione dall'array delle conversazioni * con conversationId coincidente con conversationId passato * chiamato dall'inizialize di dettaglio-conversazione.ts * @param conversationId */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/chat21-core/providers/chat-manager.ts#L194-L214
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ChatManager.setOffAllReferences
setOffAllReferences() { this.handlers.forEach((data) => { // const item = data.ref; // item.ref.off(); }); this.handlers = []; }
/** * elimino tutti gli hendler presenti nell'array handlers * dopo aver cancellato la reference per ogni handlers */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/chat21-core/providers/chat-manager.ts#L220-L226
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ChatManager.setConversationsHandler
setConversationsHandler(handler) { this.conversationsHandlerService = handler; }
/** * Salvo il CONVERSATIONS handler dopo averlo creato nella lista conversazioni */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/chat21-core/providers/chat-manager.ts#L233-L235
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ChatManager.disposeConversationsHandler
disposeConversationsHandler() { this.logger.debug('[CHAT MANAGER] 2 - this.conversationsHandler:: ', this.conversationsHandlerService); this.conversationsHandlerService.dispose(); }
/** * elimino la reference dell'handler delle conversazioni */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/chat21-core/providers/chat-manager.ts#L243-L246
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ChatManager.disposeArchivedConversationsHandler
disposeArchivedConversationsHandler() { this.logger.debug('[CHAT MANAGER] 3 - this.archivedConversationsService:: ', this.archivedConversationsService); this.archivedConversationsService.dispose(); }
/** * elimino la reference dell'handler delle conversazioni archiviate */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/chat21-core/providers/chat-manager.ts#L251-L254
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CustomTranslateService.translateLanguage
public translateLanguage(keys: any, lang?: string): Map<string, string> { // if (!lang || lang === '') { // this.language = this.translateService.currentLang; // } else { // this.language = lang; // } // this.translateService.use(this.language); return this.initialiseTranslation(keys); }
/** */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/chat21-core/providers/custom-translate.service.ts#L21-L29
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CustomTranslateService.initialiseTranslation
private initialiseTranslation(keys): Map<string, string> { const mapTranslate = new Map(); keys.forEach((key: string) => { this.translateService.get(key).subscribe((res: string) => { mapTranslate.set(key, res); }); }); return mapTranslate; }
/** */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/chat21-core/providers/custom-translate.service.ts#L32-L40
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
LocalSessionStorage.getItem
getItem(key: string) { let prefix; try { // const sv = 'sv' + environment.shemaVersion + '_'; // prefix = prefix + sv; prefix = this.storagePrefix + '_'; } catch (e) { this.logger.error('[LocalSessionStorage] getItem - Error :' + e); } const newKey = prefix + this.projectID + '_' + key; return this.getValueForKey(newKey); }
/** GET item in local/session storage from key value * @param key */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/chat21-core/providers/localSessionStorage.ts#L27-L38
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
LocalSessionStorage.setItem
setItem(key: string, value: any): void { // this.removeItem(key); let prefix; try { // const sv = 'sv' + environment.shemaVersion + '_'; // prefix = prefix + sv; prefix = this.storagePrefix + '_'; } catch (e) { this.logger.error('[LocalSessionStorage] setItem > Error :' + e); } const newKey = prefix + this.projectID + '_' + key; this.saveValueForKey(newKey, value); }
/** SET new item in local/session storage * @param key * @param value */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/chat21-core/providers/localSessionStorage.ts#L44-L56
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
LocalSessionStorage.removeItem
removeItem(key: string): void { let prefix; try { // const sv = 'sv' + environment.shemaVersion + '_'; // prefix = prefix + sv; prefix = this.storagePrefix + '_'; } catch (e) { this.logger.error('[LocalSessionStorage] removeItem > Error :' + e); } const newKey = prefix + this.projectID + '_' + key; return this.removeItemForKey(newKey); }
// }
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/chat21-core/providers/localSessionStorage.ts#L93-L104
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
LocalSessionStorage.getValueForKey
private getValueForKey(key) { if (this.persistence === 'local' || this.persistence === 'LOCAL') { if (supports_html5_storage()) { return localStorage.getItem(key); } else { this.logger.warn('localStorage is not defind. Storage disabled'); return null; } } else if (this.persistence === 'session' || this.persistence === 'SESSION') { if (supports_html5_session()) { return sessionStorage.getItem(key); } else { this.logger.warn('sessionStorage is not defind. Storage disabled'); return null; } } else if (this.persistence === 'none' || this.persistence === 'NONE') { return null; } else { if (supports_html5_storage()) { return localStorage.getItem(key); } else { this.logger.warn('localStorage is not defind. Storage disabled'); return null; } } }
// ---------- PRIVATE METHODS start --------------- //
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/chat21-core/providers/localSessionStorage.ts#L134-L159
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
FirebaseArchivedConversationsHandler.initialize
async initialize(tenant: string, userId: string, translationMap: Map<string, string>) { this.logger.log('initialize FROM [APP-COMP] - FIREBASEArchivedConversationsHandlerSERVICE] tenant ', tenant, ' - userId: ', userId, ' - translationMap: ', translationMap) this.tenant = tenant; this.loggedUserId = userId; this.translationMap = translationMap; this.archivedConversations = []; this.isConversationClosingMap = new Map(); const { default: firebase} = await import("firebase/app"); await Promise.all([import("firebase/database"), import("firebase/auth")]); this.firebase = firebase this.ref = this.firebase.database['Query']; }
/** * inizializzo conversations handler */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/chat21-core/providers/firebase/firebase-archivedconversations-handler.ts#L58-L70
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
FirebaseArchivedConversationsHandler.subscribeToConversations
subscribeToConversations(callback: any) { const that = this; const urlNodeFirebase = archivedConversationsPathForUserId(this.tenant, this.loggedUserId); this.logger.debug('[FIREBASEArchivedConversationsHandlerSERVICE] SubscribeToConversations conversations::ARCHIVED urlNodeFirebase', urlNodeFirebase) this.ref = this.firebase.database().ref(urlNodeFirebase).orderByChild('timestamp').limitToLast(200); this.ref.on('child_changed', (childSnapshot) => { that.changed(childSnapshot); }); this.ref.on('child_removed', (childSnapshot) => { that.removed(childSnapshot); }); this.ref.on('child_added', (childSnapshot) => { that.added(childSnapshot); }); setTimeout(() => { callback() }, 2000); // SET AUDIO // this.audio = new Audio(); // this.audio.src = URL_SOUND; // this.audio.load(); }
//----------------------------------------------------------------------------------
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/chat21-core/providers/firebase/firebase-archivedconversations-handler.ts#L97-L119
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
FirebaseArchivedConversationsHandler.countIsNew
countIsNew(): number { let num = 0; this.archivedConversations.forEach((element) => { if (element.is_new === true) { num++; } }); return num; }
/** * restituisce il numero di conversazioni nuove */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/chat21-core/providers/firebase/firebase-archivedconversations-handler.ts#L126-L134
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
FirebaseArchivedConversationsHandler.setConversationRead
setConversationRead(conversationrecipient): void { this.logger.log('[CONVS-DETAIL][FB-ARCHIVED] updateConversationBadge: '); const urlUpdate = archivedConversationsPathForUserId(this.tenant, this.loggedUserId) + '/' + conversationrecipient; const update = {}; update['/is_new'] = false; this.firebase.database().ref(urlUpdate).update(update); }
//imposto la conversazione come: letta
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/chat21-core/providers/firebase/firebase-archivedconversations-handler.ts#L137-L143
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
FirebaseArchivedConversationsHandler.getClosingConversation
getClosingConversation(conversationId: string) { return this.isConversationClosingMap[conversationId]; }
/** * Returns the status of the conversations with conversationId from isConversationClosingMap * @param conversationId the conversation id * @returns true if the conversation is waiting to be closed, false otherwise */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/chat21-core/providers/firebase/firebase-archivedconversations-handler.ts#L151-L153
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
FirebaseArchivedConversationsHandler.setClosingConversation
setClosingConversation(conversationId: string, status: boolean) { this.isConversationClosingMap[conversationId] = status; }
/** * Add the conversation with conversationId to the isConversationClosingMap * @param conversationId the id of the conversation of which it wants to save the state * @param status true if the conversation is waiting to be closed, false otherwise */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/chat21-core/providers/firebase/firebase-archivedconversations-handler.ts#L160-L162
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
FirebaseArchivedConversationsHandler.deleteClosingConversation
deleteClosingConversation(conversationId: string) { this.isConversationClosingMap.delete(conversationId); }
/** * Delete the conversation with conversationId from the isConversationClosingMap * @param conversationId the id of the conversation of which is wants to delete */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/chat21-core/providers/firebase/firebase-archivedconversations-handler.ts#L168-L170
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
FirebaseArchivedConversationsHandler.dispose
dispose() { this.archivedConversations = []; this.uidConvSelected = ''; //this.ref.off(); // this.ref.off("child_changed"); // this.ref.off("child_removed"); // this.ref.off("child_added"); this.logger.debug('[FIREBASEArchivedConversationsHandlerSERVICE] DISPOSE::: ', this.ref) }
/** * dispose reference di conversations */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/chat21-core/providers/firebase/firebase-archivedconversations-handler.ts#L215-L223
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
FirebaseArchivedConversationsHandler.conversationGenerate
private conversationGenerate(childSnapshot: any): boolean { const childData: ConversationModel = childSnapshot.val(); childData.uid = childSnapshot.key; const conversation = this.completeConversation(childData); if (this.isValidConversation(conversation)) { this.setClosingConversation(childSnapshot.key, false); const index = searchIndexInArrayForUid(this.archivedConversations, conversation.uid); if (index > -1) { this.archivedConversations.splice(index, 1, conversation); } else { this.archivedConversations.splice(0, 0, conversation); } //this.databaseProvider.setConversation(conversation); this.archivedConversations.sort(compareValues('timestamp', 'desc')); return true; } else { return false; } }
// */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/chat21-core/providers/firebase/firebase-archivedconversations-handler.ts#L248-L266
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
FirebaseArchivedConversationsHandler.added
private added(childSnapshot: any) { if (this.conversationGenerate(childSnapshot)) { const index = searchIndexInArrayForUid(this.archivedConversations, childSnapshot.key); if (index > -1) { const conversationAdded = this.archivedConversations[index] this.archivedConversationAdded.next(conversationAdded); } } else { // this.logger.error('[FIREBASEArchivedConversationsHandlerSERVICE] ADDED::conversations with conversationId: ', childSnapshot.key, 'is not valid') } }
/** * 1 - completo la conversazione con i parametri mancanti * 2 - verifico che sia una conversazione valida * 3 - salvo stato conversazione (false) nell'array delle conversazioni chiuse * 4 - aggiungo alla pos 0 la nuova conversazione all'array di conversazioni * o sostituisco la conversazione con quella preesistente * 5 - salvo la conversazione nello storage * 6 - ordino l'array per timestamp * 7 - pubblico conversations:update */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/chat21-core/providers/firebase/firebase-archivedconversations-handler.ts#L306-L316
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
FirebaseArchivedConversationsHandler.changed
private changed(childSnapshot: any) { if (this.conversationGenerate(childSnapshot)) { const index = searchIndexInArrayForUid(this.archivedConversations, childSnapshot.key); if (index > -1) { const conversationChanged = this.archivedConversations[index] this.archivedConversationChanged.next(conversationChanged); } } else { this.logger.error('[FIREBASEArchivedConversationsHandlerSERVICE] CHANGED::conversations with conversationId: ', childSnapshot.key, 'is not valid') } }
/** * 1 - completo la conversazione con i parametri mancanti * 2 - verifico che sia una conversazione valida * 3 - aggiungo alla pos 0 la nuova conversazione all'array di conversazioni * 4 - salvo la conversazione nello storage * 5 - ordino l'array per timestamp * 6 - pubblico conversations:update * 7 - attivo sound se è un msg nuovo */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/chat21-core/providers/firebase/firebase-archivedconversations-handler.ts#L328-L338
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
FirebaseArchivedConversationsHandler.removed
private removed(childSnapshot: any) { const index = searchIndexInArrayForUid(this.archivedConversations, childSnapshot.key); if (index > -1) { const conversationRemoved = this.archivedConversations[index] this.archivedConversations.splice(index, 1); // this.conversations.sort(compareValues('timestamp', 'desc')); //this.databaseProvider.removeConversation(childSnapshot.key); this.archivedConversationRemoved.next(conversationRemoved); } // remove the conversation from the isConversationClosingMap this.deleteClosingConversation(childSnapshot.key); }
/** * 1 - cerco indice conversazione da eliminare * 2 - elimino conversazione da array conversations * 3 - elimino la conversazione dallo storage * 4 - pubblico conversations:update * 5 - elimino conversazione dall'array delle conversazioni chiuse */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/chat21-core/providers/firebase/firebase-archivedconversations-handler.ts#L347-L358
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
FirebaseArchivedConversationsHandler.completeConversation
private completeConversation(conv): ConversationModel { conv.selected = false; if (!conv.sender_fullname || conv.sender_fullname === 'undefined' || conv.sender_fullname.trim() === '') { conv.sender_fullname = conv.sender; } if (!conv.recipient_fullname || conv.recipient_fullname === 'undefined' || conv.recipient_fullname.trim() === '') { conv.recipient_fullname = conv.recipient; } let conversation_with_fullname = conv.sender_fullname; let conversation_with = conv.sender; if (conv.sender === this.loggedUserId) { conversation_with = conv.recipient; conversation_with_fullname = conv.recipient_fullname; conv.sender_fullname = this.translationMap.get('YOU') // conv.last_message_text = YOU + conv.last_message_text; // } else if (conv.channel_type === TYPE_GROUP) { } else if (isGroup(conv)) { // conversation_with_fullname = conv.sender_fullname; // conv.last_message_text = conv.last_message_text; conversation_with = conv.recipient; conversation_with_fullname = conv.recipient_fullname; } // Fixes the bug: if a snippet of code is pasted and sent it is not displayed correctly in the archived convesations list conv.conversation_with = conversation_with; conv.conversation_with_fullname = conversation_with_fullname; conv.status = this.setStatusConversation(conv.sender, conv.uid); conv.time_last_message = getTimeLastMessage(conv.timestamp); // evaluate if is used conv.avatar = avatarPlaceholder(conversation_with_fullname); conv.color = getColorBck(conversation_with_fullname); conv.archived = true; //conv.image = this.imageRepo.getImagePhotoUrl(conversation_with); return conv; }
/** * Completo conversazione aggiungendo: * 1 - nel caso in cui sender_fullname e recipient_fullname sono vuoti, imposto i rispettivi id come fullname, * in modo da avere sempre il campo fullname popolato * 2 - imposto conversation_with e conversation_with_fullname con i valori del sender o al recipient, * a seconda che il sender corrisponda o meno all'utente loggato. Aggiungo 'tu:' se il sender coincide con il loggedUser * Se il sender NON è l'utente loggato, ma è una conversazione di tipo GROUP, il conversation_with_fullname * sarà uguale al recipient_fullname * 3 - imposto stato conversazione, che indica se ci sono messaggi non letti nella conversazione * 4 - imposto il tempo trascorso tra l'ora attuale e l'invio dell'ultimo messaggio * 5 - imposto avatar, colore e immagine * @param conv */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/chat21-core/providers/firebase/firebase-archivedconversations-handler.ts#L374-L406
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
FirebaseArchivedConversationsHandler.setStatusConversation
private setStatusConversation(sender: string, uid: string): string { let status = '0'; // letto if (sender === this.loggedUserId || uid === this.uidConvSelected) { status = '0'; } else { status = '1'; // non letto } return status; }
/** */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/chat21-core/providers/firebase/firebase-archivedconversations-handler.ts#L409-L417
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
FirebaseArchivedConversationsHandler.isValidConversation
private isValidConversation(convToCheck: ConversationModel): boolean { if (!this.isValidField(convToCheck.uid)) { return false; } if (!this.isValidField(convToCheck.is_new)) { return false; } if (!this.isValidField(convToCheck.last_message_text)) { return false; } if (!this.isValidField(convToCheck.recipient)) { return false; } if (!this.isValidField(convToCheck.recipient_fullname)) { return false; } if (!this.isValidField(convToCheck.sender)) { return false; } if (!this.isValidField(convToCheck.sender_fullname)) { return false; } if (!this.isValidField(convToCheck.status)) { return false; } if (!this.isValidField(convToCheck.timestamp)) { return false; } if (!this.isValidField(convToCheck.channel_type)) { return false; } return true; }
/** * check if the conversations is valid or not */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/chat21-core/providers/firebase/firebase-archivedconversations-handler.ts#L422-L454
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
FirebaseArchivedConversationsHandler.isValidField
private isValidField(field: any): boolean { return (field === null || field === undefined) ? false : true; }
/** * * @param field */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/chat21-core/providers/firebase/firebase-archivedconversations-handler.ts#L460-L462
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
FirebaseAuthService.initialize
async initialize() { this.SERVER_BASE_URL = this.getBaseUrl(); this.URL_TILEDESK_CREATE_CUSTOM_TOKEN = this.SERVER_BASE_URL + 'chat21/firebase/auth/createCustomToken'; this.logger.debug('[FIREBASEAuthSERVICE] - initialize URL_TILEDESK_CREATE_CUSTOM_TOKEN ', this.URL_TILEDESK_CREATE_CUSTOM_TOKEN) // this.checkIsAuth(); const { default: firebase} = await import("firebase/app"); await Promise.all([import("firebase/auth")]); this.firebase = firebase this.onAuthStateChanged(); }
/** * */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/chat21-core/providers/firebase/firebase-auth-service.ts#L46-L57
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
FirebaseAuthService.getToken
getToken(): string { return this.firebaseToken; }
/** */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/chat21-core/providers/firebase/firebase-auth-service.ts#L85-L87
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
FirebaseAuthService.onAuthStateChanged
onAuthStateChanged() { const that = this; this.firebase.auth().onAuthStateChanged(user => { this.logger.debug('[FIREBASEAuthSERVICE] onAuthStateChanged', user) if (!user) { this.logger.debug('[FIREBASEAuthSERVICE] 1 - PUBLISH OFFLINE to chat-manager') that.BSAuthStateChanged.next('offline'); } else { this.logger.debug('[FIREBASEAuthSERVICE] 2 - PUBLISH ONLINE to chat-manager') that.BSAuthStateChanged.next('online'); } }); }
/** * FIREBASE: onAuthStateChanged */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/chat21-core/providers/firebase/firebase-auth-service.ts#L94-L107
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
FirebaseAuthService.signInFirebaseWithCustomToken
signInFirebaseWithCustomToken(token: string): Promise<any> { const that = this; let firebasePersistence; switch (this.getPersistence()) { case 'SESSION': { firebasePersistence = this.firebase.auth.Auth.Persistence.SESSION; break; } case 'LOCAL': { firebasePersistence = this.firebase.auth.Auth.Persistence.LOCAL; break; } case 'NONE': { firebasePersistence = this.firebase.auth.Auth.Persistence.NONE; break; } default: { firebasePersistence = this.firebase.auth.Auth.Persistence.NONE; break; } } return that.firebase.auth().setPersistence(firebasePersistence).then(async () => { return that.firebase.auth().signInWithCustomToken(token).then(async () => { // that.firebaseSignInWithCustomToken.next(response); }).catch((error) => { that.logger.error('[FIREBASEAuthSERVICE] signInFirebaseWithCustomToken Error: ', error); // that.firebaseSignInWithCustomToken.next(null); }); }).catch((error) => { that.logger.error('[FIREBASEAuthSERVICE] signInFirebaseWithCustomToken Error: ', error); }); }
/** * FIREBASE: signInWithCustomToken * @param token */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/chat21-core/providers/firebase/firebase-auth-service.ts#L113-L144
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
FirebaseAuthService.createUserWithEmailAndPassword
createUserWithEmailAndPassword(email: string, password: string): any { const that = this; return this.firebase.auth().createUserWithEmailAndPassword(email, password).then((response) => { that.logger.debug('[FIREBASEAuthSERVICE] CRATE USER WITH EMAIL: ', email, ' & PSW: ', password); // that.firebaseCreateUserWithEmailAndPassword.next(response); return response; }).catch((error) => { that.logger.error('[FIREBASEAuthSERVICE] createUserWithEmailAndPassword error: ', error.message); return error; }); }
/** * FIREBASE: createUserWithEmailAndPassword * @param email * @param password * @param firstname * @param lastname */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/chat21-core/providers/firebase/firebase-auth-service.ts#L153-L163
297d30da01d98a1299e7197eb88cff5b2390a386