botserver/packages/analytics.gblib/services/AnalyticsService.ts

78 lines
4 KiB
TypeScript
Raw Normal View History

2018-04-21 02:59:30 -03:00
/*****************************************************************************\
2024-01-09 17:40:48 -03:00
| ® |
| |
| |
| |
| |
2018-04-21 02:59:30 -03:00
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
2018-04-21 02:59:30 -03:00
| Licensed under the AGPL-3.0. |
2018-11-11 19:09:18 -02:00
| |
2018-04-21 02:59:30 -03:00
| According to our dual licensing model, this program can be used either |
| under the terms of the GNU Affero General Public License, version 3, |
| or under a proprietary license. |
| |
| The texts of the GNU Affero General Public License with an additional |
| permission and of our proprietary license can be found at and |
| in the LICENSE file you have received along with this program. |
| |
| This program is distributed in the hope that it will be useful, |
2018-09-11 19:40:53 -03:00
| but WITHOUT ANY WARRANTY, without even the implied warranty of |
2018-04-21 02:59:30 -03:00
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU Affero General Public License for more details. |
| |
| "General Bots" is a registered trademark of pragmatismo.com.br. |
2018-04-21 02:59:30 -03:00
| The licensing of the program under the AGPLv3 does not imply a |
| trademark license. Therefore any rights, title and interest in |
| our trademarks remain entirely with us. |
| |
\*****************************************************************************/
2018-11-11 19:09:18 -02:00
/**
* @fileoverview General Bots server core.
*/
2022-01-03 13:11:21 -03:00
import { FindOptions } from 'sequelize/types';
import { GBServer } from '../../../src/app.js';
import { GuaribasUser } from '../../security.gbapp/models/index.js';
import { GuaribasConversation, GuaribasConversationMessage } from '../models/index.js';
2018-04-21 02:59:30 -03:00
/**
* Base services for Bot Analytics.
*/
2018-04-21 02:59:30 -03:00
export class AnalyticsService {
2025-09-21 16:49:03 -03:00
public async createConversation(user: GuaribasUser): Promise<GuaribasConversation> {
const conversation = new GuaribasConversation();
conversation.startedBy = user;
conversation.startedByUserId = user.userId;
conversation.instanceId = user.instanceId;
return await conversation.save();
2018-04-21 02:59:30 -03:00
}
2025-09-21 16:49:03 -03:00
public async updateConversationSuggestion(
2022-11-19 23:34:58 -03:00
instanceId: number,
conversationId: string,
feedback: string,
locale: string
): Promise<number> {
const minBoot = GBServer.globals.minBoot as any;
2025-09-21 16:49:03 -03:00
return 0;
}
2025-09-21 16:49:03 -03:00
public async createMessage(
instanceId: number,
conversationId: number,
2020-06-04 16:18:02 -03:00
userId: number,
2018-09-09 14:39:37 -03:00
content: string
): Promise<GuaribasConversationMessage> {
const message = GuaribasConversationMessage.build();
2022-11-19 23:34:58 -03:00
message.content = typeof content === 'object' ? JSON.stringify(content) : content;
message.instanceId = instanceId;
2020-06-04 16:18:02 -03:00
message.userId = userId;
message.conversationId = conversationId;
return await message.save();
2018-04-21 02:59:30 -03:00
}
}