Move in progress apps temporarily
This commit is contained in:
parent
ba04aa108c
commit
6eaaf8e9be
360 changed files with 6171 additions and 55 deletions
24
fix/metamigo-db/records/whatsapp/attachments.ts
Normal file
24
fix/metamigo-db/records/whatsapp/attachments.ts
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import { RepositoryBase, recordInfo, UUID, Flavor } from "common";
|
||||
|
||||
export type WhatsappAttachmentId = Flavor<UUID, "Whatsapp Attachment Id">;
|
||||
|
||||
export interface UnsavedWhatsappAttachment {
|
||||
whatsappBotId: string;
|
||||
whatsappMessageId: string;
|
||||
attachment: Buffer;
|
||||
}
|
||||
|
||||
export interface SavedWhatsappAttachment extends UnsavedWhatsappAttachment {
|
||||
id: WhatsappAttachmentId;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
}
|
||||
|
||||
export const WhatsappAttachmentRecord = recordInfo<
|
||||
UnsavedWhatsappAttachment,
|
||||
SavedWhatsappAttachment
|
||||
>("app_public", "whatsapp_attachments");
|
||||
|
||||
export class WhatsappAttachmentRecordRepository extends RepositoryBase(
|
||||
WhatsappAttachmentRecord
|
||||
) { }
|
||||
48
fix/metamigo-db/records/whatsapp/bots.ts
Normal file
48
fix/metamigo-db/records/whatsapp/bots.ts
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
import { RepositoryBase, recordInfo, UUID, Flavor } from "common";
|
||||
|
||||
export type WhatsappBotId = Flavor<UUID, "Whatsapp Bot Id">;
|
||||
|
||||
export interface UnsavedWhatsappBot {
|
||||
phoneNumber: string;
|
||||
userId: string;
|
||||
description: string;
|
||||
}
|
||||
|
||||
export interface SavedWhatsappBot extends UnsavedWhatsappBot {
|
||||
id: WhatsappBotId;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
token: string;
|
||||
authInfo: string;
|
||||
qrCode: string;
|
||||
isVerified: boolean;
|
||||
}
|
||||
|
||||
export const WhatsappBotRecord = recordInfo<
|
||||
UnsavedWhatsappBot,
|
||||
SavedWhatsappBot
|
||||
>("app_public", "whatsapp_bots");
|
||||
|
||||
export class WhatsappBotRecordRepository extends RepositoryBase(
|
||||
WhatsappBotRecord
|
||||
) {
|
||||
async updateQR(
|
||||
bot: SavedWhatsappBot,
|
||||
qrCode: string | undefined
|
||||
): Promise<SavedWhatsappBot> {
|
||||
return this.db.one(
|
||||
"UPDATE $1 SET (qr_code) = ROW($2) WHERE id = $3 RETURNING *",
|
||||
[this.schemaTable, qrCode, bot.id]
|
||||
);
|
||||
}
|
||||
|
||||
async updateAuthInfo(
|
||||
bot: SavedWhatsappBot,
|
||||
authInfo: string | undefined
|
||||
): Promise<SavedWhatsappBot> {
|
||||
return this.db.one(
|
||||
"UPDATE $1 SET (auth_info, is_verified) = ROW($2, true) WHERE id = $3 RETURNING *",
|
||||
[this.schemaTable, authInfo, bot.id]
|
||||
);
|
||||
}
|
||||
}
|
||||
26
fix/metamigo-db/records/whatsapp/messages.ts
Normal file
26
fix/metamigo-db/records/whatsapp/messages.ts
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import { RepositoryBase, recordInfo, UUID, Flavor } from "common";
|
||||
|
||||
export type WhatsappMessageId = Flavor<UUID, "Whatsapp Message Id">;
|
||||
|
||||
export interface UnsavedWhatsappMessage {
|
||||
whatsappBotId: string;
|
||||
waMessageId: string;
|
||||
waTimestamp: Date;
|
||||
waMessage: string;
|
||||
attachments?: string[];
|
||||
}
|
||||
|
||||
export interface SavedWhatsappMessage extends UnsavedWhatsappMessage {
|
||||
id: WhatsappMessageId;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
}
|
||||
|
||||
export const WhatsappMessageRecord = recordInfo<
|
||||
UnsavedWhatsappMessage,
|
||||
SavedWhatsappMessage
|
||||
>("app_public", "whatsapp_messages");
|
||||
|
||||
export class WhatsappMessageRecordRepository extends RepositoryBase(
|
||||
WhatsappMessageRecord
|
||||
) { }
|
||||
Loading…
Add table
Add a link
Reference in a new issue