feat: add db

This commit is contained in:
2026-09-14 18:27:27 +08:00
parent e4b77e1c11
commit 193e5fff31
9 changed files with 88 additions and 10 deletions
+3 -3
View File
@@ -61,7 +61,7 @@ async function handleRequest(request: BridgeRequest) {
}
case "listContacts": {
const contacts = await WPP.contact.getAllContacts();
const contacts = await WPP.contact.list();
const result = request.params?.limit
? contacts.slice(0, request.params.limit)
@@ -240,7 +240,7 @@ function start() {
/*
* Forward new-message events to Node.
*/
WPP.chat.on("chat.new_message", (message: unknown) => {
WPP.on("chat.new_message", (message: unknown) => {
if (socket?.readyState !== WebSocket.OPEN) {
return;
}
@@ -248,7 +248,7 @@ function start() {
send({
type: "event",
event: "message",
data: serialize(message),
data: serializeMessage(message),
});
});
});
+2
View File
@@ -163,6 +163,7 @@ export function serializeContact(contact: any): ContactDTO {
pushname: contact.pushname ?? null,
shortName: contact.shortName ?? null,
formattedName: contact.formattedName ?? null,
notifyName: contact.notifyName ?? null,
number: contact.number ?? null,
isMe: contact.isMe ?? false,
@@ -279,6 +280,7 @@ export function serializeMessage(message: any): MessageDTO {
forwardingScore: message.forwardingScore ?? 0,
isStarred: message.isStarred ?? false,
broadcast: message.broadcast ?? false,
notifyName: message.notifyName ?? null,
mentionedIds: Array.isArray(message.mentionedIds)
? message.mentionedIds.map(serializeId)
: [],
+3 -1
View File
@@ -52,11 +52,13 @@ declare const WPP: {
};
contact: {
getAllContacts(): Promise<any[]>;
list(): Promise<any[]>;
get(contactId: string): any | undefined;
};
group: {
getAllGroups(): Promise<any[]>;
};
on(event: string, callback: (...args: any[]) => void): void;
};