feat(notifications): add notifications to schema
This commit is contained in:
parent
043bc91a56
commit
c75bbb445e
|
|
@ -16,6 +16,7 @@ model Users {
|
|||
phone_number String
|
||||
residence String?
|
||||
role Roles @default(EMPLOYEE)
|
||||
notifications Notifications? @relation("UserNotification")
|
||||
employee Employees? @relation("UserEmployee")
|
||||
oauth_sessions OAuthSessions[] @relation("UserOAuthSessions")
|
||||
preferences Preferences? @relation("UserPreferences")
|
||||
|
|
@ -24,6 +25,20 @@ model Users {
|
|||
@@map("users")
|
||||
}
|
||||
|
||||
model Notifications {
|
||||
id Int @id @default(autoincrement())
|
||||
user_id String @unique @db.Uuid
|
||||
affected_module Modules
|
||||
subject String
|
||||
description String
|
||||
metadata Json @db.JsonB
|
||||
created_at DateTime @default(now())
|
||||
viewed_at DateTime?
|
||||
user Users @relation("UserNotification", fields: [user_id], references: [id])
|
||||
|
||||
@@map("notifications")
|
||||
}
|
||||
|
||||
model userModuleAccess {
|
||||
id Int @id @default(autoincrement())
|
||||
user_id String @unique @db.Uuid
|
||||
|
|
|
|||
15
prisma/postgres/scripts/create-table-notifications.sql
Normal file
15
prisma/postgres/scripts/create-table-notifications.sql
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
CREATE TABLE notifications (
|
||||
id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
user_id uuid NOT NULL,
|
||||
affected_module text,
|
||||
subject text NOT NULL,
|
||||
description text,
|
||||
metadata jsonb,
|
||||
created_at timestamptz NOT NULL DEFAULT now(),
|
||||
viewed_at timestamptz NULL,
|
||||
|
||||
CONSTRAINT notifications_user_id_fkey
|
||||
FOREIGN KEY (user_id)
|
||||
REFERENCES users(id)
|
||||
ON DELETE CASCADE
|
||||
);
|
||||
|
|
@ -3,7 +3,6 @@ import { UserMessageDto } from 'src/chatbot/dtos/user-message.dto';
|
|||
import { HttpService } from '@nestjs/axios';
|
||||
import { firstValueFrom } from 'rxjs';
|
||||
import { Message } from 'src/chatbot/dtos/dialog-message.dto';
|
||||
import { AxiosError, isAxiosError } from 'axios';
|
||||
|
||||
@Injectable()
|
||||
export class ChatbotService {
|
||||
|
|
@ -12,13 +11,16 @@ export class ChatbotService {
|
|||
|
||||
async pingExternalApi(body: UserMessageDto, email: string): Promise<Message> {
|
||||
try {
|
||||
const { data } = await firstValueFrom(this.httpService.post(
|
||||
const response = await firstValueFrom(this.httpService.post(
|
||||
'https://n8nai.targo.ca/webhook/chatty-Mcbot',
|
||||
{ userInput: body.userInput, userId: email, sessionId: this.sessionId, pageContext: body.pageContext ?? undefined }
|
||||
));
|
||||
|
||||
console.log('chatbot data received: ', response);
|
||||
|
||||
return {
|
||||
text: data[0].output,
|
||||
// text: data[0].output,
|
||||
text: 'success',
|
||||
sent: false,
|
||||
};
|
||||
} catch (error) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user